11.10.2013 Views

Slides Part 2 (OOA, pages 1-128, pdf, 4 slides per page)

Slides Part 2 (OOA, pages 1-128, pdf, 4 slides per page)

Slides Part 2 (OOA, pages 1-128, pdf, 4 slides per page)

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Excursion: Design by Contract<br />

What are preconditions and postconditions good<br />

EXAMPLE<br />

I want to travel from Berlin to Duisburg.<br />

for?<br />

Commitments Advantages<br />

Passenger Pay ticket getting to Duisburg<br />

Traffic<br />

provider<br />

73<br />

Be there at departure time<br />

must keep precondition Has advantages from the postcondition<br />

Must take the passenger to<br />

Duisburg<br />

receives the price for the ticket;<br />

does not have to take passengers<br />

who have not paid or did not arrive<br />

in time<br />

Must guarantee postcond. Can assume precondition<br />

75<br />

SOURCE<br />

Bertrand Meyer<br />

Object-Oriented Software Construction<br />

Prentice Hall 1988 (1. Aufl.), 1997 (2. Aufl.)<br />

online see:<br />

http://archive.eiffel.com/doc/manuals/technology/contract/<strong>page</strong>.html<br />

CONTRACTS IN DAILY LIFE<br />

➠ Contractual partners are clients and sellers or service providers.<br />

➠ Both expect advantages from the contract and are willing to make a<br />

commitment.<br />

ADVANTAGES OF EXPLICIT CONTRACTS<br />

Meyer:<br />

74<br />

A contract document protects both the client, by specifying how much<br />

should be done, and the supplier, by stating that the supplier is not<br />

liable for failing to carry out tasks outside of the specified scope.<br />

APPLICATION TO SOFTWARE<br />

A contract is a formal agreement between a system / a class and its actors /<br />

clients. It specifies the rights and duties for both sides.<br />

76

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

Saved successfully!

Ooh no, something went wrong!