L11: Modelling Structure Flashcards

1
Q

What is a system in object oriented design?

A

In object-oriented design, a system is a collection of interacting objects

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

What are objects in object oriented design?

A

Objects of a class share the same attributes, operations and relationships but may have different state

Identity
Unique to each other

State
Values of its attributes and the relationships it has to other objects at a particular point in time.
Some attribute values may change over time, while others will stay the same.

Behaviour
Operations that can be invoked on the object

State can affect behaviour, and behaviour can affect state (state transition)

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

What is a class in OOD?

A

A way of grouping objects with similar structure and behaviour (template)

A class is a description of a set of objects that share the same attributes, operations, relationships, and semantics, but not necessarily the same attribute values.
Each object is an instance of exactly one class.

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

What is a class diagram in OOD?

A

A class diagram shows the class name, attributes and methods and their respective scope and visibility.

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

What is the scope of attributes/methods?

A

The scope of attributes or methods tells whether they belong to each object created (no adornment) or the class (underlined in diagram, static).

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

What is the visibility of a class, and how is it denoted?

A

The accessibility of an element- who can see it.

Sometimes, methods only need to be accessed within a class.

+ : public, accessible to any class
- : private, accessible only within the same class
# : protected, accessible only within the same class or its subclasses
~ : package, accessible to any class in the same package

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

How are derived attributes denoted?

A

/

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

What do relationships model?

A

Interactions between classes are modelled by relationships

Relationships model how objects of different classes work together
- Association
- Aggregation
- Composition
- Generalisation

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

How are relationships between classes denoted?

A

In increasing order of strength:

Dependency: Dotted line with arrow
Association: Straight line
Aggregation: Straight line with hollow diamond
Composition: Straight line with coloured in diamond
Generalisation/Inheritance: Straight line with triangle arrow

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

What is association in OOD?

A
  • A design-time relation between classes
  • Specifies that at runtime instances of those classes have a link and be able to request services from one another
  • Associations can have a name to describe the nature of the relationship
  • An additional arrowhead can be used to indicate the direction in which to read the name
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is the syntax for association?

A

An association name
- Verb phrases, indicating an action that the source object performs on the target object

A role name
- Names the class on one or both ends of the association, indicating the role that
objects play when they are linked by this association

Multiplicity
- Constrains the number of objects of a class that can be involved in a particular relationship at any point in time

Navigability
- Direction from an object of the source class to one or more objects of the target class

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

What are the association roles?

A

Objects can play a specific role in a relationship.
Roles are shown as a name placed near the end of an association.

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

What is multiplicity on an association?

A

Multiplicity on an association end indicates the possible number of instances from that end that can participate in the association at runtime.

0..1
1
0..*
1..*
0..n
1..n

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

What is the navigability of an association?

A

The direction of navigability or message flow of the association may be specified by adding an open arrowhead.
No arrowheads means that the association is bidirectional.

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

What is aggregation in OOD?

A

A special kind of association indicating the existence of a “whole- part” relation between two classes
Object of one class owns object of another class, but those part objects may be shared by objects of another class.

E.g., a wallet has money, but the money does not need a walled to exist. If the wallet that money was in is deleted, the money still exists.

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

What is composition in OOD?

A

A stricter form of aggregation.
A unique “whole” (“composite”) has explicit responsibility for the
creation and destruction of the part objects.

E.g., a room is part of a house. The room cannot exist outside of a house. If the house was deleted, the room would be deleted too.

17
Q

What is generalisation in OOD?

A

Generalisation (also called inheritance) is a relationship between a general element and a more specific element, where:
- the specific element is consistent with the general element
- but contains more information

Can be interpreted as “is a kind of”
We can use the more specific element anywhere the more general element is expected without breaking the system

Subclasses have all the attributes, operations and relations of the superclasses, and may specialise or extend them

18
Q

When do we use inheritance, and what do we consider when using it?

A

Beware of implementation inheritance, when a class inherits from another class simply to reuse parts of its behaviour

Beware of multiple inheritance and complications such as the diamond problem

Not supported by many programming languages.

Superclasses should know nothing about subclasses.

Factor commonality as high as possible in the class hierarchy
E.g. If ClassB and ClassC both inherit from ClassA, and they both need behaviour X, then X should be implemented in ClassA. If only ClassB needs X, then X belongs in ClassB

The higher a method is, the more reusable it becomes. However, this does not mean that you should place every single method in the root class.

19
Q

What is coupling?

A

Describes the degree of interconnectedness between design elements.

Aim for loose coupling to optimise performance, localise changes and increase usability.

20
Q

What is cohesion?

A

A measure of the degree to which an element contributes to a single purpose- each element should do one thing. Only include what is relevant in each class.

Aim for high cohesion.

21
Q

What is the criteria for good design?

A
  • Design clarity
  • Do not over-design- abstraction is key
  • Clear inheritance hierarchies
  • Keep interactions and operations simple
  • Clear separation of classes