Patterns Lab

Requirements

This lab consists of several .uml files created using StarUML. If you don't have StarUML you can download it from:

http://staruml.sourceforge.net

Locale Fix

If you have trouble opening my .uml files, try starting StarUML using the LocaleFix.bat batch file. Read the comments to understand how to use it. You can also download this file from:

http://www.cameel.xt.pl/

Seeing Patterns I

Download the file problems1.uml and open it with StarUML. Here's a screen shot:

Each package in the model explorer (problem1, problem2, etc.) contains a partially completed class diagram and a suggestion. The suggestion suggests using one or more design patterns to complete the design.

To complete the diagram, add any missing elements (classes, interfaces, associations, and generalizations). In some cases you may need to remove elements. You may also need to alter attributes and operations of classes. Next, apply the suggested patterns. This also may involve adding more elements.

Suggestions

1. It might be a good idea to create a library package containing pattern classes that can be reused in several problems.

2. If the suggested patterns are from the GoF pattern catalog, you can use the StarUML "Apply Patterns" tool:

This tool regards a pattern as a collaboration parameterized by roles that will be played by different classes in different situations. Using the tool, designers simply match their classes with the collaboration parameters. Click the "Pattern Help" button to find out what the different role parameters do.

Note: Using this tool is a good exercise in itself.

Submission

Before the deadline upload your updated version of problems1.uml to a place accessible to the instructor, but not accessible to other students. (Specifics will be given in lecture.)

Seeing Anti-Patterns

Download the file problems2.uml and open it with StarUML. Here's a screen shot:

Each package in the model explorer (problem1, problem2, etc.) contains a partially completed class diagram. Each diagram has one or more design flaws. The flaws range from major flaws, such as logical errors, to medium flaws such as a failure to anticipate obvious uses and extensions, to minor flaws such as un-encapsulated fields. In some cases the flaws are well known anti-patterns (bloated class, feature envy, lazy class, etc.)

To complete the problem you must refactor the diagram. This may involve eliminating elements (interfaces, classes, associations, generalizations, methods, fields, etc.), altering elements, and/or adding new elements. In some cases the refactoring involves applying well known refactoring transformations (push-up/down method, extract sub/super class, eliminate middleman, etc.). In some cases the refactoring involves applying a design pattern. In most cases the refactoring involves applying common sense and well known principles of design (modularity, abstraction, open-closed, etc.).

Submission

Before the deadline upload your updated version of problems1.uml to a place accessible to the instructor, but not accessible to other students. (Specifics will be given in lecture.)

Seeing Patterns II

This exercise has the same instructions as Seeing Patterns I. However, this should probably be part I as it contains easier problems. Download the file problems3.uml and open with StarUML.