I have been researching this all day, and I haven't found a good solution yet.
Before we get started: if you think the answer is "singleton", it isn't, singletons are not allowed in the project. Don't ask me why, cause I do not want to go in that discussion again. :)
So here goes (it is just an example):
- Object X of class A (only one instance is allowed to exist, but it needs to be created)
- Object X has a certain property like $color = 'green';
- All objects of class B that are created get the value of that property.
- When the property of Object X changes to $color = 'red'; all new objects of class B that are created will get the new value
- If an object of class B is create when one of class A does not exist yet, the object of class A needs to be created
The question now ... how do I build my classes, and make sure only one instance of class A is created?
Am I making sense?