Map the following simple model to 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.
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.
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
Worker. Discuss the benefits or drawbacks with respect to performance of queries (runtime), changes to the attributes (evolution), storage consumption.
(Evaluation: 0,5 points for every two wrong implementations identified by your tests. -2 points if a test fails for the correct implementation.)
Triangle.contains(Triangle t) and it is supposed to check if the triangle contains some other triangle t. For example the green triangle on the right contains the red one, i.e.
greenTriangle.contains(redTriangle) should be true. On the other hand the red doesn't contain the green one, i.e.
redTriangle.contains(greenTriangle) should be false.
You may optionally implement the
contains method yourself in a Test-First manner1). You don't need to do it, but this will strongly increase your chances to solve the task. Finding the correct implementation is not that easy. The main point of this preparation is to get some experience with finding test cases.
Your company decided that it is too difficult2) to develop the
contains(..) method within the company. So they announced that they want to buy an implementation. In response they got 17 implementations, but they doubt that many of them are correct. You got the job to find the implementation that is working. Of course you didn't get the source code, but you are a smart tester. Write some tests to find the implementation your company should actually buy. If you did the optional step, you can use the tests that your produced. Here is your guide to the source code:
cls contains the implementations
tst you find the class
geometry.TriangleTest. This test exercises all the implementations using the same test methods for each.3)
Triangle16 are out.
ifOneTriangleIsVeryLargeAndTheOtherVerySmall is annotated with
@Ignore and therefore ignored.
@Ignore annotation and run the tests again.
Describe the contract of a Map in OCL. Describe in particular the methods
V get(Object key),
V put(K key, V value),
createTriangle(..) method to create triangles. Don't use the constructors directly!
createTriangle(..) method to create triangles!