Using Design Patterns in Real Projects

26
Using Design Patterns in Real Projects -Andy Bulka 2002 http://www.andypatterns.com

Transcript of Using Design Patterns in Real Projects

Page 1: Using Design Patterns in Real Projects

Using Design Patterns in

Real Projects

-Andy Bulka

2002

http://www.andypatterns.com

Page 2: Using Design Patterns in Real Projects

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.

Page 3: Using Design Patterns in Real 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

Page 4: Using Design Patterns in Real Projects

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.

Page 5: Using Design Patterns in Real Projects

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.

Page 6: Using Design Patterns in Real Projects

Adapter - two solutions

and one based on multiple inheritance

Adapter comes in two variants; one

making use of delegation:

Page 7: Using Design Patterns in Real Projects

Design Patterns Book

The

"Bible" of

Design

Patterns

Page 8: Using Design Patterns in Real Projects

Pattern Format

• Pattern templates typically contain:

• Name

• Intent / Motivation

• Problem

• Context & Forces

• Solution

• Consequences

Page 9: Using Design Patterns in Real Projects

To Record Experience...

Anecdote

- working

alone...

Page 10: Using Design Patterns in Real Projects

To Share Experience...

Page 11: Using Design Patterns in Real Projects

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.

Page 12: Using Design Patterns in Real Projects

Commercial Projects

Educational Reasoning Software

Payroll System

War Game

Page 13: Using Design Patterns in Real Projects

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.

Page 14: Using Design Patterns in Real Projects

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..

Page 15: Using Design Patterns in Real Projects

Reason!Able www.goreason.com

Page 16: Using Design Patterns in Real Projects

Game - 2D wargame

• Python

• SDL graphics (pyGame)

• Single and Multiplayer over internet

• Game AI

• Lots of pieces Moving

• Scrolling map

Page 17: Using Design Patterns in Real Projects

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.

Page 18: Using Design Patterns in Real Projects

Game Patterns as UML

Page 19: Using Design Patterns in Real Projects

Game so far

Page 20: Using Design Patterns in Real Projects

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.

Page 21: Using Design Patterns in Real Projects

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)

Page 22: Using Design Patterns in Real Projects

Australian Patterns Conference

Page 23: Using Design Patterns in Real Projects

Venue

The Country Place Conference

Centre

Location: The Dandenongs

International visitors

Page 24: Using Design Patterns in Real Projects

Patterns I have written for the conference

• Model Gui Mediator

• Relationship Manager

• Transformation Interface

See www.andypatterns.com

Page 25: Using Design Patterns in Real Projects

Plop Conference Proceedings

Page 26: Using Design Patterns in Real Projects

Links

• KoalaPLoP is hosted in Melbourne

http://www.mcs.vuw.ac.nz/~kplop

• Melbourne Patterns Group

http://www.melbournepatterns.org