NivaarExam PrepOfficial exam papers ↗

25-Comp-A6 Software Engineering · Undated paper

Question 2 of 8: Software Design and Object-Oriented Design

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

Notes on this paper

National Exams — 17-Comp-A6 Software Engineering. Three-hour, closed-book exam, no calculator permitted. Format: eight questions, candidates answer any five (all questions equal weight — each of the five counted questions is worth 20%; any five questions constitute a complete paper, and only the first five as they appear in the answer book are marked). All eight questions are solved below for completeness. The page-1 heading reads "National Exams.

Reference texts: Sommerville, Software Engineering (10th ed., Pearson) — software process models, object-oriented and function-oriented design, software reuse and portability, dependable/critical systems, distributed software engineering, configuration management, reliability metrics; Pressman, Software Engineering: A Practitioner's Approach (9th ed.) — supplementary process and testing coverage; Leveson, Safeware — hazard and fault-tree analysis for safety-critical software.

Question 2: Software Design and Object-Oriented Design (a) 10, (b) 10 — 20 marks

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.

(a) Object-Oriented vs. Function-Oriented Design

Function-oriented design decomposes a system top-down into a hierarchy of functions (procedures) that transform input data into output data, typically documented as data-flow diagrams and structure charts. Data is treated as a separate, often shared or global, resource that flows between functions; the functions themselves are the primary unit of decomposition and reuse. Object-oriented design instead decomposes the system into objects, each of which bundles together a piece of state (its attributes) and the operations that are allowed to act on that state, and objects collaborate by sending each other messages (calling one another's operations) rather than by all reaching into a common pool of data.

The practical consequence is that function-oriented systems are easy to reason about for simple, well-defined data transformations (batch reports, numerical pipelines) but scale poorly as systems grow: because state is shared, a change to a data structure's representation can ripple through every function that touches it, producing the classic "change amplification" problem. Object-oriented design's information hiding — each object exposes only an interface and hides its internal representation — localizes the impact of a representation change to the object itself, and its support for inheritance and polymorphism gives a natural mechanism for extending and reusing behaviour. The trade-off is that object-oriented designs generally require more up-front design effort to identify the right objects and their responsibilities, and the extra layer of indirection (message passing between many small objects) can make the control flow of the finished system harder to trace by eye than a single top-down function hierarchy.

(b) Object-Oriented Design of the Insulin Delivery System

Applying the standard object-identification heuristic — underlining the nouns implicit in the scenario ("micro-sensor", "pump controller", "miniaturized pump", "needle") and separating what senses, what decides, and what physically acts — gives four collaborating objects, plus a fifth introduced deliberately as an independent safety check rather than derived from the narrative's nouns directly.

BloodSensor- sensorId- calibrationOffset+ read(): sugarLevel+ selfTest(): ok PumpController- targetRange- maxDosePerCycle+ controlLoop()+ computeDose(sugarLevel):dose+ notifyAlarm(condition)+ handleStopCommand() SafetyLimiter- hardMaxDose+ clamp(dose): safeDose(independent hardware,not overridable by software) InsulinPump- reservoirLevel- needleAttached+ dispense(safeDose) AlarmManager+ raise(condition)+ acknowledge() read(): sugarLevel computeDose() clamp():safeDose notifyAlarm()
Fig. Q2(b) — five collaborating objects: sensing (BloodSensor), decision (PumpController), independent hardware enforcement (SafetyLimiter), actuation (InsulinPump), and fault reporting (AlarmManager).

BloodSensor wraps the micro-sensor embedded in the patient, exposing only a calibrated read() operation that returns a sugar-level reading and hiding the raw analog signal path and calibration behind it. PumpController is the central decision object: its controlLoop() periodically calls BloodSensor.read(), passes the reading to computeDose() to derive a candidate insulin dose from the current target range, and forwards that candidate dose onward — but, critically, not directly to the pump. SafetyLimiter sits between the controller and the pump specifically because it must never be reachable through the same software path that computed the candidate dose: its clamp() operation is implemented as independent hardware logic (not a software class the PumpController can bypass or reconfigure) that caps whatever dose it is given at a fixed, separately-verified maximum, so that a single defect in PumpController's dosing algorithm cannot by itself cause the delivered dose to exceed a hard physical ceiling. InsulinPump is a thin actuator object whose only externally visible operation, dispense(safeDose), physically delivers the already-clamped dose via the permanently attached needle; it never receives an unclamped dose. AlarmManager is notified by PumpController whenever a hazardous condition is detected (a sensor reading outside plausible bounds, a candidate dose the SafetyLimiter had to clamp, a stop command that fails to take effect) and is kept as a separate object precisely so that alarm-handling logic can be tested, and reasoned about, independently of the dosing logic itself.

Check — assumptions
The scenario's own text describes a single sensor and a single pump feeding a single needle, so the design above assumes one BloodSensor/InsulinPump pair per patient (no sensor redundancy at the class-diagram level, though Question 5's fault-tree analysis of this same system recommends dual redundant sensors as a further fault-tolerance measure layered on top of this base design). The independent-hardware SafetyLimiter interposed between PumpController and InsulinPump is not explicitly requested by this question's text but is adopted directly from the design implication reached in Question 5(b)'s fault-tree analysis of the identical system (a single-point software fault must not be able to cause an overdose on its own) — stated explicitly here as a reasonable assumption per the question's own instruction to make and state assumptions.