Machine-translated by Google. Questions are authored in English.
Top

Discussion

Which design pattern is most suitable for decoupling components in an event-driven architecture ?

  • A.Singleton
  • B.Factory
  • C.Observer
  • D.Adapter

Answer: C

The pattern is Observer.

In the observer (publish-subscribe) pattern, a subject keeps a list of observers and notifies them when an event occurs, without knowing what they are or what they do. Components can be added or removed by subscribing or unsubscribing, which decouples event producers from consumers, the core of event-driven design.

Singleton ensures a class has one instance, factory centralises object creation, and adapter converts one interface into another. None of them is about delivering events between independent components.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.