NivaarExam PrepOfficial exam papers ↗

25-Comp-A6 Software Engineering · May 2016

Question 3 of 8: Object-oriented Design

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

Notes on this paper

Paper: 98-Comp-A6, Software Engineering — 2016-May, 3 hours, closed book, no calculators. Answer any five of the eight questions; all five count equally (20 marks each, 100 total). All eight questions are answered below.

Reference texts: Sommerville, Software Engineering (10th ed., Pearson) — software process models, object-oriented and function-oriented design, real-time systems, software testing, formal methods, rapid software development, client-server/distributed architectures; Pressman, Software Engineering: A Practitioner's Approach (9th ed.) — supplementary process/testing coverage; IEEE/ISO 12207 — software life-cycle processes; SWEBOK — body-of-knowledge cross-reference.

Question 3: Object-oriented Design (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.

Identifying the Objects

Extracting candidate objects from the nouns of the requirement (sensor, base station, central monitoring station) and specializing the sensor concept into its four stated variants gives an object model built around an abstract Sensor superclass:

Sensor (abstract)- id, - zone, - enabled+ enable(), + disable()+ checkState() [abstract]+ reportTrigger()DoorWindowSensor+ checkState()open/closed contactSmokeSensor+ checkState()always-activeWaterSensor+ checkState()always-activeMotionDetector+ checkState()armed-onlyBaseStation- armed, - sensors[]+ arm(), + disarm()+ toggleSensor(id)+ onSensorTriggered(s)+ soundAlarm()AlarmSounder+ sound(), + silence()CentralMonitoringLink+ notifyAlarm(zone,type)+ heartbeat()1..*Internet
Fig. Q3 — abstract Sensor superclass specialized into the four required sensor types, all owned by one BaseStation.

Object Responsibilities and Behaviour

The abstract Sensor class factors out what all four wireless devices share — an id, an assigned zone, an enabled/disabled flag toggled from the base station, and the ability to report a trigger event upward — leaving only checkState() abstract, since how each subclass actually senses (a contact switch for DoorWindowSensor, an ionization/photoelectric element for SmokeSensor, a conductivity probe for WaterSensor, a PIR element for MotionDetector) genuinely differs. BaseStation is the coordinating object: it owns the full set of installed sensors, holds the system's armed/disarmed state, and exposes the two owner-facing operations the requirement calls for — arm()/disarm() for the whole system and toggleSensor(id) for an individual sensor. Its onSensorTriggered(s) operation is called by any enabled sensor that detects an event; if the system is armed, it invokes AlarmSounder.sound() locally and CentralMonitoringLink.notifyAlarm(zone, type) over the Internet to the monitoring company. CentralMonitoringLink is kept as its own object (rather than folding the network call directly into BaseStation) specifically so the Internet-connectivity concern — retries, connection loss, heartbeat keep-alives to the monitoring station — is isolated behind one narrow interface, matching the cohesion/coupling reasoning of Question 2(a): BaseStation's own logic never needs to know how the notification actually reaches the monitoring station.

Check
Assumptions made explicit for this design: smoke and water sensors are always active regardless of the armed/disarmed state (they protect against life-safety/property hazards, not intrusion), while door/window and motion sensors are subject to the owner's per-sensor enable/disable toggle and are only treated as alarm-worthy while the system is armed; toggleSensor(id) can disable a sensor entirely (e.g. a pet-triggered motion detector) independent of the overall armed state, per the requirement's "turn on or off any of the sensors individually" wording; and CentralMonitoringLink retries its notification and raises a local fault indication on BaseStation if the Internet connection itself is down, since an unreachable monitoring station on a genuine intrusion is the single most safety-critical failure mode of this design.