W4: Compositions, Aggregations and Associations Flashcards

1
Q

A composition is…

A

a strong relationship: the composer object owns the component object: one class completely contains another class and determines its lifetime.

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

An aggregation is…

A

a weaker relationship: the aggregator has an instance of another class, which determines its own lifetime.

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

An association is…

A

the weakest relationship of the three: one class accesses or uses another class: neither class exhibit a ‘has a’ relationship to the other class.

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

Compositions, aggregations, and associations appear in classes with _________

A

resources

If a class with a resource is responsible for copying and destroying its resource, then that class is a composition. If the class is not responsible for copying or destroying its resource, then that class is an aggregation or an association.

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

A composition is a ____ relationship between classes.

A

has-a

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

A composition can be implemented in 2 ways:

A

a sub-object or a pointer to the sub-object

ex.
Name name; // sub-object

OR

Name* name {nullptr}; // pointer

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

In an aggregation relationship, the aggregator ____ the aggregatee.

A

uses

The aggregator is complete whether or not any of the objects that it uses exist.

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

Does the aggregator create and destroy the objects it uses?

A

No, the aggregator is not responsible for creating and destroying.

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

Association does not involve any _______ of one type by another.

A

ownership

Each type is independent and complete without any related type.

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

If one object of an association is destroyed, is the other object destroyed as well?

A

No, they exist independently.

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