Summary

The OBSERVER pattern appears most frequently in GUI applications and is a fundamental aspect of Java's Swing architecture. With Swing, you never have to change or subclass a component class just to communicate its events to an interested object. For small applications, a common practice is to register a single object to receive all the events in a GUI. Doing so has no inherent problem, but you should recognize that it reverses the distribution of responsibility that OBSERVER intends. For a large GUI, consider letting each interested object register for events rather than introducing a mediator.

OBSERVER lets you delineate the responsibility between business objects and a GUI, which allows you to establish an MVC design. MVC lets you create ...

Get Design Patterns Java™ Workbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.