200-901 · Question #347
A developer creates a program in which an object maintains a list of classes based on the observer pattern. The classes are dependent on the object. Whenever the state of the object changes, it…
The correct answer is D. loose coupling. In the observer pattern, the observed (subject) object maintains a list of its dependents (observers or listeners), and these dependents are notified of any state changes in the observed object through callbacks or notifications. The key benefit of this pattern is that it…
Question
A developer creates a program in which an object maintains a list of classes based on the observer pattern. The classes are dependent on the object. Whenever the state of the object changes, it notifies the dependent classes directly through callbacks. Which advantage of the observer pattern offers minimum dependencies and maximum flexibility between dependent objects or classes?
Options
- Atight coupling
- Bcohesion
- Cmediation
- Dloose coupling
How the community answered
(63 responses)- A8% (5)
- B2% (1)
- C5% (3)
- D86% (54)
Explanation
In the observer pattern, the observed (subject) object maintains a list of its dependents (observers or listeners), and these dependents are notified of any state changes in the observed object through callbacks or notifications. The key benefit of this pattern is that it promotes loose coupling between the subject and its observers. The subject doesn't need to know the specific details of its observers, and observers can be added or removed without affecting the subject.
Topics
Community Discussion
No community discussion yet for this question.