Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Twenty-one Years of Design
Patterns
Ralph E. Johnson
rjohnson.uiuc@gmail.com
Design Patterns: Elements of Reusable
Object-Oriented Design by Erich
Gamma, Richard Helm, Ralph Johnson
and John Vlisside...
Other books
• The Design Patterns Smalltalk
Companion, Alpert, Brown and Woolf
• Heads First Design Patterns, Freeman,
Fre...
• Describes 23 object-oriented design
patterns
• Typical of advanced object-oriented
programming
• Provides a design vocab...
Core patterns
• Mediator
• Façade
• Proxy
• Command
• Template Method
• Adapter
• Null Object
• Composite
• Strategy
• Dec...
Composite
• Idea: make abstract "component" class.
• Alternative 1: every component has a
(possibly empty) set of componen...
Composite Pattern
Component
container
childrenDo:
CompositeLeaf
Composite and Component
have the exact same
interface.
• e...
Observer Pattern
Observer
update:
Subject
addDependent:
removeDependent:
changed:
Mobster
robBank
driveCar
FBIAgent
update...
Listening instead of Observing
• Argument to “update” is an Event
• Many kinds of EventListeners, each
with their own inte...
Different Kinds of Listeners
• ActionListener
– actionPerformed(ActionEvent)
• ComponentListener
– componentResized(Compon...
From the book …
Avoiding observer-specific update protocols: the push and
pull models. Implementations of the Observer pat...
Data Binding
• Implement the model as a composite
model.
• Primitives are properties, lists, etc.
• Model does not “assign...
Value Object
• Immutable object - variables set only by
constructor
• Equality is important, not identity
• Lack of side e...
Null Object
if (obj == NULL) error(‘null pointer’);
else obj->f();
-----------------------
obj->f();
Give an interface to ...
Null Object
NullPart
Part
PartDecoratorCompositePart
1-N
Dangerous Patterns
• Mediator
– Supposed to be used to allow colleagues to
be reusable. Is often used to allow
programmers...
Creational
• Abstract factory (peripheral)
• Factory method
• Prototype
• Builder
• Singleton
• Dependency Injection
Peripheral
• Memento
• Chain of responsibility
• Bridge
• Visitor
• Type Object
• Extension Object
• Generation Gap
Compound
• Flyweight
– To save space, factor out a Value Object, and create
them using a Memoizing Factory that records th...
Issues: Design
• Refactor to patterns
• Patterns not measure of goodness
• Patterns used for
– Variability management
– De...
Ways to improve
• Patterns are examples of principles
• Patterns are part of overall design style
– Pattern language
– Evo...
Conclusion
• We could have done better.
• But we did pretty well!
• For more info on patterns, including
conferences and p...
Upcoming SlideShare
Loading in …5
×

JDD2015: Twenty-one years of "Design Patterns" - Ralph Johnson

188 views

Published on

TWENTY-ONE YEARS OF "DESIGN PATTERNS"

The book "Design Patterns" was released in October of 1994 and is still in print. It has received many awards and has many imitators. However, the years have shown weaknesses in the book. This talk describes a few lessons that we have learned since writing it.

Published in: Software
  • Be the first to comment

JDD2015: Twenty-one years of "Design Patterns" - Ralph Johnson

  1. 1. Twenty-one Years of Design Patterns Ralph E. Johnson rjohnson.uiuc@gmail.com
  2. 2. Design Patterns: Elements of Reusable Object-Oriented Design by Erich Gamma, Richard Helm, Ralph Johnson and John Vlissides, 1995. Released in October 1994 at OOPSLA. Jolt Award, Dr. Dobbs Journal award, SIGPLAN Programming Languages award, SIGSOFT Software Engineering award, Aito Dahl-Nygard Prize
  3. 3. Other books • The Design Patterns Smalltalk Companion, Alpert, Brown and Woolf • Heads First Design Patterns, Freeman, Freeman, Bates and Sierra. • Domain Driven Design, Eric Evans • Patterns of Enterprise Application Architecture, Fowler et. al. • http://hillside.net/patterns/books
  4. 4. • Describes 23 object-oriented design patterns • Typical of advanced object-oriented programming • Provides a design vocabulary – Learning – Communication – Design
  5. 5. Core patterns • Mediator • Façade • Proxy • Command • Template Method • Adapter • Null Object • Composite • Strategy • Decorator • State • Iterator • Observer • Value Object
  6. 6. Composite • Idea: make abstract "component" class. • Alternative 1: every component has a (possibly empty) set of components. • Problem: many components have no components. Component Children ParagraphChapter ... *
  7. 7. Composite Pattern Component container childrenDo: CompositeLeaf Composite and Component have the exact same interface. • enumerating children • childrenDo: for Component does nothing • only Composite adds removes children. 1-N
  8. 8. Observer Pattern Observer update: Subject addDependent: removeDependent: changed: Mobster robBank driveCar FBIAgent update: observer/ dependent model 1-N
  9. 9. Listening instead of Observing • Argument to “update” is an Event • Many kinds of EventListeners, each with their own interface • An EventListener interface can have more than one update method
  10. 10. Different Kinds of Listeners • ActionListener – actionPerformed(ActionEvent) • ComponentListener – componentResized(ComponentEvent) – componentMoved(ComponentEvent) – componentShown(ComponentEvent) – componentHidden(ComponentEvent) • PropertyChangeListener – propertyChange(PropertyChangeEvent)
  11. 11. From the book … Avoiding observer-specific update protocols: the push and pull models. Implementations of the Observer pattern often have the subject broadcast additional information about the change. The subject passes this information as an argument to Update. The amount of information may vary widely. … The pull model emphasizes the subject’s ignorance of its observers, whereas the push model assumes subjects know something about their observers’ needs. The push model might make observers less reusable, because Subject classes make assumptions about Observer classes that might not always be true.
  12. 12. Data Binding • Implement the model as a composite model. • Primitives are properties, lists, etc. • Model does not “assign to variable”, but “sets value of property”. • Results: Observers are reusable, don’t have to invoke update events explicitely
  13. 13. Value Object • Immutable object - variables set only by constructor • Equality is important, not identity • Lack of side effects - easier to make correct
  14. 14. Null Object if (obj == NULL) error(‘null pointer’); else obj->f(); ----------------------- obj->f(); Give an interface to “null”, make a version of null for any interface. Eliminate checking.
  15. 15. Null Object NullPart Part PartDecoratorCompositePart 1-N
  16. 16. Dangerous Patterns • Mediator – Supposed to be used to allow colleagues to be reusable. Is often used to allow programmers to continue to be procedural. • Singleton – Supposed to be used to encapsulate global state when it cannot be eliminated. Is often used as a justification of global state.
  17. 17. Creational • Abstract factory (peripheral) • Factory method • Prototype • Builder • Singleton • Dependency Injection
  18. 18. Peripheral • Memento • Chain of responsibility • Bridge • Visitor • Type Object • Extension Object • Generation Gap
  19. 19. Compound • Flyweight – To save space, factor out a Value Object, and create them using a Memoizing Factory that records the flyweight pool. • Interpreter – Represent a program with a Composite, and let the class hierarchy match the grammar of the language. Define an “interpret” method in each class.
  20. 20. Issues: Design • Refactor to patterns • Patterns not measure of goodness • Patterns used for – Variability management – Decoupling – Dependence management • Patterns a means to an end, not the end
  21. 21. Ways to improve • Patterns are examples of principles • Patterns are part of overall design style – Pattern language – Evolving Frameworks – http://st- www.cs.uiuc.edu/~droberts/evolve.html
  22. 22. Conclusion • We could have done better. • But we did pretty well! • For more info on patterns, including conferences and publications, see http://hillside.net • rjohnson.uiuc@gmail.com

×