A program must represent a delivery, store its destination and status, and allow the status to be updated. Which first-pass design best matches the requirement?
Destination • Attribute: Delivery • Behavior: statusDelivery • Attributes: destination, status • Behavior: updateStatusStatus • Attributes: updateStatus, Delivery • Behavior: noneProgram • Attributes: none • Behavior: destinationExplanation
A first-pass design reads the requirement and sorts its words into three roles. The noun the program is about names the class; the values that describe each one become attributes; the actions the requirement asks for become behaviors. Here the requirement is about a delivery that stores a destination and a status and can have its status updated, so each part lands in exactly one role.
- A is not correct: it makes
Destinationthe class andDeliveryan attribute, which reverses the thing being represented and one of its descriptive values. - C is not correct: it lists
updateStatusas an attribute even though it is the action the requirement asks for, and it leaves the design with no behavior at all. - D is not correct:
Programnames the whole application rather than the thing being modelled, and it treatsdestination, a stored value, as a behavior.