I have a design question. Just for reference, I believe this an implementation of the composite pattern. If not, let me know what pattern this fits into. I have a class called Sprite, ICollidable, IController. I also have Managers, a physics manager and a Render manager. A Collidable object references a sprite, a controller also references a sprite. If I want to turn on collision for a sprite, I just create a Collidable object referencing my sprite and then add it to the physics manager. Same if I want to make it move. I create a controller object and reference the sprite and then add it to the Physics manager (in the controller list. I may move this to a different manager). I would like to be able to have any one class to delete the underlying sprite and all classes referencing the sprite to be informed. I need it to propagate upwards to inform all of the objects that reference it so it knows to not reference it anymore. So for instance, if the Sprite object is deleted, then the ICollidable object needs to be informed who in turn needs to inform the physics manager. The physics manager is not aware of the underlying Sprite object so it cannot be directly informed.
I am just starting down this path and worry about future performance. I know that I should not worry about performance, but this construct is going to be used a lot and I don't want to find out when it is too late. Has anyone used something similar or is there a different way to solve the problem above that may lead to better results?
Some things I have thought of are:
1. Straight inheritance -> better performance, but does not as flexible
2. Checking the state of the object before use -> seems like it would have really bad performance since I will use way more often than I will delete it
3. Treating each object in the hierarchy as a bi-directional linked tree node so that I can traverse up and down to delete all of the objects. -> seems to lose a lot of flexibility and will probably require that each class who wants to participate to inherit from a base class.
I hope my intention is clear.








