patterns - DESIGN PATTERNS A design pattern is a solution...

Info iconThis preview shows pages 1–11. Sign up to view the full content.

View Full Document Right Arrow Icon
DESIGN PATTERNS A design pattern is a solution to a problem in a context descriptions of communicating objects and classes that are customized to solve a general design problem in a particular context -- Gamma et al. It is a means of capturing and reusing design knowledge Besides a broad collection of books on design patterns there are also books on analysis and reengineering patterns, as well as programming language-specific pattern books and even a book on anti-patterns
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
HISTORY The concept of patterns derived from building architecture – Christopher Alexander et al. wrote the book A Pattern Language in 1977 that described prototypical ways in which building and their rooms are used The seminal book on software design patterns (sometimes called the Gang of Four book) is Gamma, Helm, Johnson, and Vlissides. Design Patterns. Addison Wesley, 1995. Other information on design patterns, including a catalog, can be found at http://hillside.net/patterns
Background image of page 2
EXAMPLE PATTERN Name: Mediator Category: Object Behavioral Intent: encapsulate how a set of objects interact Also known as : Motivation: reduce coupling between objects; promote reuse; increase intensionality; encapsulate collective behavior in a Mediator object – Example--complex widget dialog
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
APPLICABILITY Use the Mediator pattern in the following situations • Object interactions are well-defined (statically understood) but complex • Embedding behavior in objects reduces reusability – Behavioral customization should be localized
Background image of page 4
MEDIATOR STATIC STRUCTURE Mediator createColleagues() updateColleagueStates() ConcreteMediator changed() Colleague getData() ConcreteColleague1 setData() ConcreteColleague2 mediator
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
MEDIATOR COLLABORATION aMediator aConcreteColleague1 aConcreteColleague2 1 : c h a n g e d 2 t D 3: setData
Background image of page 6
MORE MEDIATOR • Participants: Mediator : defines collaboration interface ConcreteMediator : implements dependencies among Colleagues ; knows of specific Colleagues Colleague : knows of Mediator but not other Colleagues • Collaborations: Colleagues communicate with Mediator ; Mediator routes requests
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
CONSEQUENCES • Decouples Colleagues , which supports Colleague reuse • Simplifies protocols – Communication is now just to and from Mediator • Centralizes and abstracts control • Intensionality: if collaboration is for the purposes of invariant maintenance, there is a single place to look to ensure compliance • Limits subclassing to Mediator when customizing collaboration
Background image of page 8
IMPLEMENTATION ISSUES • If Colleagues are interacting with a single Mediator , there is no need for an abstract Mediator class • Mediator can be implemented as an Observer – Register interest with Colleague ; change causes notification • Colleagues can pass self as an argument so the Mediator knows where the event came from
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
FORMAT FOR PATTERNS Name: captures the concept in a word or phrase Category: creational, structural, behavioral
Background image of page 10
Image of page 11
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 56

patterns - DESIGN PATTERNS A design pattern is a solution...

This preview shows document pages 1 - 11. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online