SlideShare une entreprise Scribd logo
1  sur  28
Télécharger pour lire hors ligne
Design Patterns
                         Introduction and Overview




                                                     By,
                                                      Abhishek Sagi
Monday 5 December 11
Today
                       Introduction to Design Patterns :
                         What are they?

                         Types of Patterns

                         Examples : Commonly used patterns

                         References




Monday 5 December 11
Design Patterns
                             What are they?




Monday 5 December 11
Design Patterns
            Idea originated from Christopher Wolfgang
            Alexander (Austria).

            Architect

            It was initially applied for architecture for
            buildings and towns, But not computer
            programming for writing software.




Monday 5 December 11
"Each pattern describes a problem which occurs
   over and over again in our environment, and
   then describes the core of the solution to that
   problem, in such a way that you can use this
   solution a million times over, without ever
   doing it the same way twice”
                         -Christopher Alexander (Architect)
                         “A Pattern Language”,New York,
                          Oxford University Press, 1977.



Monday 5 December 11
Design Patterns
                   Even through he was talking about patterns in
                   buildings and towns, What he says is true about
                   object-oriented design patterns.

                   Solutions are expressed in terms of objects and
                   interfaces instead of walls and doors.

                   At core both patterns is a solution to a problem
                   in a context.

                   Simply, design patterns help a designer to get a
                   right design faster.

Monday 5 December 11
Describes a design pattern as a three-part rule

                       1.) Description of a context

                       2.) A problem

                       3.) A solution

                This is modified for software design patterns which
                consists of four parts




Monday 5 December 11
Four Essential Parts
               Pattern name

                       A handle to briefly describe the design
                       problem,but more importantly to provide a common
                       vocabulary for software designers to use.

               Problem

                       A description of the problem that the design
                       pattern is intended to solve.



Monday 5 December 11
Solution

                       Describes what elements are required to make up
                       the design, their relationships and its context.

             Consequences

                       What are the results and trade offs by applying
                       the design pattern.

                       Allows comparison between different design
                       patterns, to see if there is a better fit for the
                       actual problem.


Monday 5 December 11
Design Patterns :
              Programming Languages
                       Aimed towards languages that have language
                       level support for Object Oriented
                       Programming
                         Not exclusively , But it would be easier to apply
                         with OOP!

                       Different OOP languages have different
                       mechanisms for applying patterns.



Monday 5 December 11
Types Of Patterns
                       General description of the type of problem the
                       pattern addresses

                         Creational:

                            Concerned with everything about the
                            creation of objects

                         Structural:

                            Concerned with how classes and objects
                            are composed to form larger structures

Monday 5 December 11
Types Of Patterns
              (Continued)
                       Behavioral

                         Concerned with algorithms and the
                         assignment of responsibilities between
                         objects.




Monday 5 December 11
Types Of Patterns (Overview)
               Creational:       Creational patterns are ones that create objects for you,
               rather than having you instantiate objects directly. This gives your program
               more flexibility in deciding which objects need to be created for a given
               case.

                       Abstract Factory*: Groups object factories that have a common theme.

                       Builder constructs: Complex objects by separating construction and
                       representation.

                       Factory Method*: Creates objects without specifying the exact class to
                       create.

                       Prototype: Creates objects by cloning an existing object.

                       Singleton*: Restricts object creation for a class to only one instance.

Monday 5 December 11
Types Of Patterns (Contd)
               Structural Patterns:          These concern class and object composition.
               They use inheritance to compose interfaces and define ways to compose
               objects to obtain new functionality.

                       Adapter: Allows classes with incompatible interfaces to work together
                       by wrapping its own interface around that of an already existing class.

                       Bridge*: Decouples an abstraction from its implementation so that the
                       two can vary independently.

                       Composite: Composes zero-or-more similar objects so that they can be
                       manipulated as one object.

                       Decorator: Dynamically adds/overrides behavior in an existing method of
                       an object.


Monday 5 December 11
Types Of Patterns (Contd)
                   Facade: Provides a simplified interface to a large body of code.

                   Flyweight: Reduces the cost of creating and manipulating a large number
                   of similar objects.

                   Proxy: Provides a placeholder for another object to control access,
                   reduce cost, and reduce complexity.


             Behavioral Patterns:        Most of these design patterns are specifically
             concerned with communication between objects.

                   Chain of responsibility: Delegates commands to a chain of processing
                   objects.

                   Command: Creates objects which encapsulate actions and parameters.

                   Interpreter: Implements a specialized language.

Monday 5 December 11
Types Of Patterns (Contd)
                       Iterator*: Accesses the elements of an object sequentially without
                       exposing its underlying representation.

                       Mediator: Allows loose coupling between classes by being the only class
                       that has detailed knowledge of their methods.

                       Memento: Provides the ability to restore an object to its previous state
                       (undo).

                       Observer: Is a publish/subscribe pattern which allows a number of
                       observer objects to see an event.

                       State*: Allows an object to alter its behavior when its internal state
                       changes.

                       Strategy: Allows one of a family of algorithms to be selected on-the-fly
                       at runtime.
Monday 5 December 11
Design Pattern
                         Example 1: The Singleton




Monday 5 December 11
Singleton
                   Creational category of design patterns

                   Intent: Ensure that a class has only once
                   instance, And provide global point of access to it.

                   Motivation: Important for some classes to have
                   no more than one instance.

                   Examples:

                       Console in a game; Logging utility; An
                       Application Class; A Window Manager.

Monday 5 December 11
Singleton
                         Code Example




Monday 5 December 11
Design Pattern
                         Example 2: State Pattern




Monday 5 December 11
State Pattern
                 Behavioral category of design patterns
                       Provides behavior to an object so that it can be changed
                       during runtime.

                 Very similar to bridge pattern but intention is
                 different

                       Bridge is structural :

                          Hide data from client

                          client only aware of the handle

                       State is behavioral :

                          Provides flexible behavior of owning object and client would be
                          aware of both owning object and state objects.
Monday 5 December 11
State Pattern: Approaches
               Application decide
                       Requires state transition

                       Implies constraints, And less flexible

                       states are unaware of each other

               States decide
                       Most flexible approach

                       States are aware of each other

                       Implementation dependencies between state code

Monday 5 December 11
State creation/destruction:
            2 Approaches:
               As Needed
                       States are created on the fly

                       Destroyed when no longer need - can be expensive

                       Conserves memory

                       Preferable where state changes are infrequent

               States created in advance (Compile time)
                       Destroyed only when application terminates - CHEAP!

                       Memory usage - COSTLY! (all data stored in states are created upfront)

                       Preferable where state changes are frequent
Monday 5 December 11
State Pattern
                             Code Example




Monday 5 December 11
Recommended Books
      Design Patterns: Elements of Reusable Object-Oriented Software
      Authors: “Gang of four”
      Hardback: 416 pages
      Publisher: Addison Wesley (14 Mar 1995)
                                                           C++
      ISBN-10: 0201633612
      ISBN-13: 978-0201633610




       Head First: Design Patterns
       Authors: Several
       Paperback: 688 pages
       Publisher: O'Reilly Media (25 Oct 2004)            Java
       ISBN-10: 0596007124
       ISBN-13: 978-0596007126



Monday 5 December 11
Questions?

                       Contact: Sharat Chandra (or) Tushar Goswami



                       Email: abhishek.sagi@ymail.com




Monday 5 December 11
References
                Design Patterns: Introduction To Design Patterns;
                Steven Mead , Senior Programming Lecturer ,
                University Of Teesside ; 2010 .

                Design Patterns: Elements of Reusable Object-
                Oriented Software; Erich Gamma et al; Addison-
                Wesley; 1995; 978-0201633610.

                http://en.wikipedia.org/wiki/Design_Patterns

                Big C++ (2nd edition); Cay Horstmann; Timothy
                Budd; John Wiley & Sons; January 2009; 978-
                0470383285.
Monday 5 December 11
Thank you J




Monday 5 December 11

Contenu connexe

Tendances

Design Patterns Presentation - Chetan Gole
Design Patterns Presentation -  Chetan GoleDesign Patterns Presentation -  Chetan Gole
Design Patterns Presentation - Chetan GoleChetan Gole
 
Gof design pattern
Gof design patternGof design pattern
Gof design patternnaveen kumar
 
Design Patterns
Design PatternsDesign Patterns
Design Patternssoms_1
 
Software design patterns ppt
Software design patterns pptSoftware design patterns ppt
Software design patterns pptmkruthika
 
Design Patterns - General Introduction
Design Patterns - General IntroductionDesign Patterns - General Introduction
Design Patterns - General IntroductionAsma CHERIF
 
Design Pattern - Singleton Pattern
Design Pattern - Singleton PatternDesign Pattern - Singleton Pattern
Design Pattern - Singleton PatternMudasir Qazi
 
Design Pattern in Software Engineering
Design Pattern in Software EngineeringDesign Pattern in Software Engineering
Design Pattern in Software EngineeringManish Kumar
 
Architectural structures and views
Architectural structures and viewsArchitectural structures and views
Architectural structures and viewsDr Reeja S R
 
Unit 1( modelling concepts & class modeling)
Unit  1( modelling concepts & class modeling)Unit  1( modelling concepts & class modeling)
Unit 1( modelling concepts & class modeling)Manoj Reddy
 
Repository and Unit Of Work Design Patterns
Repository and Unit Of Work Design PatternsRepository and Unit Of Work Design Patterns
Repository and Unit Of Work Design PatternsHatim Hakeel
 
Object Oriented Analysis and Design
Object Oriented Analysis and DesignObject Oriented Analysis and Design
Object Oriented Analysis and DesignHaitham El-Ghareeb
 
Software Engineering - chp4- design patterns
Software Engineering - chp4- design patternsSoftware Engineering - chp4- design patterns
Software Engineering - chp4- design patternsLilia Sfaxi
 
Object oriented modeling and design
Object oriented modeling and designObject oriented modeling and design
Object oriented modeling and designjayashri kolekar
 

Tendances (20)

Design pattern
Design patternDesign pattern
Design pattern
 
Design Patterns
Design PatternsDesign Patterns
Design Patterns
 
Design Patterns Presentation - Chetan Gole
Design Patterns Presentation -  Chetan GoleDesign Patterns Presentation -  Chetan Gole
Design Patterns Presentation - Chetan Gole
 
Design patterns tutorials
Design patterns tutorialsDesign patterns tutorials
Design patterns tutorials
 
Gof design pattern
Gof design patternGof design pattern
Gof design pattern
 
Design Pattern
Design PatternDesign Pattern
Design Pattern
 
Design Patterns
Design PatternsDesign Patterns
Design Patterns
 
Software design patterns ppt
Software design patterns pptSoftware design patterns ppt
Software design patterns ppt
 
Design Patterns - General Introduction
Design Patterns - General IntroductionDesign Patterns - General Introduction
Design Patterns - General Introduction
 
Design Pattern - Singleton Pattern
Design Pattern - Singleton PatternDesign Pattern - Singleton Pattern
Design Pattern - Singleton Pattern
 
Design Pattern in Software Engineering
Design Pattern in Software EngineeringDesign Pattern in Software Engineering
Design Pattern in Software Engineering
 
Architectural structures and views
Architectural structures and viewsArchitectural structures and views
Architectural structures and views
 
Unit 1( modelling concepts & class modeling)
Unit  1( modelling concepts & class modeling)Unit  1( modelling concepts & class modeling)
Unit 1( modelling concepts & class modeling)
 
Repository and Unit Of Work Design Patterns
Repository and Unit Of Work Design PatternsRepository and Unit Of Work Design Patterns
Repository and Unit Of Work Design Patterns
 
Object Oriented Analysis and Design
Object Oriented Analysis and DesignObject Oriented Analysis and Design
Object Oriented Analysis and Design
 
Software Engineering - chp4- design patterns
Software Engineering - chp4- design patternsSoftware Engineering - chp4- design patterns
Software Engineering - chp4- design patterns
 
Object oriented modeling and design
Object oriented modeling and designObject oriented modeling and design
Object oriented modeling and design
 
Design Patterns.ppt
Design Patterns.pptDesign Patterns.ppt
Design Patterns.ppt
 
OOAD
OOADOOAD
OOAD
 
Facade Pattern
Facade PatternFacade Pattern
Facade Pattern
 

En vedette

Linux process management
Linux process managementLinux process management
Linux process managementRaghu nath
 
Design pattern in android
Design pattern in androidDesign pattern in android
Design pattern in androidJay Kumarr
 
Object Oriented Design in Software Engineering SE12
Object Oriented Design in Software Engineering SE12Object Oriented Design in Software Engineering SE12
Object Oriented Design in Software Engineering SE12koolkampus
 
Loving & Hating Christopher Alexander
Loving & Hating Christopher AlexanderLoving & Hating Christopher Alexander
Loving & Hating Christopher AlexanderMolly Steenson
 
Christopher Alexander: Elements Of Style
Christopher Alexander: Elements Of StyleChristopher Alexander: Elements Of Style
Christopher Alexander: Elements Of StyleMatthias Mueller-Prove
 
Traditional Serial Vision Excerpt
Traditional Serial Vision ExcerptTraditional Serial Vision Excerpt
Traditional Serial Vision Excerptsstannard
 
Townscape - Gordon Cullen V2
Townscape - Gordon Cullen V2Townscape - Gordon Cullen V2
Townscape - Gordon Cullen V2Proyectar Ciudad
 
Analytical approach on design theories of christopher alexander
Analytical approach on design theories of christopher alexanderAnalytical approach on design theories of christopher alexander
Analytical approach on design theories of christopher alexanderShabnam Golkarian
 

En vedette (11)

Linux process management
Linux process managementLinux process management
Linux process management
 
Design pattern in android
Design pattern in androidDesign pattern in android
Design pattern in android
 
Object Oriented Design in Software Engineering SE12
Object Oriented Design in Software Engineering SE12Object Oriented Design in Software Engineering SE12
Object Oriented Design in Software Engineering SE12
 
Loving & Hating Christopher Alexander
Loving & Hating Christopher AlexanderLoving & Hating Christopher Alexander
Loving & Hating Christopher Alexander
 
Christopher Alexander: Elements Of Style
Christopher Alexander: Elements Of StyleChristopher Alexander: Elements Of Style
Christopher Alexander: Elements Of Style
 
Traditional Serial Vision Excerpt
Traditional Serial Vision ExcerptTraditional Serial Vision Excerpt
Traditional Serial Vision Excerpt
 
Townscape - Gordon Cullen V2
Townscape - Gordon Cullen V2Townscape - Gordon Cullen V2
Townscape - Gordon Cullen V2
 
Townscape - Gordon Cullen
Townscape - Gordon CullenTownscape - Gordon Cullen
Townscape - Gordon Cullen
 
Christopher alexander
Christopher alexanderChristopher alexander
Christopher alexander
 
Analytical approach on design theories of christopher alexander
Analytical approach on design theories of christopher alexanderAnalytical approach on design theories of christopher alexander
Analytical approach on design theories of christopher alexander
 
serial vision
serial visionserial vision
serial vision
 

Similaire à Design patterns

Up to speed in domain driven design
Up to speed in domain driven designUp to speed in domain driven design
Up to speed in domain driven designRick van der Arend
 
Module 2 design patterns-2
Module 2   design patterns-2Module 2   design patterns-2
Module 2 design patterns-2Ankit Dubey
 
dotnet stuff.com tutorials-design-patterns_exploring-net-design-patterns-in-s...
dotnet stuff.com tutorials-design-patterns_exploring-net-design-patterns-in-s...dotnet stuff.com tutorials-design-patterns_exploring-net-design-patterns-in-s...
dotnet stuff.com tutorials-design-patterns_exploring-net-design-patterns-in-s...Anil Sharma
 
Gang of Four in Java
Gang of Four in Java Gang of Four in Java
Gang of Four in Java Mina Tafreshi
 
PATTERNS01 - An Introduction to Design Patterns
PATTERNS01 - An Introduction to Design PatternsPATTERNS01 - An Introduction to Design Patterns
PATTERNS01 - An Introduction to Design PatternsMichael Heron
 
Design Pattern - Introduction
Design Pattern - IntroductionDesign Pattern - Introduction
Design Pattern - IntroductionMudasir Qazi
 
Design Patterns Course
Design Patterns CourseDesign Patterns Course
Design Patterns CourseAhmed Soliman
 
Dino Esposito. Polyglot Persistence: From Architecture to Solutions
Dino Esposito. Polyglot Persistence: From Architecture to SolutionsDino Esposito. Polyglot Persistence: From Architecture to Solutions
Dino Esposito. Polyglot Persistence: From Architecture to SolutionsCodeFest
 
11 ooad uml-14
11 ooad uml-1411 ooad uml-14
11 ooad uml-14Niit Care
 
Design in construction
Design in constructionDesign in construction
Design in constructionAsha Sari
 
Design in construction
Design in constructionDesign in construction
Design in constructionAsha Sari
 
The Object Model
The Object Model  The Object Model
The Object Model yndaravind
 

Similaire à Design patterns (20)

7494607
74946077494607
7494607
 
Up to speed in domain driven design
Up to speed in domain driven designUp to speed in domain driven design
Up to speed in domain driven design
 
Module 2 design patterns-2
Module 2   design patterns-2Module 2   design patterns-2
Module 2 design patterns-2
 
dotnet stuff.com tutorials-design-patterns_exploring-net-design-patterns-in-s...
dotnet stuff.com tutorials-design-patterns_exploring-net-design-patterns-in-s...dotnet stuff.com tutorials-design-patterns_exploring-net-design-patterns-in-s...
dotnet stuff.com tutorials-design-patterns_exploring-net-design-patterns-in-s...
 
Gang of Four in Java
Gang of Four in Java Gang of Four in Java
Gang of Four in Java
 
OOP design patterns
OOP design patternsOOP design patterns
OOP design patterns
 
Oops design pattern_amitgupta
Oops design pattern_amitguptaOops design pattern_amitgupta
Oops design pattern_amitgupta
 
PATTERNS01 - An Introduction to Design Patterns
PATTERNS01 - An Introduction to Design PatternsPATTERNS01 - An Introduction to Design Patterns
PATTERNS01 - An Introduction to Design Patterns
 
Design Patterns
Design PatternsDesign Patterns
Design Patterns
 
Design Pattern - Introduction
Design Pattern - IntroductionDesign Pattern - Introduction
Design Pattern - Introduction
 
Unit iii design patterns 9
Unit iii design patterns 9Unit iii design patterns 9
Unit iii design patterns 9
 
What is design pattern
What is design patternWhat is design pattern
What is design pattern
 
Design Patterns Course
Design Patterns CourseDesign Patterns Course
Design Patterns Course
 
Dino Esposito. Polyglot Persistence: From Architecture to Solutions
Dino Esposito. Polyglot Persistence: From Architecture to SolutionsDino Esposito. Polyglot Persistence: From Architecture to Solutions
Dino Esposito. Polyglot Persistence: From Architecture to Solutions
 
11 ooad uml-14
11 ooad uml-1411 ooad uml-14
11 ooad uml-14
 
Design in construction
Design in constructionDesign in construction
Design in construction
 
Design in construction
Design in constructionDesign in construction
Design in construction
 
Design patterns
Design patternsDesign patterns
Design patterns
 
The Object Model
The Object Model  The Object Model
The Object Model
 
Design pattern
Design patternDesign pattern
Design pattern
 

Dernier

TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
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
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
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
 

Dernier (20)

TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
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
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.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
 

Design patterns

  • 1. Design Patterns Introduction and Overview By, Abhishek Sagi Monday 5 December 11
  • 2. Today Introduction to Design Patterns : What are they? Types of Patterns Examples : Commonly used patterns References Monday 5 December 11
  • 3. Design Patterns What are they? Monday 5 December 11
  • 4. Design Patterns Idea originated from Christopher Wolfgang Alexander (Austria). Architect It was initially applied for architecture for buildings and towns, But not computer programming for writing software. Monday 5 December 11
  • 5. "Each pattern describes a problem which occurs over and over again in our environment, and then describes the core of the solution to that problem, in such a way that you can use this solution a million times over, without ever doing it the same way twice” -Christopher Alexander (Architect) “A Pattern Language”,New York, Oxford University Press, 1977. Monday 5 December 11
  • 6. Design Patterns Even through he was talking about patterns in buildings and towns, What he says is true about object-oriented design patterns. Solutions are expressed in terms of objects and interfaces instead of walls and doors. At core both patterns is a solution to a problem in a context. Simply, design patterns help a designer to get a right design faster. Monday 5 December 11
  • 7. Describes a design pattern as a three-part rule 1.) Description of a context 2.) A problem 3.) A solution This is modified for software design patterns which consists of four parts Monday 5 December 11
  • 8. Four Essential Parts Pattern name A handle to briefly describe the design problem,but more importantly to provide a common vocabulary for software designers to use. Problem A description of the problem that the design pattern is intended to solve. Monday 5 December 11
  • 9. Solution Describes what elements are required to make up the design, their relationships and its context. Consequences What are the results and trade offs by applying the design pattern. Allows comparison between different design patterns, to see if there is a better fit for the actual problem. Monday 5 December 11
  • 10. Design Patterns : Programming Languages Aimed towards languages that have language level support for Object Oriented Programming Not exclusively , But it would be easier to apply with OOP! Different OOP languages have different mechanisms for applying patterns. Monday 5 December 11
  • 11. Types Of Patterns General description of the type of problem the pattern addresses Creational: Concerned with everything about the creation of objects Structural: Concerned with how classes and objects are composed to form larger structures Monday 5 December 11
  • 12. Types Of Patterns (Continued) Behavioral Concerned with algorithms and the assignment of responsibilities between objects. Monday 5 December 11
  • 13. Types Of Patterns (Overview) Creational: Creational patterns are ones that create objects for you, rather than having you instantiate objects directly. This gives your program more flexibility in deciding which objects need to be created for a given case. Abstract Factory*: Groups object factories that have a common theme. Builder constructs: Complex objects by separating construction and representation. Factory Method*: Creates objects without specifying the exact class to create. Prototype: Creates objects by cloning an existing object. Singleton*: Restricts object creation for a class to only one instance. Monday 5 December 11
  • 14. Types Of Patterns (Contd) Structural Patterns: These concern class and object composition. They use inheritance to compose interfaces and define ways to compose objects to obtain new functionality. Adapter: Allows classes with incompatible interfaces to work together by wrapping its own interface around that of an already existing class. Bridge*: Decouples an abstraction from its implementation so that the two can vary independently. Composite: Composes zero-or-more similar objects so that they can be manipulated as one object. Decorator: Dynamically adds/overrides behavior in an existing method of an object. Monday 5 December 11
  • 15. Types Of Patterns (Contd) Facade: Provides a simplified interface to a large body of code. Flyweight: Reduces the cost of creating and manipulating a large number of similar objects. Proxy: Provides a placeholder for another object to control access, reduce cost, and reduce complexity. Behavioral Patterns: Most of these design patterns are specifically concerned with communication between objects. Chain of responsibility: Delegates commands to a chain of processing objects. Command: Creates objects which encapsulate actions and parameters. Interpreter: Implements a specialized language. Monday 5 December 11
  • 16. Types Of Patterns (Contd) Iterator*: Accesses the elements of an object sequentially without exposing its underlying representation. Mediator: Allows loose coupling between classes by being the only class that has detailed knowledge of their methods. Memento: Provides the ability to restore an object to its previous state (undo). Observer: Is a publish/subscribe pattern which allows a number of observer objects to see an event. State*: Allows an object to alter its behavior when its internal state changes. Strategy: Allows one of a family of algorithms to be selected on-the-fly at runtime. Monday 5 December 11
  • 17. Design Pattern Example 1: The Singleton Monday 5 December 11
  • 18. Singleton Creational category of design patterns Intent: Ensure that a class has only once instance, And provide global point of access to it. Motivation: Important for some classes to have no more than one instance. Examples: Console in a game; Logging utility; An Application Class; A Window Manager. Monday 5 December 11
  • 19. Singleton Code Example Monday 5 December 11
  • 20. Design Pattern Example 2: State Pattern Monday 5 December 11
  • 21. State Pattern Behavioral category of design patterns Provides behavior to an object so that it can be changed during runtime. Very similar to bridge pattern but intention is different Bridge is structural : Hide data from client client only aware of the handle State is behavioral : Provides flexible behavior of owning object and client would be aware of both owning object and state objects. Monday 5 December 11
  • 22. State Pattern: Approaches Application decide Requires state transition Implies constraints, And less flexible states are unaware of each other States decide Most flexible approach States are aware of each other Implementation dependencies between state code Monday 5 December 11
  • 23. State creation/destruction: 2 Approaches: As Needed States are created on the fly Destroyed when no longer need - can be expensive Conserves memory Preferable where state changes are infrequent States created in advance (Compile time) Destroyed only when application terminates - CHEAP! Memory usage - COSTLY! (all data stored in states are created upfront) Preferable where state changes are frequent Monday 5 December 11
  • 24. State Pattern Code Example Monday 5 December 11
  • 25. Recommended Books Design Patterns: Elements of Reusable Object-Oriented Software Authors: “Gang of four” Hardback: 416 pages Publisher: Addison Wesley (14 Mar 1995) C++ ISBN-10: 0201633612 ISBN-13: 978-0201633610 Head First: Design Patterns Authors: Several Paperback: 688 pages Publisher: O'Reilly Media (25 Oct 2004) Java ISBN-10: 0596007124 ISBN-13: 978-0596007126 Monday 5 December 11
  • 26. Questions? Contact: Sharat Chandra (or) Tushar Goswami Email: abhishek.sagi@ymail.com Monday 5 December 11
  • 27. References Design Patterns: Introduction To Design Patterns; Steven Mead , Senior Programming Lecturer , University Of Teesside ; 2010 . Design Patterns: Elements of Reusable Object- Oriented Software; Erich Gamma et al; Addison- Wesley; 1995; 978-0201633610. http://en.wikipedia.org/wiki/Design_Patterns Big C++ (2nd edition); Cay Horstmann; Timothy Budd; John Wiley & Sons; January 2009; 978- 0470383285. Monday 5 December 11
  • 28. Thank you J Monday 5 December 11