Nivaar Exam Prep

25-Comp-B11 Advanced Software Design · May 2014

Question 16 of 25: Observer Roles vs. Boundary/Entity Classes

Nivaar worked solution (AI-drafted; not reviewed by a licensed engineer) · Last updated

Notes on this paper

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). 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

Question 16: Observer Roles vs. Boundary/Entity Classes (Part III)

Question text not reproduced: the examination questions are © Engineers and Geoscientists BC. Open the official past paper (linked at the top of this page) to read the question, then follow the worked solution below.

The Boundary/Control/Entity (ECB) classification is a REQUIREMENTS-ANALYSIS-level responsibility category (what role a class plays with respect to actors, data, or use-case control flow), while Subject/Observer is a DESIGN-level, GoF pattern role (who publishes state changes, who subscribes to them). These are ORTHOGONAL classifications, so no ECB role is bound to a particular pattern role.

ConcreteSubject. "The object whose state changes matter to others" is very commonly an ENTITY (e.g., a StockPrice or SensorReading data object), but it need not be: a CONTROL class tracking the current step of a long-running workflow can itself be a ConcreteSubject, notifying several UI panels whenever the workflow's control-state advances. The "subject" role only requires "has state that other objects care about"; Entity, Control, and even Boundary classes can all satisfy that.

ConcreteObserver. "The object that reacts to a notification" is very commonly a BOUNDARY class (a GUI widget refreshing its display when notified — the classic use case, and the mechanism underlying MVC's Model-to-View notification in Question 18), but it need not be: a CONTROL class can observe another object purely to trigger further internal processing with no display involved at all — e.g., a logging/audit Control class observing a domain object to persist an audit trail, or a Control class recalculating a derived value whenever an upstream Entity changes. Nothing in the Observer contract (register interest, get notified, react) requires that reaction to be a screen update.

Conclusion. Observer's Subject/Observer roles describe the NOTIFICATION RELATIONSHIP, which is independent of WHY a class exists in the requirements model (data storage vs. use-case control vs. actor interface). Treating a design pattern's structural role as if it were itself a requirements-analysis responsibility category is a category error.