sean-barton - 2021-09-01

I have a list of Ingredients where each Ingredient contains a structure of variables.

The structure of variables is common to all Ingredients; however, occasionally an Ingredient will have a unique variable, in which case the variable is not in the structure but defined as a class variable.

I have separated the Ingredients into classes, 'Ingredient' being the base class and other derived classes with unique parameters and overridden methods.

When I create a list of Ingredients, only the structure of variables is passed to the list, and child ingredients extra parameters are lost.

I cannot create a list of Ingredient interfaces because of the way the system persists objects - only instantiated objects may be persisted (stored to file).

Do I just add the parameters of the child class to the structure of variables even though the parameter won't be used in most cases? This seems 'clunky' to me, but I can't seem to think of another way to save the parameter data. I'm trying to make this as object oriented as I can.