Developing Applications and Automating Workflows Using Cisco Platforms (DEVASC) — Question 294

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?

Answer options

Correct answer: D

Explanation

The correct answer is D, loose coupling, as it allows dependent classes to operate independently of the object, promoting greater flexibility. Tight coupling (A) refers to strong dependencies, which is contrary to the goal of the observer pattern. Cohesion (B) relates to how closely related functionalities are within a single class, and mediation (C) involves an intermediary, which is not a direct advantage of the observer pattern.