SlideShare une entreprise Scribd logo
1  sur  43
Design Pattern
         By Julie Iskander
MSc. Communication and Electronics
Outlines
                        Lecture 2
• What is Design Patterns?
• History of Design Patterns
• How to learn Design Patterns?
• Design Patterns Classifications acc. to GoF
• Creational DP:
  •   Singleton
  •   Factory Method
  •   Abstract Method
  •   Builder
  •   Prototype
What is Design Pattern

• A pattern is a solution to a common problem,

• NOT a code solution ready for copy-and-paste but
 a best practice, a useful abstraction, and a template
 for solving categories of problems.
What is Design Pattern

• Design Patterns are frequently used ways
  of organizing objects to make solutions
  easier to extend and modify
• Design Patterns name and describe
  effective solutions for common problems
• Design Pattern help a designer get a
  design right faster.
   • Never reinvent the wheel.
What is Design Pattern
• “Each pattern
  describes a problem
  which occurs over and
  over again, and then
  describes the core of
  the solution in such a
  way that you can use
  this solution many
  times without ever
  doing it the same way
  twice”, Christopher
History of Design Pattern
• Dr. Christopher Alexander (in civil
  engineering), in1977, A Pattern
  Language.

• In 1978–79, Prof. Trygve Reenskaug
  (in computer science), wrote “The
  design pattern: Model-View–
  Controller (MVC)”.

• In 1995, a catalog of 23 design
  patterns by Drs. Gamma, Helm,
  Johnson, and Vlissides “Gang of
  Four” (GoF), “Design Patterns:
  Elements of Reusable Object-
  Oriented Software (Addison-Wesley,
  1995)”.
How to learn Design
            patterns ?
The best way to
use patterns is to
load your brain with
them and then
recognize places in
your designs and
existing
applications where
you can apply them
“Designing OO software is hard and designing
reusable OO software even harder”,
Erich Gamma

Experience  Reusing solutions that worked before

Knowing patterns that worked in the past  make
designer more productive and creating flexible and
reusable designs
Instead of code reuse,
with design patterns you
get experience reuse
Advantages of learning Design
             Pattern
• It helps us to communicate in an efficient manner,
  creates a common vocabulary
• It enables us to discuss low-level implementation in
  a high-level, abstract manner.
• It enables us to apply a proven solution (experience
  reuse)
• It helps extendibility and avoid solution redesign
• It help present design alternatives if found.
• It can help improve maintenance and documentation
Design Pattern elements
• Pattern Name
• Problem : When to apply? Problem and
  Context
• Solution
• Consequence : results, trade offs of
  applying it
Model-View-Controller
        MVC
MVC
• What , Where
 • a requirement to vary perspectives or views (output)
   without changing the underlying information source
   (model).

• Why
 • it is more manageable and less expensive to
   encapsulate change in a set of controller objects than
   it is to disfigure the model object through constant
   reengineering.
MVC
• How
 • Encapsulating the client requirements in a
   controller object that transposes the
   information from the model object into the
   variety of formats required by the client.
  • a model object (model)
  • a view interface (IView), or abstract class, if you
    prefer;
  • Deriving any number of views (GraphView and
    BarView classes) from the interface;
  • creating a controller object (controller), to represent
    each view; and then wiring up the functionality.
Design Patterns
according to the
     GOF
DP Classifications
• According to scope

             Class                      Object

   Deals with relationships    Deals with objects
   between classes and their   relationships that can be
   subclasses                  changed at runtime,
                               dynamically
   Done by inheritance
DP Classifications
• According to purpose

    Creational           Structural          Behavioral

 Gives program the      Deals with the  Characterizes the
     flexibility in    composition of    way classes and
  deciding which    classes and objects objects interact and
  object to create.    to create larger      distribute
 When and how to          structures      responsibilities
   create objects           Or add
                        functionalities
DP Classifications
• According to purpose
    Creational    Structural              Behavioral

     Singleton       Adapter (Class    Chain of Responsibility
  Factory Method        Pattern)             Command
  (Class Pattern)        Bridge       Iterator(Class Pattern)
  Abstract Factory     Composite              Mediator
      Builder          Decorator              Memento
     Prototype          Façade                Observer
                       Flyweight                State
                         Proxy                Strategy
                                         Template Method
                                          (Class Pattern)
                                               Visitor
                                             Interpreter
Creational Patterns
Singleton
(object – creational dp)
Singleton
    (object – Creational DP)
• What, Why
 • A class has one and only one instance
   created
• How
 • private constructor
Singleton
(object – Creational DP)
Singleton
    (object – Creational DP)
• Notes:
 • Can permit a variable # of instances
Factory method
      (Class – Creational DP)
 There is more to making objects than just using
the new operator. Instantiation is an activity that
shouldn’t always be done in public and can often
           lead to coupling problems.
Factory method
      (Class – Creational DP)
• What
 • A design that defines an interface for creating
   objects and delegates the choice of what objects to
   create to subclasses.
 • A creator class is required to be decoupled from
   creating specific objects.

• Why
 • Flexibility in creating a variety of objects

• How
 • Subclasses, with overridden factory method create
   specific types, which in turn create content objects.
Factory method
(Class – Creational DP)
Factory method
    (Class – Creational DP)
• Example
  • An application with multiple documents
  • Document type to create depends on
    specific application
   • Drawing Application  Drawing Documents
   • Writing Application  Writing Documents
Factory method
(Class – Creational DP)
Factory method
      (Class – Creational DP)
• Another implementation:
 • Parametrized Factory Method
   • Parameter specifies the type of product to
     instantiate
   • No inheritance in creator class
   • All Products must implement the product
     interface
Abstract Factory DP
         (object– Creational DP)
• What
 • Client deals with a high-level abstraction for creating
   families of products while leaving the factory
   abstraction to deal with coupling the implementation.
 • A requirement not to couple the client to an
   implementation that creates sets or families of objects.
   The pattern enables the client to commit to an interface
   and avoid commitment to an implementation.
• Why
 • Enhancing the client’s ability to switch between a set or
   family of objects.
• How
 • Client code has an association with the interface of the
   factory class. The factory objects create sets of
   objects .
Abstract Factory DP
(object– Creational DP)
Abstract Factory DP
(object– Creational DP)
Abstract Factory DP
(object– Creational DP)
Abstract Factory DP
     (object– Creational DP)
• Another Example
 • Web application that renders a set of controls
   appropriate for a given web browser type or
   version.
Abstract Factory DP
      (object– Creational DP)
• Factories can be singletons
• Factory Method for each Product, each
  ConcreteFactory class overrides it
  choosing the type of products to create
 •  a new concrete factory subclass for each
   product family

• If many product families used Prototype
  DP
Builder DP
(object– Creational DP)
Builder DP
         (object– Creational DP)
• What
 • Separate Construction of complex objects from the
   representation of its parts
 • Algorithm for creating a complex object should be
   independent of the parts that make up the object
   and how they're assembled.
Builder DP
(object– Creational DP)
Builder DP
(object– Creational DP)
Builder DP
     (object– Creational DP)
• Example
 • A Schedule Builder where there are two types
   of Schedules(Inhouse or OnSite).
 • A RTF Converter where there may be text or
   Images (convert to PDF or ASCII text or……)
Report #1:
Prototype DP with
code example

N.B. Hand Written 

Contenu connexe

Tendances

Design patterns creational patterns
Design patterns creational patternsDesign patterns creational patterns
Design patterns creational patternsMalik Sajid
 
Design Pattern
Design PatternDesign Pattern
Design PatternHimanshu
 
Creational pattern
Creational patternCreational pattern
Creational patternHimanshu
 
GOF Design pattern with java
GOF Design pattern with javaGOF Design pattern with java
GOF Design pattern with javaRajiv Gupta
 
Design pattern in android
Design pattern in androidDesign pattern in android
Design pattern in androidJay Kumarr
 
Java Design Pattern Interview Questions
Java Design Pattern Interview QuestionsJava Design Pattern Interview Questions
Java Design Pattern Interview Questionsjbashask
 
Design patterns Structural
Design patterns StructuralDesign patterns Structural
Design patterns StructuralUMAR ALI
 
How I Learned To Apply Design Patterns
How I Learned To Apply Design PatternsHow I Learned To Apply Design Patterns
How I Learned To Apply Design PatternsAndy Maleh
 
Java Design Patterns Tutorial | Edureka
Java Design Patterns Tutorial | EdurekaJava Design Patterns Tutorial | Edureka
Java Design Patterns Tutorial | EdurekaEdureka!
 
Oops design pattern intro
Oops design pattern intro Oops design pattern intro
Oops design pattern intro anshu_atri
 
Software Architecture: Principles, Patterns and Practices
Software Architecture: Principles, Patterns and PracticesSoftware Architecture: Principles, Patterns and Practices
Software Architecture: Principles, Patterns and PracticesGanesh Samarthyam
 
Design Patterns For 70% Of Programmers In The World
Design Patterns For 70% Of Programmers In The WorldDesign Patterns For 70% Of Programmers In The World
Design Patterns For 70% Of Programmers In The WorldSaurabh Moody
 
Weekly Meeting: Basic Design Pattern
Weekly Meeting: Basic Design PatternWeekly Meeting: Basic Design Pattern
Weekly Meeting: Basic Design PatternNguyen Trung Kien
 
You need to extend your models? EMF Facet vs. EMF Profiles
You need to extend your models? EMF Facet vs. EMF ProfilesYou need to extend your models? EMF Facet vs. EMF Profiles
You need to extend your models? EMF Facet vs. EMF ProfilesPhilip Langer
 
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
 

Tendances (20)

Design patterns creational patterns
Design patterns creational patternsDesign patterns creational patterns
Design patterns creational patterns
 
Design Pattern
Design PatternDesign Pattern
Design Pattern
 
Creational pattern
Creational patternCreational pattern
Creational pattern
 
GOF Design pattern with java
GOF Design pattern with javaGOF Design pattern with java
GOF Design pattern with java
 
Design pattern in android
Design pattern in androidDesign pattern in android
Design pattern in android
 
Design patterns
Design patternsDesign patterns
Design patterns
 
Design patterns
Design patternsDesign patterns
Design patterns
 
Java Design Pattern Interview Questions
Java Design Pattern Interview QuestionsJava Design Pattern Interview Questions
Java Design Pattern Interview Questions
 
Design patterns Structural
Design patterns StructuralDesign patterns Structural
Design patterns Structural
 
How I Learned To Apply Design Patterns
How I Learned To Apply Design PatternsHow I Learned To Apply Design Patterns
How I Learned To Apply Design Patterns
 
Java Design Patterns Tutorial | Edureka
Java Design Patterns Tutorial | EdurekaJava Design Patterns Tutorial | Edureka
Java Design Patterns Tutorial | Edureka
 
Oops design pattern intro
Oops design pattern intro Oops design pattern intro
Oops design pattern intro
 
Software Architecture: Principles, Patterns and Practices
Software Architecture: Principles, Patterns and PracticesSoftware Architecture: Principles, Patterns and Practices
Software Architecture: Principles, Patterns and Practices
 
Design Patterns For 70% Of Programmers In The World
Design Patterns For 70% Of Programmers In The WorldDesign Patterns For 70% Of Programmers In The World
Design Patterns For 70% Of Programmers In The World
 
What is design pattern
What is design patternWhat is design pattern
What is design pattern
 
Design patterns
Design patternsDesign patterns
Design patterns
 
Weekly Meeting: Basic Design Pattern
Weekly Meeting: Basic Design PatternWeekly Meeting: Basic Design Pattern
Weekly Meeting: Basic Design Pattern
 
Design rule 3
Design rule 3Design rule 3
Design rule 3
 
You need to extend your models? EMF Facet vs. EMF Profiles
You need to extend your models? EMF Facet vs. EMF ProfilesYou need to extend your models? EMF Facet vs. EMF Profiles
You need to extend your models? EMF Facet vs. EMF Profiles
 
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
 

En vedette

Cavity preparation-according-g.v.black.09.may.2011
Cavity preparation-according-g.v.black.09.may.2011Cavity preparation-according-g.v.black.09.may.2011
Cavity preparation-according-g.v.black.09.may.2011ddert
 
De java à swift en 2 temps trois mouvements
De java à swift en 2 temps trois mouvementsDe java à swift en 2 temps trois mouvements
De java à swift en 2 temps trois mouvementsDidier Plaindoux
 
Android Bonnees pratiques
Android Bonnees pratiques Android Bonnees pratiques
Android Bonnees pratiques Patrick Bashizi
 
Design Pattern
Design PatternDesign Pattern
Design Patternnewegg
 
Design Pattern: Développement et Bonnes pratiques
Design Pattern: Développement et Bonnes pratiquesDesign Pattern: Développement et Bonnes pratiques
Design Pattern: Développement et Bonnes pratiquesAlex Wilfried OUATTARA
 
Swift, opportunités et perspectives du dernier langage d'Apple
Swift, opportunités et perspectives du dernier langage d'AppleSwift, opportunités et perspectives du dernier langage d'Apple
Swift, opportunités et perspectives du dernier langage d'AppleDamien GOSSET
 
Design patterns - Exemples en Java
Design patterns - Exemples en JavaDesign patterns - Exemples en Java
Design patterns - Exemples en JavaOussama BEN KHIROUN
 
Design Patterns Presentation - Chetan Gole
Design Patterns Presentation -  Chetan GoleDesign Patterns Presentation -  Chetan Gole
Design Patterns Presentation - Chetan GoleChetan Gole
 
Visitor Pattern
Visitor PatternVisitor Pattern
Visitor PatternIder Zheng
 
01 programmation mobile - android - (introduction)
01 programmation mobile - android - (introduction)01 programmation mobile - android - (introduction)
01 programmation mobile - android - (introduction)TECOS
 
Design Pattern introduction
Design Pattern introductionDesign Pattern introduction
Design Pattern introductionneuros
 
Chp6 - Développement iOS
Chp6 - Développement iOSChp6 - Développement iOS
Chp6 - Développement iOSLilia Sfaxi
 
Chp2 - Conception UX-UI des Applications Mobiles
Chp2 - Conception UX-UI des Applications MobilesChp2 - Conception UX-UI des Applications Mobiles
Chp2 - Conception UX-UI des Applications MobilesLilia Sfaxi
 

En vedette (20)

Design pattern
Design patternDesign pattern
Design pattern
 
Cavity preparation-according-g.v.black.09.may.2011
Cavity preparation-according-g.v.black.09.may.2011Cavity preparation-according-g.v.black.09.may.2011
Cavity preparation-according-g.v.black.09.may.2011
 
Design pattern
Design patternDesign pattern
Design pattern
 
Sibtel&Swift
Sibtel&SwiftSibtel&Swift
Sibtel&Swift
 
De java à swift en 2 temps trois mouvements
De java à swift en 2 temps trois mouvementsDe java à swift en 2 temps trois mouvements
De java à swift en 2 temps trois mouvements
 
Android Bonnees pratiques
Android Bonnees pratiques Android Bonnees pratiques
Android Bonnees pratiques
 
Design Pattern
Design PatternDesign Pattern
Design Pattern
 
Cours1
Cours1Cours1
Cours1
 
Design pattern
Design patternDesign pattern
Design pattern
 
Design Pattern: Développement et Bonnes pratiques
Design Pattern: Développement et Bonnes pratiquesDesign Pattern: Développement et Bonnes pratiques
Design Pattern: Développement et Bonnes pratiques
 
Swift, opportunités et perspectives du dernier langage d'Apple
Swift, opportunités et perspectives du dernier langage d'AppleSwift, opportunités et perspectives du dernier langage d'Apple
Swift, opportunités et perspectives du dernier langage d'Apple
 
Design patterns - Exemples en Java
Design patterns - Exemples en JavaDesign patterns - Exemples en Java
Design patterns - Exemples en Java
 
Design Patterns Presentation - Chetan Gole
Design Patterns Presentation -  Chetan GoleDesign Patterns Presentation -  Chetan Gole
Design Patterns Presentation - Chetan Gole
 
Visitor Pattern
Visitor PatternVisitor Pattern
Visitor Pattern
 
Design Patterns
Design PatternsDesign Patterns
Design Patterns
 
Gof design patterns
Gof design patternsGof design patterns
Gof design patterns
 
01 programmation mobile - android - (introduction)
01 programmation mobile - android - (introduction)01 programmation mobile - android - (introduction)
01 programmation mobile - android - (introduction)
 
Design Pattern introduction
Design Pattern introductionDesign Pattern introduction
Design Pattern introduction
 
Chp6 - Développement iOS
Chp6 - Développement iOSChp6 - Développement iOS
Chp6 - Développement iOS
 
Chp2 - Conception UX-UI des Applications Mobiles
Chp2 - Conception UX-UI des Applications MobilesChp2 - Conception UX-UI des Applications Mobiles
Chp2 - Conception UX-UI des Applications Mobiles
 

Similaire à Design Pattern lecture 2

Creational Design Patterns.pptx
Creational Design Patterns.pptxCreational Design Patterns.pptx
Creational Design Patterns.pptxSachin Patidar
 
UNIT IV DESIGN PATTERNS.pptx
UNIT IV DESIGN PATTERNS.pptxUNIT IV DESIGN PATTERNS.pptx
UNIT IV DESIGN PATTERNS.pptxanguraju1
 
Cs 1023 lec 8 design pattern (week 2)
Cs 1023 lec 8 design pattern (week 2)Cs 1023 lec 8 design pattern (week 2)
Cs 1023 lec 8 design pattern (week 2)stanbridge
 
Design patterns
Design patternsDesign patterns
Design patternsAlok Guha
 
Nodejs Chapter 3 - Design Pattern
Nodejs Chapter 3 - Design PatternNodejs Chapter 3 - Design Pattern
Nodejs Chapter 3 - Design PatternTalentica Software
 
P Training Presentation
P Training PresentationP Training Presentation
P Training PresentationGaurav Tyagi
 
Chapter 4_Introduction to Patterns.ppt
Chapter 4_Introduction to Patterns.pptChapter 4_Introduction to Patterns.ppt
Chapter 4_Introduction to Patterns.pptRushikeshChikane1
 
Chapter 4_Introduction to Patterns.ppt
Chapter 4_Introduction to Patterns.pptChapter 4_Introduction to Patterns.ppt
Chapter 4_Introduction to Patterns.pptRushikeshChikane2
 
Solid Principles Of Design (Design Series 01)
Solid Principles Of Design (Design Series 01)Solid Principles Of Design (Design Series 01)
Solid Principles Of Design (Design Series 01)Heartin Jacob
 
MWLUG 2015 - An Introduction to MVC
MWLUG 2015 - An Introduction to MVCMWLUG 2015 - An Introduction to MVC
MWLUG 2015 - An Introduction to MVCUlrich Krause
 
An Introduction To Model  View  Controller In XPages
An Introduction To Model  View  Controller In XPagesAn Introduction To Model  View  Controller In XPages
An Introduction To Model  View  Controller In XPagesUlrich Krause
 
How to design an application correctly ?
How to design an application correctly ?How to design an application correctly ?
How to design an application correctly ?Guillaume AGIS
 
Design pattern and their application
Design pattern and their applicationDesign pattern and their application
Design pattern and their applicationHiệp Tiến
 
Design Patterns from 10K feet
Design Patterns from 10K feetDesign Patterns from 10K feet
Design Patterns from 10K feetNaresha K
 
Design Patterns Part1
Design Patterns  Part1Design Patterns  Part1
Design Patterns Part1Tom Chen
 

Similaire à Design Pattern lecture 2 (20)

Creational Design Patterns.pptx
Creational Design Patterns.pptxCreational Design Patterns.pptx
Creational Design Patterns.pptx
 
UNIT IV DESIGN PATTERNS.pptx
UNIT IV DESIGN PATTERNS.pptxUNIT IV DESIGN PATTERNS.pptx
UNIT IV DESIGN PATTERNS.pptx
 
Decorator Pattern
Decorator PatternDecorator Pattern
Decorator Pattern
 
Cs 1023 lec 8 design pattern (week 2)
Cs 1023 lec 8 design pattern (week 2)Cs 1023 lec 8 design pattern (week 2)
Cs 1023 lec 8 design pattern (week 2)
 
Design patterns
Design patternsDesign patterns
Design patterns
 
Nodejs Chapter 3 - Design Pattern
Nodejs Chapter 3 - Design PatternNodejs Chapter 3 - Design Pattern
Nodejs Chapter 3 - Design Pattern
 
Introduction to Design Patterns
Introduction to Design PatternsIntroduction to Design Patterns
Introduction to Design Patterns
 
P Training Presentation
P Training PresentationP Training Presentation
P Training Presentation
 
Chapter 4_Introduction to Patterns.ppt
Chapter 4_Introduction to Patterns.pptChapter 4_Introduction to Patterns.ppt
Chapter 4_Introduction to Patterns.ppt
 
Chapter 4_Introduction to Patterns.ppt
Chapter 4_Introduction to Patterns.pptChapter 4_Introduction to Patterns.ppt
Chapter 4_Introduction to Patterns.ppt
 
Solid Principles Of Design (Design Series 01)
Solid Principles Of Design (Design Series 01)Solid Principles Of Design (Design Series 01)
Solid Principles Of Design (Design Series 01)
 
MWLUG 2015 - An Introduction to MVC
MWLUG 2015 - An Introduction to MVCMWLUG 2015 - An Introduction to MVC
MWLUG 2015 - An Introduction to MVC
 
An Introduction To Model  View  Controller In XPages
An Introduction To Model  View  Controller In XPagesAn Introduction To Model  View  Controller In XPages
An Introduction To Model  View  Controller In XPages
 
How to design an application correctly ?
How to design an application correctly ?How to design an application correctly ?
How to design an application correctly ?
 
CBD.pptx
CBD.pptxCBD.pptx
CBD.pptx
 
Design pattern and their application
Design pattern and their applicationDesign pattern and their application
Design pattern and their application
 
Design patterns
Design patternsDesign patterns
Design patterns
 
Decorator design pattern
Decorator design patternDecorator design pattern
Decorator design pattern
 
Design Patterns from 10K feet
Design Patterns from 10K feetDesign Patterns from 10K feet
Design Patterns from 10K feet
 
Design Patterns Part1
Design Patterns  Part1Design Patterns  Part1
Design Patterns Part1
 

Plus de Julie Iskander (20)

HTML 5
HTML 5HTML 5
HTML 5
 
Data structures and algorithms
Data structures and algorithmsData structures and algorithms
Data structures and algorithms
 
C for Engineers
C for EngineersC for Engineers
C for Engineers
 
Design Pattern lecture 3
Design Pattern lecture 3Design Pattern lecture 3
Design Pattern lecture 3
 
Scriptaculous
ScriptaculousScriptaculous
Scriptaculous
 
Prototype Framework
Prototype FrameworkPrototype Framework
Prototype Framework
 
Design Pattern lecture 4
Design Pattern lecture 4Design Pattern lecture 4
Design Pattern lecture 4
 
Design Pattern lecture 1
Design Pattern lecture 1Design Pattern lecture 1
Design Pattern lecture 1
 
Ajax and ASP.NET AJAX
Ajax and ASP.NET AJAXAjax and ASP.NET AJAX
Ajax and ASP.NET AJAX
 
jQuery
jQueryjQuery
jQuery
 
ASP.NET Lecture 5
ASP.NET Lecture 5ASP.NET Lecture 5
ASP.NET Lecture 5
 
ASP.NET lecture 8
ASP.NET lecture 8ASP.NET lecture 8
ASP.NET lecture 8
 
ASP.NET Lecture 7
ASP.NET Lecture 7ASP.NET Lecture 7
ASP.NET Lecture 7
 
ASP.NET Lecture 6
ASP.NET Lecture 6ASP.NET Lecture 6
ASP.NET Lecture 6
 
ASP.NET Lecture 4
ASP.NET Lecture 4ASP.NET Lecture 4
ASP.NET Lecture 4
 
ASP.NET Lecture 3
ASP.NET Lecture 3ASP.NET Lecture 3
ASP.NET Lecture 3
 
ASP.NET Lecture 2
ASP.NET Lecture 2ASP.NET Lecture 2
ASP.NET Lecture 2
 
ASP.NET Lecture 1
ASP.NET Lecture 1ASP.NET Lecture 1
ASP.NET Lecture 1
 
AJAX and JSON
AJAX and JSONAJAX and JSON
AJAX and JSON
 
Object Oriented JavaScript
Object Oriented JavaScriptObject Oriented JavaScript
Object Oriented JavaScript
 

Dernier

Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 

Dernier (20)

Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 

Design Pattern lecture 2

  • 1. Design Pattern By Julie Iskander MSc. Communication and Electronics
  • 2. Outlines Lecture 2 • What is Design Patterns? • History of Design Patterns • How to learn Design Patterns? • Design Patterns Classifications acc. to GoF • Creational DP: • Singleton • Factory Method • Abstract Method • Builder • Prototype
  • 3. What is Design Pattern • A pattern is a solution to a common problem, • NOT a code solution ready for copy-and-paste but a best practice, a useful abstraction, and a template for solving categories of problems.
  • 4. What is Design Pattern • Design Patterns are frequently used ways of organizing objects to make solutions easier to extend and modify • Design Patterns name and describe effective solutions for common problems • Design Pattern help a designer get a design right faster. • Never reinvent the wheel.
  • 5. What is Design Pattern • “Each pattern describes a problem which occurs over and over again, and then describes the core of the solution in such a way that you can use this solution many times without ever doing it the same way twice”, Christopher
  • 6. History of Design Pattern • Dr. Christopher Alexander (in civil engineering), in1977, A Pattern Language. • In 1978–79, Prof. Trygve Reenskaug (in computer science), wrote “The design pattern: Model-View– Controller (MVC)”. • In 1995, a catalog of 23 design patterns by Drs. Gamma, Helm, Johnson, and Vlissides “Gang of Four” (GoF), “Design Patterns: Elements of Reusable Object- Oriented Software (Addison-Wesley, 1995)”.
  • 7. How to learn Design patterns ? The best way to use patterns is to load your brain with them and then recognize places in your designs and existing applications where you can apply them
  • 8. “Designing OO software is hard and designing reusable OO software even harder”, Erich Gamma Experience  Reusing solutions that worked before Knowing patterns that worked in the past  make designer more productive and creating flexible and reusable designs
  • 9. Instead of code reuse, with design patterns you get experience reuse
  • 10. Advantages of learning Design Pattern • It helps us to communicate in an efficient manner, creates a common vocabulary • It enables us to discuss low-level implementation in a high-level, abstract manner. • It enables us to apply a proven solution (experience reuse) • It helps extendibility and avoid solution redesign • It help present design alternatives if found. • It can help improve maintenance and documentation
  • 11. Design Pattern elements • Pattern Name • Problem : When to apply? Problem and Context • Solution • Consequence : results, trade offs of applying it
  • 13.
  • 14. MVC • What , Where • a requirement to vary perspectives or views (output) without changing the underlying information source (model). • Why • it is more manageable and less expensive to encapsulate change in a set of controller objects than it is to disfigure the model object through constant reengineering.
  • 15. MVC • How • Encapsulating the client requirements in a controller object that transposes the information from the model object into the variety of formats required by the client. • a model object (model) • a view interface (IView), or abstract class, if you prefer; • Deriving any number of views (GraphView and BarView classes) from the interface; • creating a controller object (controller), to represent each view; and then wiring up the functionality.
  • 17. DP Classifications • According to scope Class Object Deals with relationships Deals with objects between classes and their relationships that can be subclasses changed at runtime, dynamically Done by inheritance
  • 18. DP Classifications • According to purpose Creational Structural Behavioral Gives program the Deals with the Characterizes the flexibility in composition of way classes and deciding which classes and objects objects interact and object to create. to create larger distribute When and how to structures responsibilities create objects Or add functionalities
  • 19. DP Classifications • According to purpose Creational Structural Behavioral Singleton Adapter (Class Chain of Responsibility Factory Method Pattern) Command (Class Pattern) Bridge Iterator(Class Pattern) Abstract Factory Composite Mediator Builder Decorator Memento Prototype Façade Observer Flyweight State Proxy Strategy Template Method (Class Pattern) Visitor Interpreter
  • 22. Singleton (object – Creational DP) • What, Why • A class has one and only one instance created • How • private constructor
  • 24. Singleton (object – Creational DP) • Notes: • Can permit a variable # of instances
  • 25. Factory method (Class – Creational DP) There is more to making objects than just using the new operator. Instantiation is an activity that shouldn’t always be done in public and can often lead to coupling problems.
  • 26. Factory method (Class – Creational DP) • What • A design that defines an interface for creating objects and delegates the choice of what objects to create to subclasses. • A creator class is required to be decoupled from creating specific objects. • Why • Flexibility in creating a variety of objects • How • Subclasses, with overridden factory method create specific types, which in turn create content objects.
  • 27. Factory method (Class – Creational DP)
  • 28. Factory method (Class – Creational DP) • Example • An application with multiple documents • Document type to create depends on specific application • Drawing Application  Drawing Documents • Writing Application  Writing Documents
  • 29. Factory method (Class – Creational DP)
  • 30. Factory method (Class – Creational DP) • Another implementation: • Parametrized Factory Method • Parameter specifies the type of product to instantiate • No inheritance in creator class • All Products must implement the product interface
  • 31. Abstract Factory DP (object– Creational DP) • What • Client deals with a high-level abstraction for creating families of products while leaving the factory abstraction to deal with coupling the implementation. • A requirement not to couple the client to an implementation that creates sets or families of objects. The pattern enables the client to commit to an interface and avoid commitment to an implementation. • Why • Enhancing the client’s ability to switch between a set or family of objects. • How • Client code has an association with the interface of the factory class. The factory objects create sets of objects .
  • 35. Abstract Factory DP (object– Creational DP) • Another Example • Web application that renders a set of controls appropriate for a given web browser type or version.
  • 36. Abstract Factory DP (object– Creational DP) • Factories can be singletons • Factory Method for each Product, each ConcreteFactory class overrides it choosing the type of products to create •  a new concrete factory subclass for each product family • If many product families used Prototype DP
  • 38. Builder DP (object– Creational DP) • What • Separate Construction of complex objects from the representation of its parts • Algorithm for creating a complex object should be independent of the parts that make up the object and how they're assembled.
  • 40.
  • 42. Builder DP (object– Creational DP) • Example • A Schedule Builder where there are two types of Schedules(Inhouse or OnSite). • A RTF Converter where there may be text or Images (convert to PDF or ASCII text or……)
  • 43. Report #1: Prototype DP with code example N.B. Hand Written 

Notes de l'éditeur

  1. for example, in a road management pattern language, the problem of cars colliding at an uncontrolled intersection is identified as problem type: uncontrolled intersection.Then a generic solution is found, the result is the creation of the intersection controller design patternfor example, in the previous scenario, we applied the intersection controller design pattern to solve an uncontrolled intersection problem, in which cars collided. However, if we had another uncontrolled intersection problem that involved cars and trains, then we would implement the intersection controller design pattern differently: in the car scenario, we might implement four sets of traffic lights, whereas in the car–train scenario we might implement four sets of traffic lights and a set of crossing gates.
  2. for example, in a road management pattern language, the problem of cars colliding at an uncontrolled intersection is identified as problem type: uncontrolled intersection.Then a generic solution is found, the result is the creation of the intersection controller design patternfor example, in the previous scenario, we applied the intersection controller design pattern to solve an uncontrolled intersection problem, in which cars collided. However, if we had another uncontrolled intersection problem that involved cars and trains, then we would implement the intersection controller design pattern differently: in the car scenario, we might implement four sets of traffic lights, whereas in the car–train scenario we might implement four sets of traffic lights and a set of crossing gates.
  3. for example, in a road management pattern language, the problem of cars colliding at an uncontrolled intersection is identified as problem type: uncontrolled intersection.Then a generic solution is found, the result is the creation of the intersection controller design patternfor example, in the previous scenario, we applied the intersection controller design pattern to solve an uncontrolled intersection problem, in which cars collided. However, if we had another uncontrolled intersection problem that involved cars and trains, then we would implement the intersection controller design pattern differently: in the car scenario, we might implement four sets of traffic lights, whereas in the car–train scenario we might implement four sets of traffic lights and a set of crossing gates.
  4. It discuss a set of 23 design patterns that they observed were commonly found in software development.
  5. It discuss a set of 23 design patterns that they observed were commonly found in software development.