I have an already existing order class with many properties and methods. I need to now create a suborder class which is a subset of the order class. It not only has many of the fields that order class has, it also would have many of the same calculation methods maybe with one or two lines of difference in some places. The order class then needs to contain a list of suborder objects. How would I go about creating the suborder class? Should I derive it from the order class?
Share
It seems to be a case for refactoring…
Although the Order class readily exists, it appears that some of its properties and methods need to be moved to the OrderSubClass.
If somehow some of the properties and behaviors of the two class are common, creating a common base class (or an interface) may be appropriate as well.
Once the above is arranged, the Order class can become a container for SubOrders, which seems to be the direction indicated in the question.