Lets say I'm trying to model a variety of objects that are virtually identical, the only difference being their class variables. Am I better off creating one boilerplate class and just calling the constructor with the specific variables, or creating a lot (in this case 100+) of essentially identical classes and hard coding their class variables (which will never change)?
To be clear:
- Identical methods
- Identical class variable names but different values
- Identical intended functionality
To be clear, my language (Python) doesn't support interfaces that I'm aware of - some of the other similar questions seemed to get answers recommending that. The other option that seems to make sense to me would be to create a base class with each field and method and then create a bunch of unique child classes that contain their unique values.
The amount of work to create all the child classes isn't significant to me - I've written a program that quickly parses a text file (that has all the unique values) and can write all the classes to a .py file quickly and easily. Making changes down the road is rather easy for the same reason.
(somewhat) Related questions