SlideShare a Scribd company logo
1 of 53
Download to read offline
Design Patterns
  illustrated




        Herman Peeren          May 31st 2010
              (DP-illustrations: Nelleke Verhoeff)
Design Patterns
●●   recipes against common (OO-) programming problems
●●   code reuse: no need to reinvent the wheel
●●   common language
●●   GOF: 23 “classical” patterns



                     classic,
                     The Book




                           very nice!
The one constant in software development:
The one constant in software development:



CHANGE!
The one constant in software development:



CHANGE!

                     I knew it ...
Ideal: code as modular black boxes
Wish list and OOP-principles
●●   loose coupling: 1 change = ceteris paribus

●●   code reuse (is not the same as copy/paste)

●●   open for extension, closed for modification

●●   encapsulate what varies

●●   single responsibility principle

●●   program against an interface not against an imple-
     mentation. Dependency injection

●●   prefer composition over inheritance

(in fact this is all the same with different words)
Avoid: tight coupling!
It might get you into trouble...
Beware of:



Code
smells!
some code smells:
1.●   duplicate code: DRY
2.●   long method, huge class: SRP
3.●   combinatorial explosion (similar classes)
4.●   conditional complexity, switch statements
5.●   “exhibitionistic” classes
some code smells:
1.●   duplicate code: DRY
2.●   long method, huge class: SRP
3.●   combinatorial explosion (similar classes)
4.●   conditional complexity, switch statements
5.●   “exhibitionistic” classes
Classic pattern categories
creational, structural and behavioral patterns:

●●   creational: object instantiation
●●   structural: larger structures of classes or objects
●●   behavioral: interaction and distribution of responsibility
Creational design patterns
●● Factory Method: Allow subclasses to “decide”
   which class to instantiate.
●● Abstract Factory: Encapsulate a set of analo-
   gous factories that produce families of objects.
●● Builder: Encapsulate the construction of com-
   plex objects from their representation; so, the
   same building process can create various repre-
   sentations by specifying only type and content.
●● Singleton: Ensure that only a single instance of
   a class exists and provide a single method for
   gaining access to it.
●● Prototype: Create an initialized instance for
   cloning or copying.
Factory Method
    Provide an interface for the creation of objects.
    Allow subclasses to “decide” which class to instantiate.
c
Abstract Factory
    Povide an interface for creating families of related
    or dependent objects. A factory for factories.
c
Builder
    Seperate the construction process (how) of a complex object
    from the concrete representations (what).
c
Singleton
    Ensure a class only has one instance, and provide a global
    point of access to it.




                               Oh, I’m so
                                loooooooonly
c
Joomla!
●●   JFactory: a class with static methods to instantiate objects
     like JDatabase, JUser, JDocument, JTemplate, etc.
●●   most of those methods are singletons




Nooku
●●   KFactory: any class can be instantiated
●●   get() = singleton, tmp() = any instantiation
“Every
      advantage
        has its
   disadvantages”
(free to Johan Cruyff,
Dutch Football Pattern Designer
and Ajax-fan...)
Prototype
    Make variations on copies of a basic-object.




                              COPY-SERVICE
c
Structural design patterns
●● Adapter: Adapt an interface to an expected
   interface.
●● Bridge: Decouple an interface from its
   implementation.
●● Composite: Create a tree structure for
   part-whole hierarchies.
●● Decorator: Extend functionality dynamically.
●● Facade: Simplify usage by defining a high-level
   interface.
●● Flyweight: Support fine-grained objects
   efficiently by sharing.
●● Proxy: Represent an object with another object
   for access control.
Adapter (= Wrapper)
c   Adapt an interface to an expected interface.
Joomla!
●●   new in 1.6: JAdapter and JAdapterInstance

●●   JUpdateAdapter extends JAdapterInstance

     JUpdaterExtension & JUpdaterExtension
     extend JUpdateAdapter


wanted: documentation and examples!
what does it adapt?
Bridge
    Decouple an abstraction from its implementation.




                                                                COLA
    1 LITER                                                     1 LITER

                                                      COLA
              1 LITER                                 1 LITER
                                               COLA
                        MILK

                                             COLA
                               MILK                 COLA
                   MILK
c
Composite
    Create a tree structure for part-whole hierarchies. A node is also a
    (part of a) tree. Recursive:
c
Decorator
    Add extra functionallity (at runtime),
    while keeping the interface the same.
    Matroushka’s...
c
Decorator




Nooku
●●   KPatternDecorator: a general decorator
●●   e.g. extended by KDecoratorJoomlaApplication
Facade
    Provide a general (simpler) interface for a set of interfaces.




              looks
             simple
c
Flyweight
    Use one instance of a class to provide many
    “virtual” instances.
c
Proxy
    Provide a surrogate or placeholder for another object
    to control access to it.
c
Behavioral design patterns
●● Chain of Responsibility: Define a method of passing a
request among a chain of objects.
●● Command: Encapsulate a command request in an object.
●● Interpreter: Allow inclusion of language elements in an appli-
cation.
●● Iterator: Enable sequential access to collection elements.
●● Mediator: Define simplified communication between classes.
●● Memento: Save and restore the internal state of an object.
●● Observer: Define a scheme for notifying objects of changes to
another object.
●● State: Alter the behavior of an object when its state changes.
●● Strategy: Encapsulate an algorithm inside a class.
●● Template Method: Allow subclasses to redefine the steps of
an algorithm.
●● Visitor: Define a new operation on a class without changing it.
Command
    Encapsulate a command request in an object.




                      YOU,DO YOUR
                         TASK!




          TASK                                    TASK
          LIGHT                                   LIGHT
           ON                                      OFF
c
Chain of Responsibility
c
    Define a method of passing a request among a chain of objects.
Nooku
●●   KCommandChain
     + KCommandContext, KCommandEvent, KCommandHandler and
     KCommandInterface

●●    N.B.: executes a series of commands
     instead of passing a command to a series of handlers
     (like in Tapestry e.g.) ...correct me if I’m wrong....
Interpreter
    Domain -> (little) language -> grammar -> objects
    (DSL)



              HÉ!         he means:
                      do this, do that,
                    and after finishing it,
                          go there!
c
Iterator
    Enable sequential access to collection elements, without showing
    the underlying data-structures (array, list, records, etc)


           next




    next
c
Mediator
c   Layer in between: communication via one object.
Memento
    Save and restore the internal state of an object.




                                          ME
c
Observer
    Notify “subscribers” of changes.



                                            ME

                                                 NO   ME
                                       ME


                 WHO?
c
Joomla!
●●   JObserver and JObservable
●●   JObserver extended by JEvent and that by JPlugin




Nooku
●●   KPatternObserver and KPatternObservable
State
Let an object show other methods after a change of internal
state (as if it changes it’s class).



      in a.....hick......different state,
      ....hick....I behave differently....hick.....




c
Strategy
    When something can be done in several ways, make those
    ways interchangeable.




                       POSSI-
                       BILITIES
c
Template Method
    The skeleton of an algorithm is fixed, but parts can be filled in
    differently.
c
Visitor
    Make a kind of plugin-possibility for methods: in that way me-
    thods can be added in runtime.




          printservice!
c
extra: Mixin
●●   Used in Nooku (and a.o. in Ruby and Python)
●●   a kind of abstract class that is mixed into another object
●●   all methods of the mixin are now part of the object
●●   handle with care: beware of tight coupling....
Golden OO-principles

 ●●   encapsulate what varies, OCP

 ●●   1class, 1 responsibility, SRP

 ●●   program against an interface, not against an imple-
      mentation, DIP

 ●●   prefer composition over inheritance

 ●●   loose coupling, modular black boxes
Some books
GOF: 23 “classical” patterns:




                               very nice!


                    classic,
                    The Book




                               handy
                               examples
good start




       Fowler:
       extended
       e.g. with
       patterns
       for web



Fowler: also
known from
refactoring




        combi: re-
        factoring
        & patterns
Resign Patterns:
Ailments of Unsuitable Project-Disoriented Software
Joomla!
Could be improved by studying design patterns and applying
them.

                                           Loose coupling...
Questions?



Contact info:
Herman Peeren
herman@yepr.nl
© Yepr
The artwork in this presentation is provided under the
Creative Commons Public License for noncommercial use.
http://creativecommons.org/licenses/by-nc/3.0/legalcode

More Related Content

What's hot (20)

Gof design patterns
Gof design patternsGof design patterns
Gof design patterns
 
The Singleton Pattern Presentation
The Singleton Pattern PresentationThe Singleton Pattern Presentation
The Singleton Pattern Presentation
 
Let us understand design pattern
Let us understand design patternLet us understand design pattern
Let us understand design pattern
 
Hibernate ppt
Hibernate pptHibernate ppt
Hibernate ppt
 
Java Design Patterns Tutorial | Edureka
Java Design Patterns Tutorial | EdurekaJava Design Patterns Tutorial | Edureka
Java Design Patterns Tutorial | Edureka
 
Design patterns ppt
Design patterns pptDesign patterns ppt
Design patterns ppt
 
Spring Boot and REST API
Spring Boot and REST APISpring Boot and REST API
Spring Boot and REST API
 
Design Patterns Presentation - Chetan Gole
Design Patterns Presentation -  Chetan GoleDesign Patterns Presentation -  Chetan Gole
Design Patterns Presentation - Chetan Gole
 
Model View Controller (MVC)
Model View Controller (MVC)Model View Controller (MVC)
Model View Controller (MVC)
 
Dependency Injection
Dependency InjectionDependency Injection
Dependency Injection
 
Spring data jpa
Spring data jpaSpring data jpa
Spring data jpa
 
Reactive Programming in Java 8 with Rx-Java
Reactive Programming in Java 8 with Rx-JavaReactive Programming in Java 8 with Rx-Java
Reactive Programming in Java 8 with Rx-Java
 
REST & RESTful Web Services
REST & RESTful Web ServicesREST & RESTful Web Services
REST & RESTful Web Services
 
Angular - Chapter 7 - HTTP Services
Angular - Chapter 7 - HTTP ServicesAngular - Chapter 7 - HTTP Services
Angular - Chapter 7 - HTTP Services
 
Basic Concepts of OOPs (Object Oriented Programming in Java)
Basic Concepts of OOPs (Object Oriented Programming in Java)Basic Concepts of OOPs (Object Oriented Programming in Java)
Basic Concepts of OOPs (Object Oriented Programming in Java)
 
Threads in JAVA
Threads in JAVAThreads in JAVA
Threads in JAVA
 
Java collections concept
Java collections conceptJava collections concept
Java collections concept
 
Software Design Patterns
Software Design PatternsSoftware Design Patterns
Software Design Patterns
 
Java Collections
Java  Collections Java  Collections
Java Collections
 
Spring Core
Spring CoreSpring Core
Spring Core
 

Viewers also liked

Design Patterns
Design PatternsDesign Patterns
Design Patternssoms_1
 
Introduction to Design Pattern
Introduction to Design  PatternIntroduction to Design  Pattern
Introduction to Design PatternSanae BEKKAR
 
Refactoring - An Introduction
Refactoring - An IntroductionRefactoring - An Introduction
Refactoring - An IntroductionGiorgio Vespucci
 
The Decorator Pattern
The Decorator PatternThe Decorator Pattern
The Decorator PatternAkshat Vig
 
Refactoring 101
Refactoring 101Refactoring 101
Refactoring 101Adam Culp
 
Design Patterns這樣學就會了:入門班 Day1 教材
Design Patterns這樣學就會了:入門班 Day1 教材Design Patterns這樣學就會了:入門班 Day1 教材
Design Patterns這樣學就會了:入門班 Day1 教材teddysoft
 
Design Patterns - 01 Introduction and Decorator Pattern
Design Patterns - 01 Introduction and Decorator PatternDesign Patterns - 01 Introduction and Decorator Pattern
Design Patterns - 01 Introduction and Decorator Patterneprafulla
 

Viewers also liked (13)

Design Patterns
Design PatternsDesign Patterns
Design Patterns
 
saleh nazzal
saleh nazzalsaleh nazzal
saleh nazzal
 
عربي
عربيعربي
عربي
 
Code Refactoring
Code RefactoringCode Refactoring
Code Refactoring
 
Introduction to Design Pattern
Introduction to Design  PatternIntroduction to Design  Pattern
Introduction to Design Pattern
 
Refactoring - An Introduction
Refactoring - An IntroductionRefactoring - An Introduction
Refactoring - An Introduction
 
The Decorator Pattern
The Decorator PatternThe Decorator Pattern
The Decorator Pattern
 
Refactoring 101
Refactoring 101Refactoring 101
Refactoring 101
 
Refactoring
RefactoringRefactoring
Refactoring
 
Design patterns
Design patternsDesign patterns
Design patterns
 
Design Patterns這樣學就會了:入門班 Day1 教材
Design Patterns這樣學就會了:入門班 Day1 教材Design Patterns這樣學就會了:入門班 Day1 教材
Design Patterns這樣學就會了:入門班 Day1 教材
 
Design Patterns - 01 Introduction and Decorator Pattern
Design Patterns - 01 Introduction and Decorator PatternDesign Patterns - 01 Introduction and Decorator Pattern
Design Patterns - 01 Introduction and Decorator Pattern
 
SlideShare 101
SlideShare 101SlideShare 101
SlideShare 101
 

Similar to Design Patterns Illustrated

Designpatterns illustrated
Designpatterns illustratedDesignpatterns illustrated
Designpatterns illustratedNhat Vo Van
 
Design patterns illustrated-2015-03
Design patterns illustrated-2015-03Design patterns illustrated-2015-03
Design patterns illustrated-2015-03Herman Peeren
 
I know Java, why should I consider Clojure?
I know Java, why should I consider Clojure?I know Java, why should I consider Clojure?
I know Java, why should I consider Clojure?sbjug
 
I didn't know you could do that with groovy
I didn't know you could do that with groovyI didn't know you could do that with groovy
I didn't know you could do that with groovySteven Hicks
 
Design Patterns Part1
Design Patterns  Part1Design Patterns  Part1
Design Patterns Part1Tom Chen
 
Dennis Benkert & Matthias Lübken - Patterns in a containerized world? - code....
Dennis Benkert & Matthias Lübken - Patterns in a containerized world? - code....Dennis Benkert & Matthias Lübken - Patterns in a containerized world? - code....
Dennis Benkert & Matthias Lübken - Patterns in a containerized world? - code....AboutYouGmbH
 
Design patterns in javascript
Design patterns in javascriptDesign patterns in javascript
Design patterns in javascriptAyush Sharma
 
Design patterns illustrated 010PHP
Design patterns illustrated 010PHPDesign patterns illustrated 010PHP
Design patterns illustrated 010PHPHerman Peeren
 
New c sharp4_features_part_iv
New c sharp4_features_part_ivNew c sharp4_features_part_iv
New c sharp4_features_part_ivNico Ludwig
 
(4) c sharp introduction_object_orientation_part_i
(4) c sharp introduction_object_orientation_part_i(4) c sharp introduction_object_orientation_part_i
(4) c sharp introduction_object_orientation_part_iNico Ludwig
 
Introduction to Clojure
Introduction to ClojureIntroduction to Clojure
Introduction to ClojureRenzo Borgatti
 
Mixing Diagram, Tree, Text, Table and Form editors to build a kick-ass modeli...
Mixing Diagram, Tree, Text, Table and Form editors to build a kick-ass modeli...Mixing Diagram, Tree, Text, Table and Form editors to build a kick-ass modeli...
Mixing Diagram, Tree, Text, Table and Form editors to build a kick-ass modeli...Chauvin Mariot
 
Smalltalk, the dynamic language
Smalltalk, the dynamic languageSmalltalk, the dynamic language
Smalltalk, the dynamic languagemohamedsamyali
 
Post-graduate course: Object technology: Implementation of object-oriented pr...
Post-graduate course: Object technology: Implementation of object-oriented pr...Post-graduate course: Object technology: Implementation of object-oriented pr...
Post-graduate course: Object technology: Implementation of object-oriented pr...Baltasar García Perez-Schofield
 
Deep Dive into Monads and Cats Lib
Deep Dive into Monads and Cats LibDeep Dive into Monads and Cats Lib
Deep Dive into Monads and Cats LibKnoldus Inc.
 
Effects, coeffects & subscriptions: a pit of success for SPAs Socracan18
Effects, coeffects & subscriptions: a pit of success for SPAs Socracan18Effects, coeffects & subscriptions: a pit of success for SPAs Socracan18
Effects, coeffects & subscriptions: a pit of success for SPAs Socracan18Manuel Rivero
 
Concurrency - Why it's hard ?
Concurrency - Why it's hard ?Concurrency - Why it's hard ?
Concurrency - Why it's hard ?Ramith Jayasinghe
 
Design Pattern lecture 2
Design Pattern lecture 2Design Pattern lecture 2
Design Pattern lecture 2Julie Iskander
 

Similar to Design Patterns Illustrated (20)

Designpatterns illustrated
Designpatterns illustratedDesignpatterns illustrated
Designpatterns illustrated
 
Design patterns illustrated-2015-03
Design patterns illustrated-2015-03Design patterns illustrated-2015-03
Design patterns illustrated-2015-03
 
I know Java, why should I consider Clojure?
I know Java, why should I consider Clojure?I know Java, why should I consider Clojure?
I know Java, why should I consider Clojure?
 
I didn't know you could do that with groovy
I didn't know you could do that with groovyI didn't know you could do that with groovy
I didn't know you could do that with groovy
 
Design Patterns Part1
Design Patterns  Part1Design Patterns  Part1
Design Patterns Part1
 
Dennis Benkert & Matthias Lübken - Patterns in a containerized world? - code....
Dennis Benkert & Matthias Lübken - Patterns in a containerized world? - code....Dennis Benkert & Matthias Lübken - Patterns in a containerized world? - code....
Dennis Benkert & Matthias Lübken - Patterns in a containerized world? - code....
 
Design patterns in javascript
Design patterns in javascriptDesign patterns in javascript
Design patterns in javascript
 
Design patterns illustrated 010PHP
Design patterns illustrated 010PHPDesign patterns illustrated 010PHP
Design patterns illustrated 010PHP
 
New c sharp4_features_part_iv
New c sharp4_features_part_ivNew c sharp4_features_part_iv
New c sharp4_features_part_iv
 
(4) c sharp introduction_object_orientation_part_i
(4) c sharp introduction_object_orientation_part_i(4) c sharp introduction_object_orientation_part_i
(4) c sharp introduction_object_orientation_part_i
 
Introduction to Clojure
Introduction to ClojureIntroduction to Clojure
Introduction to Clojure
 
Mixing Diagram, Tree, Text, Table and Form editors to build a kick-ass modeli...
Mixing Diagram, Tree, Text, Table and Form editors to build a kick-ass modeli...Mixing Diagram, Tree, Text, Table and Form editors to build a kick-ass modeli...
Mixing Diagram, Tree, Text, Table and Form editors to build a kick-ass modeli...
 
Smalltalk, the dynamic language
Smalltalk, the dynamic languageSmalltalk, the dynamic language
Smalltalk, the dynamic language
 
Post-graduate course: Object technology: Implementation of object-oriented pr...
Post-graduate course: Object technology: Implementation of object-oriented pr...Post-graduate course: Object technology: Implementation of object-oriented pr...
Post-graduate course: Object technology: Implementation of object-oriented pr...
 
Deep Dive into Monads and Cats Lib
Deep Dive into Monads and Cats LibDeep Dive into Monads and Cats Lib
Deep Dive into Monads and Cats Lib
 
Multi screenlab
Multi screenlabMulti screenlab
Multi screenlab
 
Effects, coeffects & subscriptions: a pit of success for SPAs Socracan18
Effects, coeffects & subscriptions: a pit of success for SPAs Socracan18Effects, coeffects & subscriptions: a pit of success for SPAs Socracan18
Effects, coeffects & subscriptions: a pit of success for SPAs Socracan18
 
Concurrency - Why it's hard ?
Concurrency - Why it's hard ?Concurrency - Why it's hard ?
Concurrency - Why it's hard ?
 
Design Pattern lecture 2
Design Pattern lecture 2Design Pattern lecture 2
Design Pattern lecture 2
 
Hibernate 1x2
Hibernate 1x2Hibernate 1x2
Hibernate 1x2
 

More from Herman Peeren

ProjectionalForms-2023-11-14.pdf
ProjectionalForms-2023-11-14.pdfProjectionalForms-2023-11-14.pdf
ProjectionalForms-2023-11-14.pdfHerman Peeren
 
ExtensionGenerator-JoomlaDagen2023-slides.pdf
ExtensionGenerator-JoomlaDagen2023-slides.pdfExtensionGenerator-JoomlaDagen2023-slides.pdf
ExtensionGenerator-JoomlaDagen2023-slides.pdfHerman Peeren
 
Programmeren, talen en het begrijpen van de wereld
Programmeren, talen en het begrijpen van de wereldProgrammeren, talen en het begrijpen van de wereld
Programmeren, talen en het begrijpen van de wereldHerman Peeren
 
Improve our PHP code with ideas from Functional Programming
Improve our PHP code with ideas from Functional ProgrammingImprove our PHP code with ideas from Functional Programming
Improve our PHP code with ideas from Functional ProgrammingHerman Peeren
 
DCI DDD-BE April 2015
DCI DDD-BE April 2015DCI DDD-BE April 2015
DCI DDD-BE April 2015Herman Peeren
 
Next Generation Joomla!
Next Generation Joomla!Next Generation Joomla!
Next Generation Joomla!Herman Peeren
 
Behat, Behavioral Driven Development (BDD) in PHP
Behat, Behavioral Driven Development (BDD) in PHPBehat, Behavioral Driven Development (BDD) in PHP
Behat, Behavioral Driven Development (BDD) in PHPHerman Peeren
 
Print, geen kunst aan
Print, geen kunst aanPrint, geen kunst aan
Print, geen kunst aanHerman Peeren
 
Jooctrine - Doctrine ORM in Joomla!
Jooctrine - Doctrine ORM in Joomla!Jooctrine - Doctrine ORM in Joomla!
Jooctrine - Doctrine ORM in Joomla!Herman Peeren
 
#jd12nl Joomla 2.5 extensies
#jd12nl Joomla 2.5 extensies#jd12nl Joomla 2.5 extensies
#jd12nl Joomla 2.5 extensiesHerman Peeren
 
Jug010 120320-templates
Jug010 120320-templatesJug010 120320-templates
Jug010 120320-templatesHerman Peeren
 
Joomla2.0 architecture
Joomla2.0 architectureJoomla2.0 architecture
Joomla2.0 architectureHerman Peeren
 
Webservices: connecting Joomla! with other programs.
Webservices: connecting Joomla! with other programs.Webservices: connecting Joomla! with other programs.
Webservices: connecting Joomla! with other programs.Herman Peeren
 
Commercial gpljoomla
Commercial gpljoomlaCommercial gpljoomla
Commercial gpljoomlaHerman Peeren
 
Flash templates for Joomla!
Flash templates for Joomla!Flash templates for Joomla!
Flash templates for Joomla!Herman Peeren
 

More from Herman Peeren (19)

ProjectionalForms-2023-11-14.pdf
ProjectionalForms-2023-11-14.pdfProjectionalForms-2023-11-14.pdf
ProjectionalForms-2023-11-14.pdf
 
ExtensionGenerator-JoomlaDagen2023-slides.pdf
ExtensionGenerator-JoomlaDagen2023-slides.pdfExtensionGenerator-JoomlaDagen2023-slides.pdf
ExtensionGenerator-JoomlaDagen2023-slides.pdf
 
Cut & Shave
Cut & ShaveCut & Shave
Cut & Shave
 
Programmeren, talen en het begrijpen van de wereld
Programmeren, talen en het begrijpen van de wereldProgrammeren, talen en het begrijpen van de wereld
Programmeren, talen en het begrijpen van de wereld
 
Dci in PHP
Dci in PHPDci in PHP
Dci in PHP
 
Improve our PHP code with ideas from Functional Programming
Improve our PHP code with ideas from Functional ProgrammingImprove our PHP code with ideas from Functional Programming
Improve our PHP code with ideas from Functional Programming
 
DCI DDD-BE April 2015
DCI DDD-BE April 2015DCI DDD-BE April 2015
DCI DDD-BE April 2015
 
Event Sourcing
Event SourcingEvent Sourcing
Event Sourcing
 
Next Generation Joomla!
Next Generation Joomla!Next Generation Joomla!
Next Generation Joomla!
 
Behat, Behavioral Driven Development (BDD) in PHP
Behat, Behavioral Driven Development (BDD) in PHPBehat, Behavioral Driven Development (BDD) in PHP
Behat, Behavioral Driven Development (BDD) in PHP
 
Print, geen kunst aan
Print, geen kunst aanPrint, geen kunst aan
Print, geen kunst aan
 
Jooctrine - Doctrine ORM in Joomla!
Jooctrine - Doctrine ORM in Joomla!Jooctrine - Doctrine ORM in Joomla!
Jooctrine - Doctrine ORM in Joomla!
 
#jd12nl Joomla 2.5 extensies
#jd12nl Joomla 2.5 extensies#jd12nl Joomla 2.5 extensies
#jd12nl Joomla 2.5 extensies
 
#jd12nl Seblod 2
#jd12nl  Seblod 2#jd12nl  Seblod 2
#jd12nl Seblod 2
 
Jug010 120320-templates
Jug010 120320-templatesJug010 120320-templates
Jug010 120320-templates
 
Joomla2.0 architecture
Joomla2.0 architectureJoomla2.0 architecture
Joomla2.0 architecture
 
Webservices: connecting Joomla! with other programs.
Webservices: connecting Joomla! with other programs.Webservices: connecting Joomla! with other programs.
Webservices: connecting Joomla! with other programs.
 
Commercial gpljoomla
Commercial gpljoomlaCommercial gpljoomla
Commercial gpljoomla
 
Flash templates for Joomla!
Flash templates for Joomla!Flash templates for Joomla!
Flash templates for Joomla!
 

Recently uploaded

A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesThousandEyes
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfIngrid Airi González
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPathCommunity
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationKnoldus Inc.
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Farhan Tariq
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch TuesdayIvanti
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfNeo4j
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Strongerpanagenda
 
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Scott Andery
 
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...AliaaTarek5
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Mark Goldstein
 

Recently uploaded (20)

A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdf
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to Hero
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog Presentation
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch Tuesday
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
 
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
 
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
 

Design Patterns Illustrated

  • 1. Design Patterns illustrated Herman Peeren May 31st 2010 (DP-illustrations: Nelleke Verhoeff)
  • 2. Design Patterns ●● recipes against common (OO-) programming problems ●● code reuse: no need to reinvent the wheel ●● common language ●● GOF: 23 “classical” patterns classic, The Book very nice!
  • 3. The one constant in software development:
  • 4. The one constant in software development: CHANGE!
  • 5. The one constant in software development: CHANGE! I knew it ...
  • 6. Ideal: code as modular black boxes
  • 7. Wish list and OOP-principles ●● loose coupling: 1 change = ceteris paribus ●● code reuse (is not the same as copy/paste) ●● open for extension, closed for modification ●● encapsulate what varies ●● single responsibility principle ●● program against an interface not against an imple- mentation. Dependency injection ●● prefer composition over inheritance (in fact this is all the same with different words)
  • 9. It might get you into trouble...
  • 11. some code smells: 1.● duplicate code: DRY 2.● long method, huge class: SRP 3.● combinatorial explosion (similar classes) 4.● conditional complexity, switch statements 5.● “exhibitionistic” classes
  • 12. some code smells: 1.● duplicate code: DRY 2.● long method, huge class: SRP 3.● combinatorial explosion (similar classes) 4.● conditional complexity, switch statements 5.● “exhibitionistic” classes
  • 13. Classic pattern categories creational, structural and behavioral patterns: ●● creational: object instantiation ●● structural: larger structures of classes or objects ●● behavioral: interaction and distribution of responsibility
  • 14. Creational design patterns ●● Factory Method: Allow subclasses to “decide” which class to instantiate. ●● Abstract Factory: Encapsulate a set of analo- gous factories that produce families of objects. ●● Builder: Encapsulate the construction of com- plex objects from their representation; so, the same building process can create various repre- sentations by specifying only type and content. ●● Singleton: Ensure that only a single instance of a class exists and provide a single method for gaining access to it. ●● Prototype: Create an initialized instance for cloning or copying.
  • 15. Factory Method Provide an interface for the creation of objects. Allow subclasses to “decide” which class to instantiate. c
  • 16. Abstract Factory Povide an interface for creating families of related or dependent objects. A factory for factories. c
  • 17. Builder Seperate the construction process (how) of a complex object from the concrete representations (what). c
  • 18. Singleton Ensure a class only has one instance, and provide a global point of access to it. Oh, I’m so loooooooonly c
  • 19. Joomla! ●● JFactory: a class with static methods to instantiate objects like JDatabase, JUser, JDocument, JTemplate, etc. ●● most of those methods are singletons Nooku ●● KFactory: any class can be instantiated ●● get() = singleton, tmp() = any instantiation
  • 20. “Every advantage has its disadvantages” (free to Johan Cruyff, Dutch Football Pattern Designer and Ajax-fan...)
  • 21. Prototype Make variations on copies of a basic-object. COPY-SERVICE c
  • 22. Structural design patterns ●● Adapter: Adapt an interface to an expected interface. ●● Bridge: Decouple an interface from its implementation. ●● Composite: Create a tree structure for part-whole hierarchies. ●● Decorator: Extend functionality dynamically. ●● Facade: Simplify usage by defining a high-level interface. ●● Flyweight: Support fine-grained objects efficiently by sharing. ●● Proxy: Represent an object with another object for access control.
  • 23. Adapter (= Wrapper) c Adapt an interface to an expected interface.
  • 24. Joomla! ●● new in 1.6: JAdapter and JAdapterInstance ●● JUpdateAdapter extends JAdapterInstance JUpdaterExtension & JUpdaterExtension extend JUpdateAdapter wanted: documentation and examples! what does it adapt?
  • 25. Bridge Decouple an abstraction from its implementation. COLA 1 LITER 1 LITER COLA 1 LITER 1 LITER COLA MILK COLA MILK COLA MILK c
  • 26. Composite Create a tree structure for part-whole hierarchies. A node is also a (part of a) tree. Recursive: c
  • 27. Decorator Add extra functionallity (at runtime), while keeping the interface the same. Matroushka’s... c
  • 28. Decorator Nooku ●● KPatternDecorator: a general decorator ●● e.g. extended by KDecoratorJoomlaApplication
  • 29. Facade Provide a general (simpler) interface for a set of interfaces. looks simple c
  • 30. Flyweight Use one instance of a class to provide many “virtual” instances. c
  • 31. Proxy Provide a surrogate or placeholder for another object to control access to it. c
  • 32. Behavioral design patterns ●● Chain of Responsibility: Define a method of passing a request among a chain of objects. ●● Command: Encapsulate a command request in an object. ●● Interpreter: Allow inclusion of language elements in an appli- cation. ●● Iterator: Enable sequential access to collection elements. ●● Mediator: Define simplified communication between classes. ●● Memento: Save and restore the internal state of an object. ●● Observer: Define a scheme for notifying objects of changes to another object. ●● State: Alter the behavior of an object when its state changes. ●● Strategy: Encapsulate an algorithm inside a class. ●● Template Method: Allow subclasses to redefine the steps of an algorithm. ●● Visitor: Define a new operation on a class without changing it.
  • 33. Command Encapsulate a command request in an object. YOU,DO YOUR TASK! TASK TASK LIGHT LIGHT ON OFF c
  • 34. Chain of Responsibility c Define a method of passing a request among a chain of objects.
  • 35. Nooku ●● KCommandChain + KCommandContext, KCommandEvent, KCommandHandler and KCommandInterface ●● N.B.: executes a series of commands instead of passing a command to a series of handlers (like in Tapestry e.g.) ...correct me if I’m wrong....
  • 36. Interpreter Domain -> (little) language -> grammar -> objects (DSL) HÉ! he means: do this, do that, and after finishing it, go there! c
  • 37. Iterator Enable sequential access to collection elements, without showing the underlying data-structures (array, list, records, etc) next next c
  • 38. Mediator c Layer in between: communication via one object.
  • 39. Memento Save and restore the internal state of an object. ME c
  • 40. Observer Notify “subscribers” of changes. ME NO ME ME WHO? c
  • 41. Joomla! ●● JObserver and JObservable ●● JObserver extended by JEvent and that by JPlugin Nooku ●● KPatternObserver and KPatternObservable
  • 42. State Let an object show other methods after a change of internal state (as if it changes it’s class). in a.....hick......different state, ....hick....I behave differently....hick..... c
  • 43. Strategy When something can be done in several ways, make those ways interchangeable. POSSI- BILITIES c
  • 44.
  • 45. Template Method The skeleton of an algorithm is fixed, but parts can be filled in differently. c
  • 46. Visitor Make a kind of plugin-possibility for methods: in that way me- thods can be added in runtime. printservice! c
  • 47. extra: Mixin ●● Used in Nooku (and a.o. in Ruby and Python) ●● a kind of abstract class that is mixed into another object ●● all methods of the mixin are now part of the object ●● handle with care: beware of tight coupling....
  • 48. Golden OO-principles ●● encapsulate what varies, OCP ●● 1class, 1 responsibility, SRP ●● program against an interface, not against an imple- mentation, DIP ●● prefer composition over inheritance ●● loose coupling, modular black boxes
  • 49. Some books GOF: 23 “classical” patterns: very nice! classic, The Book handy examples
  • 50. good start Fowler: extended e.g. with patterns for web Fowler: also known from refactoring combi: re- factoring & patterns
  • 51. Resign Patterns: Ailments of Unsuitable Project-Disoriented Software
  • 52. Joomla! Could be improved by studying design patterns and applying them. Loose coupling...
  • 53. Questions? Contact info: Herman Peeren herman@yepr.nl © Yepr The artwork in this presentation is provided under the Creative Commons Public License for noncommercial use. http://creativecommons.org/licenses/by-nc/3.0/legalcode