volume_mute

Pattern Identification

publish date2026/06/13 06:39:43.844548 UTC

volume_mute

Classify each design scenario into the pattern that best solves it.

drag and drop the selected option to the right place

Correct Answer

(1) A music player app must update a waveform display, a track-time counter, and lyrics view simultaneously whenever the playback position changes,Observer
(2) A legacy codebase has dozens of interrelated subsystems with inconsistent interfaces; a new module needs a single clean interface to all of them,Façade
(3) A shopping cart object must be able to iterate over its list of items without exposing whether items are stored in an array, a linked list, or a database,Iterator
(4) A text editor needs to add spell-checking, grammar-checking, and auto-save features to documents at runtime without modifying the base Document class,Decorator

Explanation

Pattern mapping: Observer - multiple displays (waveform, timer, lyrics) that must update when a shared subject (playback position) changes; Façade - a single clean interface to a complex set of subsystems with inconsistent interfaces; Iterator - traversal of a collection independent of its implementation; Decorator - adding functionality (spell-check, grammar-check, auto-save) to an existing class at runtime without modifying it.

Reference

Software Engineering, Ian Sommerville, 10th edition


Quizzes you can take where this question appears