(C) 2011 — Software Languages Team, University of Koblenz-Landau
Navigation
Check-in deadline
June 11, 2011 (End Of Day, Koblenz timezone)
This is one day extra because of the barbecue on 9 June.
Resources
URLs to Wiki with SVN checkout URI
- 101implementation javaComposition (Recommended starting point for your solution)
- 101implementation javaTemplate (Recommendation for inspiration)
- 101implementation javaVisitor (Recommendation for inspiration)
- 101implementation javaExorcism (Advanced implementation for inspiration)
Preamble
The lectures on 31 May and 7 June (without any recording) deal/dealt exclusively with design patterns. This assignment asks you to discover two additional patterns that were not even mentioned in the lecture. You are advised to learn about these patterns from the literature recommended in the lecture, but links to web-based resources are provided below. Please understand that there is not just a single way of interpreting or applying these patterns. Feel free to deviate from the solution that is promoted by the source of your choice.
Variation 1
Title
The Memento pattern for 101companies
References
- http://en.wikipedia.org/wiki/Memento_pattern
- http://www.oodesign.com/memento-pattern.html
- http://c2.com/cgi/wiki?MementoPattern
Instructions
Use the pattern to provide effectively checkpoints for undoing changes on company objects.
More specifically, you should be able to save a memento on the rooting company object to be restored later.
Your test scenario could be this:
- Load a company object.
- Total the salaries in the company to have a baseline b.
- Save a memento.
- Cut all salaries in half.
- Show that the total of all salaries in this new state is different from b.
- Restore the baseline.
- Show that the total of all salaries now again equals b.
Variation 2
Title
The Strategy pattern for 101companies
References
- http://en.wikipedia.org/wiki/Strategy_pattern
- http://www.oodesign.com/strategy-pattern.html
- http://c2.com/cgi/wiki?StrategyPattern
Instructions
Use the pattern to provide context-dependent salary adjustment.
More specifically, you should be able to set the adjustment behavior on a company.
Your test scenario could be this:
- Load a company object.
- Set the behavior for salary adjustment to a form that implies salary raise.
- Carry out deep salary adjustment while using the behavior parameter.
- Total the salaries in the company to have a baseline b.
- Load the same company object again.
- Set the behavior for salary adjustment to a form that implies salary cut.
- Carry out deep salary adjustment while using the behavior parameter.
- Total the salaries in the company to have another value b'.
- Show that b does not equal b'.