This website provides the up to date information on course material, exercises and announcements about Modeling, Design Patterns.

The module description can be found here.

Literature

Tooling: Netbeans-IDE as IDE, logo as UML Tool.

Study the theory/ tutorials before you come to class. This will make the lessons most effective, because the questions that you might have from studying could be answered immediately.
Studying is not just reading Doing the exercises is the best way of verifying that you understand the subject. Use the books advice: use a pencil and a sharpener. If you do not like to write in books (as I do), make you exercises on another paper.
If you DO work on paper, you can scan in your work (which is free of charge) and hand that in through the repository. Make sure I can read your scribbling.

Weekly subjects, week 1-7

1. State, Modeling behavior.

Table 1. Sheets and handouts

topic

sheets

handout

State, Modeling behavior

uml state slides

uml state handout

Tasks for week 1. Handin using personal mod2 repository on fontys venlo.
Create directory per task, e.g. task1_dream_on
It goes without saying that you will add tests to you code as in work test driven. Mockito and friends can help here.

1.1. Task 1: Dream on.

dreammachine clock controls Model and implement the state behavior of a simple radio alarm clock.
The model should be done in either visual paradigm or umlet.
Provide two implementations:

  1. Using a two level switch case,

  2. Using the State Pattern, such as demonstrated in JAVA2 and SEN1 in 2016, olifantysballs.

1.2. Task 2: Cruise along.

CruiseControlSTD2

Implement the hierarchical state machine of the cruise control using the enum technique as in the olifontysballs machine combined with a stack to remember the hierarchy of states. Implementation idea: The "state" of the context now exists of a stack of enum values. The top most enum receives the event(s) and either handles and thereby consumes it, or passes it on to the state below, if any. Example: When the cruising state is active, it is the top of the stack, the stack (top to bottom) will contain Cruising, NotAccelerating, AutomatedControl, EngineRunning

You could add checks, to make sure that state values only occur in their intended position. Like EngineRunning is only on level 0. When the engine is turned on, Idle (on the top==bottom) should be replaces by engine running and on entry add Standby to the stack.

2. Object Oriented Analysis and Design.

Table 2. Sheets and handouts

topic

sheets

handout

State, Modeling behavior

OOAD slides

OOAD handout

Tasks for week 2.
  • Study and make the exercises in Chapter 8 of OOAD.

  • Study and complete the exercises in Chapter 1 of HFDP.

3. Decorator and Factory

Table 3. Sheets and handouts

topic

sheets

handout

State, Modeling behavior

Design Patterns Slides

Design Patterns Handout

Tasks for week 2.
  • Read Chapter 2 of HFDP. Observer should be already quite familiar, Think of JavaFX Observables and Bindings and such.

  • Study and complete the exercises in Chapter 3 and 4 of HFDP.

3.1. Logging Cruise Control

Enhance the Cruise Control Application from week 1 with event logging, using the Decorator Pattern. What should be decorated? You might have to extract an interface somewhere.
In a modern car, you might find something similar to a black box or flight recorder. Such a device would be the receiver of such logs.

3.2. Tied to a factory

Study the JavaFX class javafx.beans.binding.Bindings and describe a few of the methods therein, using the terminology (Abstract Product, Concrete Product, etc.) of one or both Factory patterns (Abstract Factory or Factory Method).

4. Combining Patterns: Calculator

Table 4. Sheets and handouts

topic

sheets

handout

State, Modeling behavior

Calculator Slides

Calculator Handout

Tasks for week 3.
  • Study and complete the exercises in Chapter 5, 6, and 7 of HFDP.

4.1. Calculator with Undo.

Using the example given in the sheets, implement a fraction calculator. The minimal implementation would be a command line version, working interactively.

The design in the slide is a bit dated, because it predates even Java 5 (e.g., No generics, no enums, certainly no lambda). It is no problem when your implementation does not use all patterns mentioned in the example (e.g., using factory and/or prototype when using enum as the command implementation is a bit nonsensical. But command with its undo must be present. In other words you vary the design as long as your meet the functional requirements of the original.

A nice touch would be a javafx gui version, but that is only optional.

Implementation notes
For the fraction calculator, simply use implementation from Java1. It would be nice if your implementation uses immutable Fraction instances.

5. Patterns are everywhere: Apps, Libraries

Table 5. Sheets and handouts

topic

sheets

handout

State, Modeling behavior

Elevator Example Slides

Elevator Example Handout

Tasks for week 5.
  • Study and complete the exercises in Chapter 8, 9 of HFDP.

5.1. Patterns in applications.

On the website you can find two small application libraries which have been used in our java classes and assessments. They are both GUI applications created in the Java Swing framework.

For each of these applications we want you to report on the patterns applied in there. For every pattern you find, indicate the role of the participating classes for that pattern instance. Remember that patterns are often combined, such that a class can have different roles in the different patterns it participates in.

The GUI apps are:

  • Slot machine GUI, which has been used to create multiple performance assessment for SEN1 in the years 2005-2013.

  • Crossing GUI, used as an environment for a SEN1 and a JAVA3 exercise.

Both a libraries, meant to be used by students in an application, where the students task is about the "business logic".

The recommended approach would be to :

  1. First read the java doc on Fontys Venlo Java bits, to make yourselves familiar with the application,

  2. then make some (hopefully educated) guesses of where applying patterns could solve a problem and then

  3. Study the code to see of your guess was right.

In the slot machine lib, you should be able to find several standard problems which are quite common in graphical user interface. In the crossing lib, the way the main drawing (the crossing with the traffic lights proper) is implemented uses quite a few patterns in combination.

6. Non GoF Patterns

Table 6. Sheets and handouts

topic

sheets

handout

Dependency Injection

Dependency Injection Slides

Dependency Injection Handout

Pipes and Filters

Pipes and Filters Slides

Dependency Injection Handout

Tasks for week 6.
  • Study and complete the exercises in Chapter 10, and 11 of HFDP.

There will be no extra tasks this week. Continue and or complete the tasks of previous weeks.

7. Q & A

The last lesson is only one hour. Question time from 8:45 til 9:30.

Q: What should we study?

A: See literature list + sheets. In particular the Non-GoF patterns.

…​

After that we will start assessment session 2. See your invitation.