Design Patterns

27
05/26/2004 www.indyjug.net 1 Indy Java User’s Group June 29 2005 6:00p.m @ Knowledge Services, Inc.

description

 

Transcript of Design Patterns

Page 1: Design Patterns

05/26/2004 www.indyjug.net 1

Indy Java User’s Group

June 29 2005

6:00p.m

@ Knowledge Services, Inc.

Page 2: Design Patterns

05/26/2004 www.indyjug.net 2

Agenda

•Welcome / Pizza 6:00-6:15

•Introductions 6:15-6:30

•Design Patterns 6:30-7:30

•Future JUG Topics 7:30-8:00

•Giveaways 8:00-8:15

Page 3: Design Patterns

05/26/2004 www.indyjug.net 3

Mission Statement

Promote the use of the Java language and components across all levels of interest in the greater Indianapolis area, by serving as a resource for knowledge, experience and career opportunities.

Page 4: Design Patterns

05/26/2004 www.indyjug.net 4

Introductions

•NameName

•WorkWork

•How long have you been How long have you been coming?coming?

•Something InterestingSomething Interesting

Page 5: Design Patterns

05/26/2004 www.indyjug.net 5

Tonight’s Objective

•Design Patterns Overview

•Elements of a Design Patterns

•Chain of Responsibility(CoR) Example

•‘Your Turn’

Page 6: Design Patterns

05/26/2004 www.indyjug.net 6

Design Patterns (Overview)

•Goals of Design Patterns

•Benefits of Design Patterns

•Challenges of Design Patterns

•History (Gang of Four)

Page 7: Design Patterns

05/26/2004 www.indyjug.net 7

Design Patterns (Goal)

•“Capture solutions that have developed and evolved over time in a succinct and easily applied form.”

•“Systematically name, explain and evaluate an important and recurring design in object-oriented systems”

Page 8: Design Patterns

05/26/2004 www.indyjug.net 8

Design Patterns (Quote)

“A design pattern isn’t ‘designed’. It’s discovered. In other words, patterns aren’t an invention as much as they are a refactoring of existing concepts.”

- A. Russell Jones

Page 9: Design Patterns

05/26/2004 www.indyjug.net 9

Design Patterns (Benefits)

•Vocabulary

•Reusability

•OO Ideals

•Standardization

Page 10: Design Patterns

05/26/2004 www.indyjug.net 10

Design Patterns (Challenges)

•“Define and describe a repetitive activity at a high enough level to be useful across very different applications, yet specific enough to have a single implementation.”

•Individual interpretation (Design vs. Impl)

•Terminology overloading.

•Implementation (language limitations, etc)

•Singleton example

Page 11: Design Patterns

05/26/2004 www.indyjug.net 11

Design Patterns (Singleton)

public static MyObject getInstance(){

if( myObject == null ) {

myObject = new MyObject(this);

}

return( myObject );

}

Page 12: Design Patterns

05/26/2004 www.indyjug.net 12

Design Patterns (History)

•Gang of Four•Erich Gamma, Richard Helm, Ralph Johnson, John Vlissides

•BookDesign Patterns:

Elements of Reusable Object-Oriented Software

•ISBN 0-201-63361-2

•Copyright 1995 by Addison Wesley, Inc.

Page 13: Design Patterns

05/26/2004 www.indyjug.net 13

Design Patterns (Elements-1)

•Pattern Name (handle)•Higher level of abstraction•Vocabulary

•Problem (context)•Conditions that must be met before the pattern can be applied•Describe class or object structures

Page 14: Design Patterns

05/26/2004 www.indyjug.net 14

Design Patterns (Elements-2)

•Solution (elements)•Relationships•Responsibilities•Collaborations

•Consequences (trade-off)•Flexibility•Extensibility•Portability

Page 15: Design Patterns

05/26/2004 www.indyjug.net 15

Design Patterns (Categories)

•Creational Patterns Factory Method, Singleton, Abstract Factory, Builder, Prototype

•Structural PatternsAdapter, Decorator, Bridge, Composite, Façade, Flyweight, Proxy

Page 16: Design Patterns

05/26/2004 www.indyjug.net 16

Design Patterns (Categories)

•Behavioral PatternsCommand, Iterator, Interpreter, Mediator,Chain of Responsibility (CoR), Memento, Observer, State, Strategy, Template Method, Visitor

Page 17: Design Patterns

05/26/2004 www.indyjug.net 17

Design Patterns (Creational)

Creational design patterns abstract the instantiation process. They help make a system independent of how its objects are created, composed, and represented.

(Factory, Singleton)

Page 18: Design Patterns

05/26/2004 www.indyjug.net 18

Design Patterns (Structural)

Structural design patterns are concerned with how classes and objects are composed to form larger structures. (i.e. Inheritance).

(Adapter, Decorator)

Page 19: Design Patterns

05/26/2004 www.indyjug.net 19

Design Patterns (Behavioral)

Behavioral design patterns are concerned with algorithms and the assignment of responsibilities between objects including the communication between them.

(Command, Iterator)

Page 20: Design Patterns

05/26/2004 www.indyjug.net 20

Design Patterns (Review)

Decorator •Allows the ability to change the ‘skin’

Strategy•Allows the ability to change the ‘guts’

Page 21: Design Patterns

05/26/2004 www.indyjug.net 21

Design Patterns (CoR)

“Avoid coupling the sender of a request to its receiver by giving more then one object a chance to handle the request. Chain the receiving objects and pass the request along the chain until an object handles it.” -GoF

Page 22: Design Patterns

05/26/2004 www.indyjug.net 22

Design Patterns

ExampleExample

Page 23: Design Patterns

05/26/2004 www.indyjug.net 23

Design Patterns (References)

•www.javaworld.com/javaworld/jw-08-2004/jw-0816-chain_p.html

•www.devx.com/opinion/Article/22035/1954?pf=true

Page 24: Design Patterns

05/26/2004 www.indyjug.net 24

Design Patterns

Your Turn!!Your Turn!!

Page 25: Design Patterns

05/26/2004 www.indyjug.net 25

Future Topics

Recap from 11/2004:•Sitemesh•Subversion•RUP / XP / Agile•JNDI/LDAP•Clustering / Deploying various OSs•Webstart•PDF Generation•SOA/SOAP/Web Services

Page 26: Design Patterns

05/26/2004 www.indyjug.net 26

Info

•Next Meeting - July 27, 2004•The Art of Agility and the AUP

- Agile unified Process -

•Discussion Forumhttp://groups.yahoo.com/group/indyjug

•Website - http://www.indyjug.net

Page 27: Design Patterns

05/26/2004 www.indyjug.net 27

Indy Java User’s Group

www.indyjug.net