Ch7-Design and Implementation
Ch7-Design and Implementation
Lecture
2
•Java Design Patterns are divided into three categories – creational (5), structural (7),
and behavioral (11). See more here
Chapter 7 Design and 29
implementation
Pattern Elements
Name
A meaningful pattern identifier.
Problem description.
Solution description.
Not a concrete design but a template for a design solution that
can be instantiated in different ways.
Consequences
The results and trade-offs of applying the pattern.
Name
Observer.
Description
Useful when you are interested in the state of an object and want to get
notified whenever there is any change.
Problem description
Used when multiple displays of state are needed.
Solution description
See slide with UML description.
Consequences
Optimisations to enhance display performance are impractical.
Pattern Observer
name
Description In observer pattern, the object that watches on the state of another object is
called Observer and the object that is being watched is called Subject.
Problem Java provides an inbuilt platform for implementing Observer pattern through
description java.util.Observable class and java.util.Observer interface.
However, it’s not widely used because the implementation is really simple and
it does not provide multiple inheritance.