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

Task 03-05 are optional. Nevertheless we recommend that you solve at least one of them.

Task 02 and Task 03 are the OCL tasks from the exams in 2010 and 2011.

Task 02 and Task 03 are the OCL tasks from the exams in 2010 and 2011.

3 points |
---|

Consider the *Queue* interface in the *java.util* package. Write pre- and postconditions in OCL for the following operations:

*E remove()*: Retrieves and removes the head of this queue*boolean offer(E o)*: Inserts the specified element into this queue if possible*E peek()*: Retrieves but does not remove the head of this queue, returning null if this queue is empty

3 points |
---|

Have a look at this diagram:

Strengthen the given domain model by formulating OCL constraints which specify the following:

- Precondition: The arguments username and password (pw) of register method of OnlineShop class must not be null.
- Invariant: A premium customer must have more than 100 orders.
- Invariant: For each customer not more than one order is allowed to be active at the same time.

3 points |
---|

The diagram below illustrates a house automation system controlling blinds. Blinds automatically turned down between 20 and 8 o'clock. In case it is dark outside the blinds are turned down, too. This is achieved by calling updateBlinds(..) every hour. The current hour (0-23) is passed as an argument to the method.

Strengthen the given domain model by formulating OCL constraints for the HouseAutomation.updateBlinds(..) method:

- Precondition: The parameter hour of the updateBlinds(..) method must be larger or equal to zero and smaller than 24.
- Postcondition: During hours that are smaller than 8 or larger than 20 or in case that the light sensor measures values below 50 lumen the blinds are down.

3 points |
---|

- Assume
*C*is a subtype of*B*and*B*is a subtype of*A*(e.g. C extends B and B implements A). Compare the strength of the conditions “x is of type A”, “x is of type B”, “x is of type C”! - Assume now that
*T*is a subtype of*S*. We expect*T*to fulfill all contracts of*S*, especially the methods in*T*should “demand no more” and “promise no less”. - In the occult OO language that we are discussing this is the only restriction on the types of parameters and return types.
- Given that
*S*has a method*B m(B x)*and*m*is overriden in*T*. Which of the following signatures would be allowed for*m*in*T*:*A m(B x)**C m(B x)**B m(A x)**B m(C x)**A m(C x)**C m(A x)*

- Maybe it helps you to meditate about the following code:
`S s = new T(); B input = new B(); B output = s.m(input);`

- Explain how this could improve the Builder Pattern (Slide 50) a bit.

3 points |
---|

- Explain shortly the motivation and the functionality of the proxy pattern. Which are the participating roles of the proxy pattern? Which responsibilities do they have? Which operations are necessary?
- Present one example for each proxy variant, discuss the differences and present the motivation behind each one.
- What is the difference between the proxy and adapter pattern?

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

SEWiki, © 2022