01.01.2015 Views

UML Weekend Crash Course™ - To Parent Directory

UML Weekend Crash Course™ - To Parent Directory

UML Weekend Crash Course™ - To Parent Directory

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

70<br />

Saturday Morning<br />

Much of this language is borrowed from the “programming by contract” concept, developed<br />

and implemented by Bertrand Meyer in the creation of the Eiffel programming language. One<br />

chief goal of the programming by contract concept is to define each unit as autonomous,<br />

whether the unit is an object or a Use Case. Each unit should remain as independent from<br />

others as possible, also referred to as being loosely coupled. Unit independence allows each<br />

unit to be maintained without requiring corresponding changes in other units. This reduces<br />

the cost of development and maintenance of the system.<br />

Assumptions<br />

Typically, developers think of assumptions as bad, something to be avoided. Here, I’m applying<br />

the concept in a positive way. In order for the Use Case to work properly, certain conditions<br />

must be true within the system.<br />

You agree, or you contract, never to invoke this Use Case unless you know that all the<br />

needed conditions have been met. In other words, assumptions describe a state of the system<br />

that must be true before you can use the Use Case. These conditions are not tested by<br />

the Use Case (contrast this later with the pre-conditions). For example, consider the tasks<br />

of performing authentication and authorization. A standard security check feature typically<br />

handles these functions. Each subsequent Use Case assumes that the user could not access<br />

the Use Case had he not made it past the security check. Consequently, you would rarely if<br />

ever include the security check in each Use Case.<br />

So how does this help you with the design of the system If one Use Case can’t work and<br />

should not even be accessed unless another Use Case has first done its job, this condition<br />

dictates the order of execution. The assumptions give you explicit clues about the sequence<br />

of execution for Use Cases (that is, the workflow).<br />

Tip<br />

Place common Use Case assumptions into a system-level document instead<br />

of including them in every Use Case narrative.<br />

Pre-conditions<br />

Pre-conditions are easily confused with assumptions. Like assumptions, pre-conditions<br />

describe a state of the system that must be true before you can use the Use Case. But unlike<br />

assumptions, these conditions are tested by the Use Case before doing anything else. If the<br />

conditions are not true, the actor is refused entry.<br />

Most programmers have coded pre-conditions nearly every time they write a method or<br />

subroutine call that has parameters. When you write code, what are the first lines of code<br />

that you write in a function or method that has parameters You validate the parameters.<br />

You test to make certain that the conditions are right to proceed with the rest of the code.<br />

Failure in these tests would mean problems for the subsequent code, so the call is refused<br />

and turned back to the requester. You established and tested the pre-conditions for execution<br />

of your method or function.<br />

These rules or pre-conditions need to be published along with the interface to your Use<br />

Case. For example, a typical interface can only tell the client to provide two integer values<br />

and a character string. It can’t tell them the rules that say that the first integer must be a

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!