O'Reilly logo

Applying UML and Patterns: An Introduction to Object-Oriented Analysis and Design and the Unified Process, Second Edition by Craig Larman

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

17.6. Object Design: endSale

The endSale system operation occurs when a cashier presses a button indicating the end of a sale. Here is the contract:

Contract CO3: endSale

Operation:endSale()
Cross References:

Use Cases: Process Sale

Preconditions:There is an underway sale.
Postconditions:Sale.isComplete became true (attribute modification).

Choosing the Controller Class

Our first choice involves handling the responsibility for the system operation message endSale. Based on the Controller GRASP pattern, as for enterItem, we will continue to use Register as a controller.

Setting the Sale.isComplete Attribute

The contract postconditions state:

  • Sale.isComplete became true (attribute modification).

As always, Expert should be the first pattern considered ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required