I am creating a main object, MACHINE, which will contain a diversity of several other objects -- AXIS, AMPLIFIER, ENDEFFECTOR, etc. The number of contained objects will vary depending on the MACHINE model object that I am using.

For example, a certain machine might have one AXIS and one ENDEFFECTOR; another 3 AXIS and 2 ENDEFFECTORS, etc.

I was planning to create subclasses with each machine model, and initialize the respective number of contained objects depending on the model. My fear is that there is going to be an explosion of machine models, as well as quite a lot of repeated code and settings among subclasses.

I get the feeling that there is a cleaner way to implement this, but I am not sure how to. Any ideas will be greatly appreciated.

没有正确的解决方案

许可以下: CC-BY-SA归因
scroll top