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

User Tools

Site Tools

Assignment 10 - Mapping Models to Code

Task 01: Zoo, OCL

4 points

In the following you are asked to apply your knowledge to refine a model of a zoo. Animals in a zoo live in enclosures. These enclosures are maintained by zoo keepers. Of course, these keepers as well feed the animals in the enclosures.

Partial Domain Object Model of a Zoo

Express the following assertions in OCL:

  1. “Zoo keepers work eight hours or less.”
  2. “Each enclosure should have not more inhabitants than its capacity.”
  3. “For all feeding times of the animals there is at least one of their keepers, who is working at that time.”

Picture © German Federal Archives,,_Hamburg,_Tierpark_Hagenbeck.jpg

Task 02: java.util.Map, OCL

4 points

Consider the Map interface in the java.util package. A Map contains values identified by keys. Write pre- and postconditions in OCL for the following operations:

  1. V get(Object key): Returns the value for the given key, or null if none is available.
  2. V put(K key, V value): Stores the given value of the given key in the map.
  3. remove(Object key): Remove the key-value pair with the given key from the map.
  4. void clear(): Removes all key-value pairs from the map.

Task 03: Mapping class diagrams to code

6+4+[3] points

Consider the following class diagram representing the domain of commercial properties (buildings owned by companies).

A simple domain object model of commercial properties

Task a), Relational Databases: We presented three alternatives to map a class hierarchy to a relational database. Describe the three alternatives and how the tables would look like for the classes House, Commercial Property, Shop and Warehouse. Discuss the benefits or drawbacks with respect to performance of queries (runtime), changes to the attributes (evolution), storage consumption.

Task b) Java Code: Map the complete model (i.e. including Address and Company) to Java code strictly following the mapping presented in the lecture. We will evaluate the mapping of the three different associations and the presence of the getter and setter methods for the attributes. As explained in the lecture there is a benefit in not being creative here. Explain this in one or two sentences.

Task c) OCL, optional: The mapping of the associations is constructed to fulfill certain invariants. Describe for each of the three associations the invariants the construction guarantees. Remember: Constraints are only expected to be fulfilled on well defined points in time. Add a note for each constraint when it will be valid and when it is invalid.

teaching/lectures/oosc/2013/assignment_10.txt · Last modified: 2018/05/09 01:59 (external edit)

SEWiki, © 2021