NivaarExam PrepOfficial exam papers ↗

25-Comp-A6 Software Engineering · May 2015

Question 3 of 8: Object-Oriented Software Design

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

Notes on this paper

National Exams — May 2015 — 98-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%; only the first five questions as they appear in the answer book are marked). All eight questions are solved below for completeness.

Reference texts: Sommerville, Software Engineering (10th ed., Pearson) — software process models, function-oriented and object-oriented design, software testing, distributed software engineering, real-time software engineering, reliability engineering, verification and validation; Pressman, Software Engineering: A Practitioner's Approach (9th ed.) — supplementary process/testing coverage; Coulouris, Dollimore, Kindberg & Blair, Distributed Systems: Concepts and Design — scalability, distributed objects, client-server architectures.

Question 3: Object-Oriented Software 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

Applying the standard noun-extraction heuristic to the problem description (entry/smoke/temperature/flood sensors, alarms, lights, phone numbers, keypad, thresholds, delays) and merging duplicates gives an abstract Sensor class with four concrete subclasses (one per sensor type, sharing a common polling/threshold interface), a coordinating SecuritySystem object that holds the armed/disarmed state and owns a Configuration object (thresholds, phone numbers, delays), a Keypad object for owner interaction, and three independent output/actuator objects (AlarmController, LightController, PhoneDialer).

SecuritySystem- state (Armed/Disarmed)- config: Configuration+ armSystem(), + disarmSystem(pin)+ handleEvent(SensorEvent)+ setThreshold(), + setDelay()Sensor (abstract)- id, - threshold+ poll(): SensorEventEntrySensor / SmokeSensor / TemperatureSensor / FloodSensor(concrete subclasses)Keypad- enteredCode+ readKey(), + verifyPin(pin)Configuration- thresholds[], - phoneNumbers[]- delays[]+ get()/set() per fieldAlarmController+ soundAlarm(), + silence()LightController+ turnOn(zone)PhoneDialer- numbers[]+ dialNext(), + notifyOwner()sensor eventsPIN / programread configalarm eventlight triggerdial request
Fig. Q3 — object model for the microprocessor-based Home Security System.

SecuritySystem is the coordinating object: it holds the current arm state (Armed/Disarmed), owns the Configuration, and its handleEvent() operation is invoked whenever any sensor reports an event, applying the configured threshold/delay logic before deciding whether to trigger an alarm. Sensor is an abstract base class defining a common poll() interface returning a SensorEvent; EntrySensor, SmokeSensor, TemperatureSensor and FloodSensor are its concrete subclasses, each knowing only how to read its own physical transducer and compare against its own threshold — polymorphism lets SecuritySystem treat every sensor type uniformly through the common interface rather than needing a type-specific branch for each. Keypad handles owner interaction (PIN entry to arm/disarm, and PIN-gated access to programming mode) and writes new thresholds, phone numbers and delays into Configuration, which is simply a structured store of the owner-settable parameters, decoupled from both the sensors that read it and the keypad that writes it. AlarmController, LightController and PhoneDialer are independent output objects, each responsible for exactly one physical actuation (sounding/silencing the siren; turning on the selected light zone; dialling the owner's programmed numbers in sequence) and each triggered only by SecuritySystem, never directly by a sensor — this keeps the decision of whether and how to respond to an event in one place.

Check — assumptions
Entry-sensor alarms are assumed to honour a programmed entry delay (to allow the owner to disarm after entering) while smoke and flood sensors are assumed to bypass any delay and trigger immediately, since they protect against life-safety/property hazards rather than intrusion and the question does not distinguish delay behaviour by sensor type. Disarming is assumed to require the correct PIN entered at the Keypad within a fixed number of attempts; a lockout or silent-alarm response after repeated failed attempts is a reasonable extension but is not specified, so it is not designed here. PhoneDialer is assumed to retry the owner's programmed numbers in the order entered until one is answered/acknowledged or the list is exhausted.