Design patterns

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
1 de 28

Recomendados

Design Patterns - General Introduction por
Design Patterns - General IntroductionDesign Patterns - General Introduction
Design Patterns - General IntroductionAsma CHERIF
627 visualizações132 slides
Introduction to Design Pattern por
Introduction to Design  PatternIntroduction to Design  Pattern
Introduction to Design PatternSanae BEKKAR
17K visualizações31 slides
Introduction to design patterns por
Introduction to design patternsIntroduction to design patterns
Introduction to design patternsAmit Kabra
1.7K visualizações44 slides
Design Patterns por
Design PatternsDesign Patterns
Design PatternsAnuja Arosha
13.5K visualizações56 slides
Design patterns ppt por
Design patterns pptDesign patterns ppt
Design patterns pptAman Jain
28.7K visualizações18 slides
Design Patterns Presentation - Chetan Gole por
Design Patterns Presentation -  Chetan GoleDesign Patterns Presentation -  Chetan Gole
Design Patterns Presentation - Chetan GoleChetan Gole
12.1K visualizações24 slides

Mais conteúdo relacionado

Mais procurados

Let us understand design pattern por
Let us understand design patternLet us understand design pattern
Let us understand design patternMindfire Solutions
35.8K visualizações45 slides
Design pattern por
Design patternDesign pattern
Design patternThibaut De Broca
3.8K visualizações61 slides
Design pattern-presentation por
Design pattern-presentationDesign pattern-presentation
Design pattern-presentationRana Muhammad Asif
3.3K visualizações47 slides
Software Engineering - chp4- design patterns por
Software Engineering - chp4- design patternsSoftware Engineering - chp4- design patterns
Software Engineering - chp4- design patternsLilia Sfaxi
14K visualizações48 slides
Design Pattern por
Design PatternDesign Pattern
Design Patternwiradikusuma
1.7K visualizações16 slides
Software Design Patterns por
Software Design PatternsSoftware Design Patterns
Software Design PatternsPankhuree Srivastava
2.6K visualizações52 slides

Mais procurados(20)

Let us understand design pattern por Mindfire Solutions
Let us understand design patternLet us understand design pattern
Let us understand design pattern
Mindfire Solutions35.8K visualizações
Design pattern por Thibaut De Broca
Design patternDesign pattern
Design pattern
Thibaut De Broca3.8K visualizações
Design pattern-presentation por Rana Muhammad Asif
Design pattern-presentationDesign pattern-presentation
Design pattern-presentation
Rana Muhammad Asif3.3K visualizações
Software Engineering - chp4- design patterns por Lilia Sfaxi
Software Engineering - chp4- design patternsSoftware Engineering - chp4- design patterns
Software Engineering - chp4- design patterns
Lilia Sfaxi14K visualizações
Design Pattern por wiradikusuma
Design PatternDesign Pattern
Design Pattern
wiradikusuma1.7K visualizações
Software Design Patterns por Pankhuree Srivastava
Software Design PatternsSoftware Design Patterns
Software Design Patterns
Pankhuree Srivastava2.6K visualizações
Design Pattern For C# Part 1 por Shahzad
Design Pattern For C# Part 1Design Pattern For C# Part 1
Design Pattern For C# Part 1
Shahzad 7.1K visualizações
Design Pattern - Singleton Pattern por Mudasir Qazi
Design Pattern - Singleton PatternDesign Pattern - Singleton Pattern
Design Pattern - Singleton Pattern
Mudasir Qazi5.7K visualizações
Design pattern & categories por Himanshu
Design pattern & categoriesDesign pattern & categories
Design pattern & categories
Himanshu 2.5K visualizações
Software design patterns ppt por mkruthika
Software design patterns pptSoftware design patterns ppt
Software design patterns ppt
mkruthika29.9K visualizações
Builder pattern por Shakil Ahmed
Builder patternBuilder pattern
Builder pattern
Shakil Ahmed6.7K visualizações
Creational pattern por Himanshu
Creational patternCreational pattern
Creational pattern
Himanshu 3.3K visualizações
Class and object_diagram por Sadhana28
Class  and object_diagramClass  and object_diagram
Class and object_diagram
Sadhana2811K visualizações
The Singleton Pattern Presentation por JAINIK PATEL
The Singleton Pattern PresentationThe Singleton Pattern Presentation
The Singleton Pattern Presentation
JAINIK PATEL3.9K visualizações
Factory Design Pattern por Jaswant Singh
Factory Design PatternFactory Design Pattern
Factory Design Pattern
Jaswant Singh266 visualizações
Design Patterns por soms_1
Design PatternsDesign Patterns
Design Patterns
soms_114.2K visualizações
Iterator Design Pattern por Varun Arora
Iterator Design PatternIterator Design Pattern
Iterator Design Pattern
Varun Arora4.3K visualizações
Factory Method Pattern por Anjan Kumar Bollam
Factory Method PatternFactory Method Pattern
Factory Method Pattern
Anjan Kumar Bollam6K visualizações
Prototype pattern por Shakil Ahmed
Prototype patternPrototype pattern
Prototype pattern
Shakil Ahmed6.6K visualizações

Destaque

Linux process management por
Linux process managementLinux process management
Linux process managementRaghu nath
12.1K visualizações20 slides
Design pattern in android por
Design pattern in androidDesign pattern in android
Design pattern in androidJay Kumarr
21K visualizações29 slides
Object Oriented Design in Software Engineering SE12 por
Object Oriented Design in Software Engineering SE12Object Oriented Design in Software Engineering SE12
Object Oriented Design in Software Engineering SE12koolkampus
22.2K visualizações55 slides
Loving & Hating Christopher Alexander por
Loving & Hating Christopher AlexanderLoving & Hating Christopher Alexander
Loving & Hating Christopher AlexanderMolly Steenson
2.7K visualizações36 slides
Christopher Alexander: Elements Of Style por
Christopher Alexander: Elements Of StyleChristopher Alexander: Elements Of Style
Christopher Alexander: Elements Of StyleMatthias Mueller-Prove
4.1K visualizações17 slides
Traditional Serial Vision Excerpt por
Traditional Serial Vision ExcerptTraditional Serial Vision Excerpt
Traditional Serial Vision Excerptsstannard
3.6K visualizações6 slides

Destaque(11)

Linux process management por Raghu nath
Linux process managementLinux process management
Linux process management
Raghu nath12.1K visualizações
Design pattern in android por Jay Kumarr
Design pattern in androidDesign pattern in android
Design pattern in android
Jay Kumarr21K visualizações
Object Oriented Design in Software Engineering SE12 por koolkampus
Object Oriented Design in Software Engineering SE12Object Oriented Design in Software Engineering SE12
Object Oriented Design in Software Engineering SE12
koolkampus22.2K visualizações
Loving & Hating Christopher Alexander por Molly Steenson
Loving & Hating Christopher AlexanderLoving & Hating Christopher Alexander
Loving & Hating Christopher Alexander
Molly Steenson2.7K visualizações
Christopher Alexander: Elements Of Style por Matthias Mueller-Prove
Christopher Alexander: Elements Of StyleChristopher Alexander: Elements Of Style
Christopher Alexander: Elements Of Style
Matthias Mueller-Prove4.1K visualizações
Traditional Serial Vision Excerpt por sstannard
Traditional Serial Vision ExcerptTraditional Serial Vision Excerpt
Traditional Serial Vision Excerpt
sstannard3.6K visualizações
Townscape - Gordon Cullen V2 por Proyectar Ciudad
Townscape - Gordon Cullen V2Townscape - Gordon Cullen V2
Townscape - Gordon Cullen V2
Proyectar Ciudad5K visualizações
Townscape - Gordon Cullen por Proyectar Ciudad
Townscape - Gordon CullenTownscape - Gordon Cullen
Townscape - Gordon Cullen
Proyectar Ciudad14.7K visualizações
Analytical approach on design theories of christopher alexander por Shabnam Golkarian
Analytical approach on design theories of christopher alexanderAnalytical approach on design theories of christopher alexander
Analytical approach on design theories of christopher alexander
Shabnam Golkarian5.7K visualizações

Similar a Design patterns

7494607 por
74946077494607
7494607Luis Daniel Abelaira Huertos
176 visualizações64 slides
Up to speed in domain driven design por
Up to speed in domain driven designUp to speed in domain driven design
Up to speed in domain driven designRick van der Arend
1.9K visualizações33 slides
Module 2 design patterns-2 por
Module 2   design patterns-2Module 2   design patterns-2
Module 2 design patterns-2Ankit Dubey
56 visualizações37 slides
dotnet stuff.com tutorials-design-patterns_exploring-net-design-patterns-in-s... por
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
358 visualizações3 slides
Gang of Four in Java por
Gang of Four in Java Gang of Four in Java
Gang of Four in Java Mina Tafreshi
97 visualizações13 slides
OOP design patterns por
OOP design patternsOOP design patterns
OOP design patternsIgor Talevski
1.1K visualizações14 slides

Similar a Design patterns(20)

Up to speed in domain driven design por Rick van der Arend
Up to speed in domain driven designUp to speed in domain driven design
Up to speed in domain driven design
Rick van der Arend1.9K visualizações
Module 2 design patterns-2 por Ankit Dubey
Module 2   design patterns-2Module 2   design patterns-2
Module 2 design patterns-2
Ankit Dubey56 visualizações
dotnet stuff.com tutorials-design-patterns_exploring-net-design-patterns-in-s... por Anil Sharma
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 Sharma358 visualizações
Gang of Four in Java por Mina Tafreshi
Gang of Four in Java Gang of Four in Java
Gang of Four in Java
Mina Tafreshi97 visualizações
OOP design patterns por Igor Talevski
OOP design patternsOOP design patterns
OOP design patterns
Igor Talevski1.1K visualizações
PATTERNS01 - An Introduction to Design Patterns por Michael Heron
PATTERNS01 - An Introduction to Design PatternsPATTERNS01 - An Introduction to Design Patterns
PATTERNS01 - An Introduction to Design Patterns
Michael Heron361 visualizações
Design Patterns por ZubairAhmedKHUSHK
Design PatternsDesign Patterns
Design Patterns
ZubairAhmedKHUSHK108 visualizações
Design Pattern - Introduction por Mudasir Qazi
Design Pattern - IntroductionDesign Pattern - Introduction
Design Pattern - Introduction
Mudasir Qazi1.1K visualizações
Design Patterns Course por Ahmed Soliman
Design Patterns CourseDesign Patterns Course
Design Patterns Course
Ahmed Soliman2.2K visualizações
Dino Esposito. Polyglot Persistence: From Architecture to Solutions por CodeFest
Dino Esposito. Polyglot Persistence: From Architecture to SolutionsDino Esposito. Polyglot Persistence: From Architecture to Solutions
Dino Esposito. Polyglot Persistence: From Architecture to Solutions
CodeFest1.6K visualizações
Design Patterns.ppt por TanishaKochak
Design Patterns.pptDesign Patterns.ppt
Design Patterns.ppt
TanishaKochak100 visualizações
11 ooad uml-14 por Niit Care
11 ooad uml-1411 ooad uml-14
11 ooad uml-14
Niit Care6.6K visualizações
Design in construction por Asha Sari
Design in constructionDesign in construction
Design in construction
Asha Sari1.8K visualizações
Design in construction por Asha Sari
Design in constructionDesign in construction
Design in construction
Asha Sari591 visualizações
Design patterns por Oksana Demediuk
Design patternsDesign patterns
Design patterns
Oksana Demediuk435 visualizações
The Object Model por yndaravind
The Object Model  The Object Model
The Object Model
yndaravind1.5K visualizações

Último

Evolving the Network Automation Journey from Python to Platforms por
Evolving the Network Automation Journey from Python to PlatformsEvolving the Network Automation Journey from Python to Platforms
Evolving the Network Automation Journey from Python to PlatformsNetwork Automation Forum
13 visualizações21 slides
"Running students' code in isolation. The hard way", Yurii Holiuk por
"Running students' code in isolation. The hard way", Yurii Holiuk "Running students' code in isolation. The hard way", Yurii Holiuk
"Running students' code in isolation. The hard way", Yurii Holiuk Fwdays
17 visualizações34 slides
"Node.js Development in 2024: trends and tools", Nikita Galkin por
"Node.js Development in 2024: trends and tools", Nikita Galkin "Node.js Development in 2024: trends and tools", Nikita Galkin
"Node.js Development in 2024: trends and tools", Nikita Galkin Fwdays
11 visualizações38 slides
Case Study Copenhagen Energy and Business Central.pdf por
Case Study Copenhagen Energy and Business Central.pdfCase Study Copenhagen Energy and Business Central.pdf
Case Study Copenhagen Energy and Business Central.pdfAitana
16 visualizações3 slides
2024: A Travel Odyssey The Role of Generative AI in the Tourism Universe por
2024: A Travel Odyssey The Role of Generative AI in the Tourism Universe2024: A Travel Odyssey The Role of Generative AI in the Tourism Universe
2024: A Travel Odyssey The Role of Generative AI in the Tourism UniverseSimone Puorto
12 visualizações61 slides
Scaling Knowledge Graph Architectures with AI por
Scaling Knowledge Graph Architectures with AIScaling Knowledge Graph Architectures with AI
Scaling Knowledge Graph Architectures with AIEnterprise Knowledge
38 visualizações15 slides

Último(20)

Evolving the Network Automation Journey from Python to Platforms por Network Automation Forum
Evolving the Network Automation Journey from Python to PlatformsEvolving the Network Automation Journey from Python to Platforms
Evolving the Network Automation Journey from Python to Platforms
Network Automation Forum13 visualizações
"Running students' code in isolation. The hard way", Yurii Holiuk por Fwdays
"Running students' code in isolation. The hard way", Yurii Holiuk "Running students' code in isolation. The hard way", Yurii Holiuk
"Running students' code in isolation. The hard way", Yurii Holiuk
Fwdays17 visualizações
"Node.js Development in 2024: trends and tools", Nikita Galkin por Fwdays
"Node.js Development in 2024: trends and tools", Nikita Galkin "Node.js Development in 2024: trends and tools", Nikita Galkin
"Node.js Development in 2024: trends and tools", Nikita Galkin
Fwdays11 visualizações
Case Study Copenhagen Energy and Business Central.pdf por Aitana
Case Study Copenhagen Energy and Business Central.pdfCase Study Copenhagen Energy and Business Central.pdf
Case Study Copenhagen Energy and Business Central.pdf
Aitana16 visualizações
2024: A Travel Odyssey The Role of Generative AI in the Tourism Universe por Simone Puorto
2024: A Travel Odyssey The Role of Generative AI in the Tourism Universe2024: A Travel Odyssey The Role of Generative AI in the Tourism Universe
2024: A Travel Odyssey The Role of Generative AI in the Tourism Universe
Simone Puorto12 visualizações
Scaling Knowledge Graph Architectures with AI por Enterprise Knowledge
Scaling Knowledge Graph Architectures with AIScaling Knowledge Graph Architectures with AI
Scaling Knowledge Graph Architectures with AI
Enterprise Knowledge38 visualizações
【USB韌體設計課程】精選講義節錄-USB的列舉過程_艾鍗學院 por IttrainingIttraining
【USB韌體設計課程】精選講義節錄-USB的列舉過程_艾鍗學院【USB韌體設計課程】精選講義節錄-USB的列舉過程_艾鍗學院
【USB韌體設計課程】精選講義節錄-USB的列舉過程_艾鍗學院
IttrainingIttraining58 visualizações
Special_edition_innovator_2023.pdf por WillDavies22
Special_edition_innovator_2023.pdfSpecial_edition_innovator_2023.pdf
Special_edition_innovator_2023.pdf
WillDavies2218 visualizações
Uni Systems for Power Platform.pptx por Uni Systems S.M.S.A.
Uni Systems for Power Platform.pptxUni Systems for Power Platform.pptx
Uni Systems for Power Platform.pptx
Uni Systems S.M.S.A.56 visualizações
Future of AR - Facebook Presentation por ssuserb54b561
Future of AR - Facebook PresentationFuture of AR - Facebook Presentation
Future of AR - Facebook Presentation
ssuserb54b56115 visualizações
Kyo - Functional Scala 2023.pdf por Flavio W. Brasil
Kyo - Functional Scala 2023.pdfKyo - Functional Scala 2023.pdf
Kyo - Functional Scala 2023.pdf
Flavio W. Brasil400 visualizações
Mini-Track: Challenges to Network Automation Adoption por Network Automation Forum
Mini-Track: Challenges to Network Automation AdoptionMini-Track: Challenges to Network Automation Adoption
Mini-Track: Challenges to Network Automation Adoption
Network Automation Forum13 visualizações
HTTP headers that make your website go faster - devs.gent November 2023 por Thijs Feryn
HTTP headers that make your website go faster - devs.gent November 2023HTTP headers that make your website go faster - devs.gent November 2023
HTTP headers that make your website go faster - devs.gent November 2023
Thijs Feryn22 visualizações
PharoJS - Zürich Smalltalk Group Meetup November 2023 por Noury Bouraqadi
PharoJS - Zürich Smalltalk Group Meetup November 2023PharoJS - Zürich Smalltalk Group Meetup November 2023
PharoJS - Zürich Smalltalk Group Meetup November 2023
Noury Bouraqadi132 visualizações
Five Things You SHOULD Know About Postman por Postman
Five Things You SHOULD Know About PostmanFive Things You SHOULD Know About Postman
Five Things You SHOULD Know About Postman
Postman36 visualizações
Melek BEN MAHMOUD.pdf por MelekBenMahmoud
Melek BEN MAHMOUD.pdfMelek BEN MAHMOUD.pdf
Melek BEN MAHMOUD.pdf
MelekBenMahmoud14 visualizações
virtual reality.pptx por G036GaikwadSnehal
virtual reality.pptxvirtual reality.pptx
virtual reality.pptx
G036GaikwadSnehal14 visualizações
PRODUCT PRESENTATION.pptx por angelicacueva6
PRODUCT PRESENTATION.pptxPRODUCT PRESENTATION.pptx
PRODUCT PRESENTATION.pptx
angelicacueva615 visualizações

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