• Shuffle
    Toggle On
    Toggle Off
  • Alphabetize
    Toggle On
    Toggle Off
  • Front First
    Toggle On
    Toggle Off
  • Both Sides
    Toggle On
    Toggle Off
  • Read
    Toggle On
    Toggle Off
Reading...
Front

Card Range To Study

through

image

Play button

image

Play button

image

Progress

1/14

Click to flip

Use LEFT and RIGHT arrow keys to navigate between flashcards;

Use UP and DOWN arrow keys to flip the card;

H to show hint;

A reads text to speech;

14 Cards in this Set

  • Front
  • Back

What are assertions?

Preconditions, postconditions and invariants are collectively known as assertions, which are statements that are, in theory at least, either true or false. Assertions specify details of the requirements that cannot be represented graphically.

In the analysis phase of system development that you studied in Units 3 and 5, what were the assertions (preconditions, postconditions and invariants) used for?

Assertions were used for placing constraints on the relationships between classes.

Explain why pre- and postconditions express a contract between a client object and a supplier object.

The contract is expressed by:


  • the precondition requiring something from the client object that is of benefit to the supplier object
  • the postcondition requiring something from the supplier object that is of benefit to the client object.

What is meant by the term design by contract (DbC)?

DbC is the process of developing software based on the notion of a contract between objects.

To what extent can DbC help with traceability, and hence be used to improve the quality of a software system?

DbC allows the development of a software system to be traced from requirements through to code.

What is the relationship between the client’s and supplier’s obligations and benefits?

A client’s obligations to constrain inputs provide benefits to a supplier in that fewer input cases need to be considered as there are less input. A supplier’s obligations to produce outputs satisfying certain constraints mean that a client can expect to receive a clearly defined service.

What does weakening a precondition mean in terms of the provision of a service?

Weakening a precondition means generalising the situation in which a service can be provided. In general, this means that it is easier for the client to satisfy the precondition because there are ‘fewer’ conditions to be satisfied.

What does strengthening a postcondition mean?

Strengthening a postcondition means making the service that is requested ‘better’ in terms of time, precision or some other measurable item.



The precise notion of ‘better’ is not fixed, but must be considered in terms of the contract of which the postcondition is part. It can, however, make the postcondition more difficult for the supplier to satisfy because there are ‘more’ conditions to be satisfied.

Under what circumstances is one object, obj1 of class A, say, substitutable for another, obj2 of class B, say?

Class A must be a subclass of class B, and class A must respect all contracts agreed to by class B.

Once a class model that meets the contractual requirements of each use case has been developed, what three sets of items in this class model should you examine to help you find suitable postconditions when identifying the possible operations for a class?

You should investigate the following three sets of items when searching for the possible postconditions for an operation:


  • instances of a class (its objects) that have been created or deleted
  • instances of associations (links) that have been formed or broken
  • attributes that have been modified.

It is crucial of course that the postconditions reflect the requirements, and some practitioners would refer more directly to the requirements.

The figure shows a class model for the lending of books where there is a requirement to record both past and current loans. Describe the contract to borrow a book in terms of objects and links created. Your answer should differentiate between the ...

The figure shows a class model for the lending of books where there is a requirement to record both past and current loans. Describe the contract to borrow a book in terms of objects and links created. Your answer should differentiate between the pre- and the postconditions.

Preconditions:


  • there must be an instance of the class LibraryMember that corresponds to the real-world member
  • there must be an instance of the class Book that corresponds to the real-world book that the member wants to borrow
  • the instance of the class LibraryMember must be linked to fewer than 3 instances of the class Loan in the role of currentLoans.


Postconditions:


  • a new instance of the class Loan will have been created and the instance of the class LibraryMember will have been linked to the new instance of Loan in the role of currentLoans
  • the instance of the class Book will have been linked to the same new instance of the class Loan.

Consider the contract for a premium-rate, 24-hour courier service in which compensation is paid for non-delivery within 24 hours.



Show in a table the obligations and benefits of the client and supplier of this service.

Consider the contract for a premium-rate, 24-hour courier service in which compensation is paid for non-delivery within 24 hours.



Give the pre- and postconditions.

The pre- and postconditions are as follows.



Precondition: the service is paid for.


Postcondition: either the package will have been delivered within 24 hours or compensation will have been paid.

Look at Figure 1 again and identify the pre- and postconditions for returning a book to the library. Include the fact that there are two significant dates for each loan in relation to the possible payment of fines:


 


an expected return d...

Look at Figure 1 again and identify the pre- and postconditions for returning a book to the library. Include the fact that there are two significant dates for each loan in relation to the possible payment of fines:



  • an expected return date
  • an actual return date.


Assume that the value of the expected return date will have been set as part of borrowing a book. Also assume that the actual return date will be recorded as an attribute of a loan (to enable you to deal with charging for overdue books at some later stage of the development).

In Figure 1 the class Loan has two associations with the class LibraryMember, to differentiate between current and past loans. The contract for returning a book can be expressed as follows.



Precondition: the instance of the class LibraryMember is linked to an instance of the class Loan in the role of currentLoans.



Postcondition:


  • the link between the instance of the class LibraryMember and the instance of the class Loan in the role of currentLoans will have been broken
  • the instance of the class LibraryMember will have been linked to the same instance of the class Loan in the role of pastLoans
  • a value will have been set for the attribute actualReturnDate in the same instance of class Loan.


Note that the association between the class Loan and the class Book is not affected by returning a book. The instance of the class Book is linked to the instance of the class Loanbefore and after its return.