Using Design Patterns in Real Projects
Transcript of Using Design Patterns in Real Projects
Using Design Patterns in
Real Projects
-Andy Bulka
2002
http://www.andypatterns.com
Using Patterns in Real Projects
• What is it like to use design pattern in real
life programming?
• Do the sometimes academic patterns
translate into the real world?
• The answer is yes – I will back this up with
three examples of where I have used
patterns in real world projects.
Overview
• Patterns - Definitions
• Patterns Example
• My personal definition and approach to
patterns
• Commercial Projects using patterns
• Patterns I have written
• Links, Patterns Groups in Australia
What are Patterns?
• Patterns are conventions for describing and
documenting recurring design decisions
within a given context, in software design &
engineering.
• A problem/solution pair given a standard
name.
• A pattern is documented using a standard
format which includes a sample UML
diagram of a typical solution.
Example - Adapter Pattern
• Convert the interface of a class into another
interface clients expect.
• Adapter lets classes work together that
couldn't otherwise because of incompatible
interfaces.
Adapter - two solutions
and one based on multiple inheritance
Adapter comes in two variants; one
making use of delegation:
Design Patterns Book
The
"Bible" of
Design
Patterns
Pattern Format
• Pattern templates typically contain:
• Name
• Intent / Motivation
• Problem
• Context & Forces
• Solution
• Consequences
To Record Experience...
Anecdote
- working
alone...
To Share Experience...
Personally I think Patterns are
• Share and document experience
• Great as a vocabulary between
programmers and design tool
• Like problem / solution pairs
• Just a name for a new „thick/non-obvious‟
concept? A „distinction‟.
• Later patterns become common terms.
Commercial Projects
Educational Reasoning Software
Payroll System
War Game
Reason 2 - Melb University
• Mentor in Delphi & OO
• Patterns where possible
• Model - „cauldron of creation‟. Composite.
• Command, Template, Strategy for
persistence, Adaptor incl. delegation via a
pointer “this is an important idiom”
• Model View Controller variation MGM.
Hooking up a standard Windows GUI
treeview to model.
Reason 2 - UML
There are
several
design
patterns in
this UML
diagram.
P.S. In
later years
I became
interested
in how to
explicitly
represent
patterns in
UML
diagrams..
Reason!Able www.goreason.com
Game - 2D wargame
• Python
• SDL graphics (pyGame)
• Single and Multiplayer over internet
• Game AI
• Lots of pieces Moving
• Scrolling map
Game - Preparation
• Starting a new project in a new domain - I
wanted to know what best practices were.
• “Game patterns” on the web documented
best practices, tips and tricks and useful
rules of thumb and mini designs.
• Melb Patterns Group presentation
• Patterns used so far - MVC, Façade,
Singleton, MGM, Mediator, RM, TI, Null
Object, Adaptor, Strategy, Observer, State.
Game Patterns as UML
Game so far
Game Gems & AI Wisdom book
• Patterns vs. “Gems”
• Patterns vs. “Problem / Solution pairs”
• Still talk about forces and consequences and
trade-offs, though not as formal section
headings.
• Some sections not strictly suited to being a
pattern, instead they talk about
optimisations or more specific issues.
Payroll System
• Delphi project
• Experienced content expert
• Was a payroll patterns paper at KoalaPlop
2002
• See also “Business Modelling in UML” by
Eriksson & Penker - “Business Patterns at
Work”.
• Transformation Interface Pattern (Gui and
DB versions)
Australian Patterns Conference
Venue
The Country Place Conference
Centre
Location: The Dandenongs
International visitors
Patterns I have written for the conference
• Model Gui Mediator
• Relationship Manager
• Transformation Interface
See www.andypatterns.com
Plop Conference Proceedings
Links
• KoalaPLoP is hosted in Melbourne
http://www.mcs.vuw.ac.nz/~kplop
• Melbourne Patterns Group
http://www.melbournepatterns.org