Unit 6 Flashcards

1
Q

What is ‘design by contract’?

A

Design by contract is the process of developing software based on the notion of contracts between objects, which are expressed as assertions.

(b2, p80)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is an assertion?

A

An assertion is a statement that is either true or false.

(b2, p79)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are the four main advantages to the DbC approach for adding assertions?

A
  1. Assertions provide accurate documentation for the implemented classes so that a programmer knows how to use the classes and what to expect from them.
  2. Provided they are executable, assertions are an important aid to testing, but without being an obstacle to efficiency.
  3. Assertions provide a way of controlling inheritance in which substitutability and redefinition of methods are allowed.
  4. Provided that the programming language has an exception mechanism that accords with the principles of DbC, assertions together with the exception-handling mechanism can be an important aid to developing mission-critical systems.

(b2, p79)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

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

A

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

(b2, p81)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What are the two basic ways in which classes relate to each other?

A
  1. Through associations
  2. Through generalisations

(b2, p85)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What three sets of items should be investigated when searching for possible postconditions for an operation?

A
  1. Instances of a class (objects) that have been created or deleted
  2. Instances of associations (links) that have been formed or broken
  3. Attributes that have been modified

(b2, p87)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is an interaction diagram?

A

An interaction diagram is a UML diagram that shows the sequencing of messages in an interaction.

(glossary)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is a sequence diagram?

A

A sequence diagram is a UML interaction diagram that focuses on the time-ordering of the messages.

(glossary)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is a communication diagram?

A

A communication diagram is a UML interaction diagram that focuses on the structural aspect (instances and links) of an interaction.

(glossary)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is GRASP?

A

GRASP stands for General Responsibility Assignment Software Patterns, and is a collections of patterns which may help the designer assign responsibilities in commonly recurring design scenarios.

(glossary)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is GRASP Creator?

A

GRASP Creator is a pattern that provides guidance on which class should be responsible for creating new objects.

(glossary)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is GRASP Expert?

A

GRASP Expert is a pattern that provides guidance on which class should be responsible for initialising or changing the state of an object.

(glossary)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is a CRC card?

A

A CRC (class-responsibility-collaboration) card is a way of modelling how classes interact.

(b2, p108)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What are the three components of a CRC card?

A
  1. Class name
  2. Responsibilities of the class (what data it holds and what it can do)
  3. Collaborators of the class (other classes it interacts with)

(b2, p108)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is the difference in emphasis between sequence diagrams and communication diagrams?

A

Sequence diagrams emphasise the flow of messages from object to object over time.

Communication diagrams emphasise the message traffic across links in a particular configuration of objects.

(b2 p114)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

How is time represented in communication diagrams?

A

Time is represented by the sequential numbering of messages.

(b2 p114)

17
Q

How do you represent the creation and deletion of an object in a sequence diagram?

A

(b2, p118)

18
Q

How can parameters be used in sequence diagrams?

A

(b2, p115)

19
Q

How would you represent navigability (direction of association) in a class diagram?

A

(b2, p124)

20
Q

When describing the shape of a communication diagram, what is the difference between the fork and cascade patterns?

A

The fork pattern centralises control in the sender.

The cascade pattern delegates responsibility to another object along a single thread of control.

(b2, p130)

(glossary)

21
Q

What is the Law of Demeter?

A

The Law of Demeter states that a method m in a class A should not send a message to another object unless that object is one of the following:

  1. an instance variable used in the method m
  2. a parameter to the method m
  3. an object created in the method m
  4. a global variable used in the method m

An object should avoid invoking methods on another object returned by some method, where the returned objct does not qualify under one of the above situations.

(b2, p131)