L18Exercise-DesignPatternsWorkSheet
L18Exercise-DesignPatternsWorkSheet
Exercise 1: An object is loosely coupled if it is dependent on only a few other objects and/or the
dependencies are abstract. In the Observer design pattern, the subject may have
hundreds of observers (dependencies). In light of this, explain why the Observer
design pattern is said to be loosely coupled.
Exercise 2: Consider the code for the Singleton design pattern given below. Modify this code so
that at most 5 instances are created and each instance can be individually referenced.
Note that the keyword static indicates a class attribute/operation.
private Singleton() { }