NivaarExam PrepOfficial exam papers ↗

25-Comp-A6 Software Engineering · May 2013

Question 3 of 9: Object-Oriented Design

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

Notes on this paper

National Exams — May 2013 — 98-Comp-A6 Software Engineering. Three-hour, closed-book exam, no calculator permitted. Format: nine questions, candidates answer any five of the nine (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 nine questions are solved below for completeness.

Reference texts: Sommerville, Software Engineering (10th ed., Pearson) — software process models, object-oriented and function-oriented design, software testing, dependability and critical systems, reliability metrics, configuration management, real-time software engineering; Pressman, Software Engineering: A Practitioner's Approach (9th ed.) — supplementary process and testing coverage; Gamma, Helm, Johnson & Vlissides, Design Patterns — object-oriented design vocabulary.

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

Applying the standard object-oriented design heuristic of extracting candidate objects from the nouns in the problem description, and merging those that turn out to be the same real-world concept, gives the following object model:

Household- address- vacationPeriods+ isOnVacation(date)Subscription- household- publication- round+ isActiveOn(date)+ dailyCopiesToday()Publication- title- unitPrice+ price()Newspaper- editionNoMagazine- issueNoDeliveryPerson- name- assignedRound+ dailyList(date)DeliveryRound- households[]- routeOrder+ summaryCounts(date)Bill- household- period- amountDue+ print()1..**..111generates monthlybilled toFig. Q3 — object model for the newspaper/magazine delivery system (associations labelled with multiplicity; open triangles = generalisation)
Fig. Q3 — object model for the newspaper/magazine delivery system.

Object Responsibilities and Behaviour

Household holds the customer's address and the list of vacation periods during which delivery must be suspended; its behaviour, isOnVacation(date), is consulted by every other object that needs to decide whether a delivery happens on a given day. Publication is an abstract class holding the shared attributes (title, unit price) common to Newspaper (which is sold daily and needs a daily "copies sold" count) and Magazine (which typically has a weekly or monthly issue cycle); factoring the shared behaviour into the Publication superclass and specializing only what differs is a direct application of inheritance to avoid duplicating the pricing and subscription-linking logic in both subclasses. Subscription is the association object linking one household to one publication on one delivery round; its isActiveOn(date) operation combines the household's vacation calendar with the subscription's own start/end dates, and dailyCopiesToday() reports whether this particular subscription contributes a copy to today's total. DeliveryPerson is assigned exactly one DeliveryRound, and its dailyList(date) behaviour asks every subscription on its round whether it is active today and assembles the printed household-by-household list. DeliveryRound aggregates the households on that route in delivery order and provides summaryCounts(date), which sums, per publication, how many active subscriptions across the whole round are due today — this is what produces the "copies of each newspaper sold each day" summary requested. Bill is generated once a month per household by summing that household's active subscriptions' prices over the billing period, and is printed for inclusion with the first delivery of the new month.

Check
Assumptions made: a household may hold more than one Subscription (e.g. one newspaper and one magazine, or two different newspapers), each on its own delivery round; billing is per household (one Bill aggregates all of that household's active subscriptions for the month) rather than per subscription; and a vacation period suspends delivery but not the subscription itself (billing is prorated by counting only the days a subscription was actually active, via isActiveOn).