volume_mute
Four Common Design Pattern Problems
publish date: 2026/06/12 10:18:12.488833 UTC
volume_muteThe Gang of Four documented problems that commonly arise in OO design. Match each problem to the pattern that solves it.
To complete the line match
- Click on an item in the first group
- Click on the match in the second group
To delete a match, double click on a line
Problem
Tell several objects that the state of some other object has changed
Tidy up the interfaces to a number of related objects that have often been developed incrementally
Provide a standard way of accessing the elements in a collection, irrespective of how that collection is implemented
Allow for the possibility of extending the functionality of an existing class at runtime
Pattern
Decorator
Façade
Observer
Iterator
Correct Answer
(1) Tell several objects that the state of some other object has changed,Observer
(2) Tidy up the interfaces to a number of related objects that have often been developed incrementally,Façade
(3) Provide a standard way of accessing the elements in a collection, irrespective of how that collection is implemented,Iterator
(4) Allow for the possibility of extending the functionality of an existing class at runtime,Decorator
Explanation
Pattern-problem mapping: Observer - notifying multiple objects of a state change; Façade - providing a clean unified interface to a set of related objects (especially useful when subsystems have grown incrementally and have messy interfaces); Iterator - standard traversal of a collection regardless of implementation; Decorator - runtime extension of an existing class without modifying the class itself.
Reference
Software Engineering, Ian Sommerville, 10th edition
