# SDA SE Wiki

Software Engineering for Smart Data Analytics & Smart Data Analytics for Software Engineering

# Assignment 02: Objects and Classes

Release date: Tuesday, 15.04.14 - Due date: Sunday, 20.04.14, 23:59

Read the formal conditions on your submissions to make sure that the tutors can accept your solutions.
How to draw an Object Diagram? Create a Class Diagram with astah. In the middle of the tool bar you find the “InstanceSpecification” and directly next to it the “Link”. These are the ingredients of an Object Diagram. For an instance of an Association Class it is ok to place it just next to the corresponding link, as it seems to be impossible to connect it with the link. (Other solutions are welcome, but be ready to explain how it should be. If you don't use astah, but provide a PDF or PNG, this is OK this time as well.)

## Task 04: Aggregation vs Composition

2 points

Give us four examples of a part-whole relationship, two examples of an aggregation and two examples of a composition relationship. Argue for each of the four cases why it is an aggregation or an composition respectively. (Such an argument would consist of the generic criterion for choosing the respective type of association and one or two sentences arguing why the criterion applies here.)

[Optional, 0 points]: Can you find an example where it depends on the context whether it is an aggregation or composition.

## Task 05: Gangsters are Persons

9 = 5 + 4 points

Studying class diagrams can be as exciting as hunting down gangsters. This task is the proof. Below you find a class diagram explaining that gangsters are persons and that certain associations are possible between gangsters and persons:

Study the class diagram carefully and understand which associations can connect objects of which class. With this knowledge you can easily solve the following two subtasks.

a) Study the object diagram carefully and tell us:

1. Who is for sure a gangster? How can you say?
2. Who is for sure a person? How can you say?

Make sure that you don't accuse a person of being a gangster, if you can not be sure. Accusing a person that might still be person will cost you a point per wrong accusation!

b) For the four persons above we know already whether they are gangsters or just persons. Given the class diagram above, which associations are possible between the following pairs (in the indicated direction)?:

1. Alonso → Bambino
2. Bambino → Carlo
3. Carlo → Donato
4. Donato → Alonso

Name all possible associations.

## Task 06: Association Classes

4[+2] points

Give us for each of the four class diagrams above:

• An object diagram that is compatible with the class diagram.
• Provide for the second class diagram an object diagram that violates the first class diagram.

(optional) We claim that the two last diagrams are equivalent.

• Describe the exact conditions under which using an association class is equivalent to having a class between the two associated classes.
• Give a (semi-formal) proof of the equivalence.

## Task 07: Seeing objects (optional)

[9 points]

This task is optional not because it is difficult, but because we added it late.

• Describe the form above with an object diagram. Don't make up more attributes than necessary. Just describe what is there. Give the values of the attributes.
• Create a class diagram describing the classes of the objects that you see. Just name the class names, attributes and maybe associations. You don't need to invent operations. You may use generalization, if you want. Name the common super class `Widget`.
• Make sure to specify the classes for the objects.
teaching/lectures/oosc/2014/assignment_02.txt · Last modified: 2018/05/09 01:59 (external edit)