Assignment No. 6 PTT 2011

(C) 2011 — Software Languages Team, University of Koblenz-Landau

Navigation

The PTT course

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

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:

  1. Load a company object.
  2. Total the salaries in the company to have a baseline b.
  3. Save a memento.
  4. Cut all salaries in half.
  5. Show that the total of all salaries in this new state is different from b.
  6. Restore the baseline.
  7. Show that the total of all salaries now again equals b.

Variation 2

Title

The Strategy pattern for 101companies

References

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:

  1. Load a company object.
  2. Set the behavior for salary adjustment to a form that implies salary raise.
  3. Carry out deep salary adjustment while using the behavior parameter.
  4. Total the salaries in the company to have a baseline b.
  5. Load the same company object again.
  6. Set the behavior for salary adjustment to a form that implies salary cut.
  7. Carry out deep salary adjustment while using the behavior parameter.
  8. Total the salaries in the company to have another value b'.
  9. Show that b does not equal b'.