Unit 7 Flashcards
How can conditions be represented in a sequence diagram?
(b2, p145)
How can multiple conditions originating from the same point be represented in a sequence diagram?
(b2, p146)
How can multiple message sends be represented in sequence diagrams?
(b2, p147)
How are optional operations represented in sequence diagrams?
(b2, p148)
How are if then operations represented in sequence diagrams?
(b2, p149)
How are loops represented in sequence diagrams?
(b2, p150)
How are preconditions checked when using defensive programming?
In defensive programming, the checking of the precondition is done by the operation itself (the receiver of the message).
(b2, p153)
How are preconditions checked when using DbC?
In DbC, the checking of the precondition is done by the caller of the operation (the sender of the message).
(b2, p153)
What are the three strategies that can be adopted for implementing use cases?
- One central class
- Interface sends all messages to a single general object, which then forwards the message to other classes.
- Interface is only aware of this one object.
- Each use case is a method of this general object.
- It is possible that the central class will become overloaded with use cases, so it is a good idea to split the system into several packages which would each make use of one class to respond to interface messages.
- Actor classes
- Messages are sent to objects that correspond to the real-world actor who initiated the operation.
- There is a complication when there are two actors that can initiate an interaction.
- Use cases as classes
- A new class is defined for each use case and would have a method like run, with a suitable number of arguments.
- The user interface would create a single instance of the appropriate class, intialise it suitably, then send the run message.
- Can improve reuse.
(b2, p155)
What is the main disadvantage of defensive programming?
The main disadvantage of defensive programming is that the same constraints within each precondition may be checked repeatedly in different operations.
(b2, p157)
What is a state machine?
A state machine is a model that shows how an object changes from state to state in response to events.
(b2, p161)
What are the six components of state machines?
- States, represented by the round-cornered rectangles containing their names.
- Events, repesented by labels on the transition arrows.
- Transitions, represented by arrows and identified by the events that give rise to them. Transitions occur as a response to an event and cause a change of state.
- Guards, represented by text in square brackets. Guards are used to choose which transition to take if the same event appears on more than one transition.
- Initial state, represented by a solid black circle. Initial state shows which state a new object will enter first. There can only be one initial state.
- Final state, represented by a black circle surrounding a solid black circle. Final state shows that processing has been terminated. There can be multiple final states.
- Possibly entry and exit events, represented by including ‘entry / ‘ or ‘exit / ‘, followed by the method name and any parameters.
(b2, p162-166)
Draw a state machine diagram for the following lending library scenario:
Newly purchased copies of a book are put on to the shelf for lending to the library’s members. Damaged copies are removed from stock. At certain times of the year, each library is allowed to select copies of books to go on sale to the public.
(b2, 166)
What is a self-transition, in relation to state diagrams?
Self-transitions originate in one state and return to the same state. They are commonly found in state machines that model loops or cycles.
(b2, p170)
What is a package, in terms of UML?
A package can be used to group model elements into a single unit. Packages may be nested.
(b2, p181)