This part will be a short one because I have to pack for my vacation. Yes, I will leave this cold and miserable weather, heading south to fill up my energy again (I am running on solar power).
Last time we switched from a static approach to an instance based one and introduced a register-method to allow adding Singletons from everywhere. There are several issues with this approach:
- doesn’t support lazy initialization, so far only eager initialization was done
- sometimes not all necessary information is available at register time to actually create the Singleton instance
- maybe you want to track, creation, requesting, and so forth of the Singleton.
Sounds complicated and scary? It isn’t, delegation is our friend again. Another way would be the observer (listener) pattern to address the above mentioned issues, however, delegation is more elegant and appropriate for this task.
