Software Development and Project Management

Which GoF design pattern makes the objects that depend on an object be notified automatically when that object's state changes?

  1. AObserver
  2. BSingleton
  3. CAdapter
Show answer and explanation

Answer: A. Observer

In the Observer pattern, the notifying object (the subject) keeps a list of registered objects that want notifications (observers) and informs all of them when its state changes. The subject does not need to know the concrete classes of the observers, which keeps coupling weak. For example, it can be used in a design that informs display, logging and alarm processing when a sensor value changes. Singleton is a pattern that ensures a class has only one instance, and Adapter is a pattern that converts a mismatched interface so that classes can work together.

  • A. Correct. Changes of state are notified to several registered objects.
  • B. This pattern ensures a class has only one instance; it is not a notification mechanism.
  • C. This pattern connects classes with mismatched interfaces by converting between them.
Practice this topic Back to topic

Related calculators

Books on Software Development and Project Management Ad

As an Amazon Associate I earn from qualifying purchases.

More Software Development and Project Management questions

  1. When a static analysis tool is used on firmware source code, which problem is it best suited to finding without running the program?
  2. Which describes black-box testing?
  3. An input field accepts only integers; values from 1 to 100 inclusive are accepted and all others cause an error. When the input is divided by equivalence partitioning, how many equivalence classes are there in total (valid and invalid classes combined)?
  4. A program sets the admission fee by age (an integer of 0 or more): ages 0 to 17 pay the child fee, 18 to 64 the adult fee, and 65 or older the senior fee. Which set of test values is most appropriate for boundary value analysis to check the boundaries where the fee category changes?
  5. The specification says 'issue a warning if the temperature is 85 °C or higher', but the firmware mistakenly contains 'if (t > 85)'. The temperature t is an integer. Which of the following test values can detect this error?