25-Comp-B11 Advanced Software Design · December 2014
Question 21 of 26: Design Patterns Paramount to GUI Design
Nivaar worked solution (AI-drafted; not reviewed by a licensed engineer)
Notes on this paper
98-Comp-B11 Advanced Software Design — National Exams, December 2014. 3 hours, closed book, no calculator permitted. The paper is organized into five parts, and candidates were instructed to answer any three (3) questions in Part I, any four (4) in Part II, any four (4) in Part III, any two (2) in Part IV, and any two (2) in Part V — only the first questions answered, in each part, as they appear in the answer book are marked. All questions carry equal weight, so the 15 questions actually marked (3+4+4+2+2 of 26) each count for 100/15 ≈ 6.7% of the paper. All 26 questions are answered below for completeness.
Reference texts: Sommerville, Software Engineering (10th ed., Pearson) — software processes, requirements engineering, agile methods, design principles; Pressman, Software Engineering: A Practitioner's Approach (9th ed.) — supplementary process and quality coverage; Gamma, Helm, Johnson & Vlissides (GoF), Design Patterns: Elements of Reusable Object-Oriented Software — structural/behavioural pattern catalogue (Proxy, Bridge, Strategy, Observer, Template Method, Composite, etc.); Sebesta, Concepts of Programming Languages (12th ed.) — polymorphism, dynamic binding, inheritance and language-level object semantics (also underpins the Java/C++ discussion in Part V); Brown, Malveau, McCormick & Mowbray, AntiPatterns: Refactoring Software, Architectures, and Projects in Crisis — anti-pattern catalogue (Question 18). Bertrand Meyer's Object-Oriented Software Construction is cited by name where the paper's own vocabulary (design by contract, open–closed principle) originates there; Barbara Liskov's 1987 substitutability paper is likewise cited by name for Question 11.
PART I — General Principles (answer any 3 of 5)
Question 21: Design Patterns Paramount to GUI Design (Part IV)
Composite. A GUI widget tree (a Window containing Panels containing Buttons/Labels and further nested Panels) is the canonical Composite structure: individual widgets (leaves) and containers of widgets (composites) are treated UNIFORMLY through a common Component interface (e.g., draw(), layout(), handleEvent()), letting the framework recursively render, lay out, and dispatch events through an arbitrarily deep widget tree using the SAME code, without ever special-casing "is this a single widget or a container." Virtually every GUI toolkit's scene graph or widget hierarchy is built as a Composite.
Observer. A GUI display must stay synchronized with underlying application/model state without the Model needing any knowledge of which, or how many, Views currently display it (Question 19) — each widget registers as an Observer of the Model (or of a lower-level GUI-side model such as a list/table model) and is notified to repaint itself whenever that state changes. Without Observer, the Model would need direct references to every UI component displaying it, coupling business logic to specific UI classes — exactly the coupling Question 20 argues against.
Justification for these two over the other six. Composite and Observer are the two patterns a GUI toolkit fundamentally CANNOT be built without: a toolkit has no way to represent a widget hierarchy at all without Composite, and no way to keep any display synchronized with changing data without Observer. The remaining six (Adapter, Bridge, Command, Decorator, Façade, Proxy) are all genuinely useful in GUI work — Command in particular is strong for decoupling menu items/toolbar buttons from the action they trigger and enabling undo/redo — but each solves a narrower sub-problem layered on top of a widget tree (Composite) that stays synchronized with data (Observer), rather than being foundational to the toolkit's own existence.