Unit 6 - Dynamic modelling – from analysis to design Flashcards
(35 cards)
In the analysis phase of system development what are the assertions (preconditions, postconditions and invariants) used for?
Assertions were used for placing constraints on the relationships between classes.
SAQ 1
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.
SAQ 1
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.
SAQ 1
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.
SAQ 2
In DbC, 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. A supplier’s obligations to produce outputs satisfying certain constraints mean that a client can expect to receive a clearly defined service.
SAQ 3
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.
SAQ 4
Similarly, 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.
SAQ 4
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.
SAQ 5
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.
SAQ 5
How does the use of a pair of object diagrams help you prepare to build a sequence diagram?
The aim is to show how a given postcondition can be achieved in a sequence diagram. A pair of object diagrams, showing the states before and after the operation in question, identifies the changes in system state that take place in order to meet the postcondition.
SAQ 6
Is the initial message on an interaction diagram always sent from an object representing the user interface?
No – we are not constrained to showing interactions with the user interface. Message sequences can originate from any object. The user interface is the origin for those messages that relate to a use case scenario, which we have described in the case of checking guests in to a hotel. However, interaction diagrams can become very complex if we try to show all the possible messages for a given configuration of objects. Following the principle of modularisation, we would split up a complex interaction into a number of smaller ones. In the new diagrams the starting point need not be the user interface.
SAQ 6
What does GRASP stand for?
General responsibility assignment software patterns.
p. 96
Describe the intent of the GRASP Expert pattern and how it works
Intent: To assign responsibility based on object properties.
How it works: The responsibility is assigned to the class that has the information necessary to fulfil that responsibility – the ‘information expert’; this information is represented by the properties of the object of the class.
p. 96
Describe the intent of the GRASP Creator pattern and how it works
Intent. To assign responsibility for creating objects.
How it works. The responsibility for creating an instance of some class is assigned to the class that aggregates, maintains or records, or contains instances of the class of the newly created object, especially if the creator class provides the data required to initialise the newly created object.
In an interaction diagram, which class must provide the operation indicated by a message passed from one object to another?
The class of the receiver object must provide the appropriate operation.
SAQ 7
What does a lifeline represent?
A lifeline represents the portion of the life of an object covered by the sequence diagram.
SAQ 7
What does the box at the top of a lifeline include?
It includes an instance name, optionally followed by a colon and a class name, or, for a generic object, just a colon and a class name. For example, objectname, objectName : ClassName and : Classname are all allowed.
SAQ 7
What sort of arrowhead is used on an arrow depicting synchronous
message sending?
A solid black arrowhead, which indicates that the interaction is procedural. An arrowhead with a dashed shaft is used to signify the method’s return, although it is often omitted for clarity.
SAQ 7
What is a procedural interaction? With what might it be contrasted?
It is an interaction in which the sender of a message is blocked until the receiver of the message has finished processing. This is exactly the same as what is sometimes called subroutine semantics. It is the usual policy when a single thread of control is allowed. If multiple threads are allowed, we might not want the sender of the message to block, in which case we could start a concurrent activity.
SAQ 7
In a sequence diagram, what does the widening of a lifeline into a tall, thin rectangle mean?
This shows that the object is active. An object is said to be active if it is either performing an operation or awaiting completion of an operation that it has requested another object to perform.
SAQ 7
What does to delegate mean in the context of object-oriented design?
One object is said to delegate behaviour to another when, instead of implementing some behaviour, it sends a message to another object that implements that behaviour. We considered the possibility that instead of the Hotel doing all the work of finding a free room and housing jill in it, the Hotel might delegate the work to a Room by passing it the message attemptToAccommodate(jill).
SAQ 8
Would you describe a sequence diagram as a programming notation?
Not really, because all it shows is the inter-object message traffic. It does not represent the algorithms needed by senders in order to decide when and to which objects messages should be sent, or those needed by receivers in order to act on the messages. When you have finished drawing sequence diagrams you know the interfaces of the various classes but not how those interfaces will be implemented.
SAQ 8
How is the sequencing of messages represented in a communication diagram?
Every message has a multi-stage number. The numbers specify the sequencing, replacing vertical position in a sequence diagram.
SAQ 9
Sequence diagrams and communication diagrams show almost equivalent information. What are their respective strengths and weaknesses?
Sequence diagrams make the relative order of messages extremely easy to see by presenting time vertically. Communication diagrams are an extension of object diagrams, so there is less new notation. They make it easy to see the links and to show role names, at the cost of making the relative ordering of messages less immediately clear.
SAQ 9