Design patterns


Published on

Introduction to Design Patterns by Samundra Shrestha

Published in: Technology
  • Be the first to comment

  • Be the first to like this

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Design patterns

  1. 1. Presentation onDesign Patterns By Samundra Shrestha
  2. 2. PatternsEach pattern describes a problem which occurs over andover again in our environment and then describes the coreof the solution to that problem, in such a way that you canuse this solution a million times over, without ever doing itthe same twice. - Christopher Alexander, The Timeless Way of Building, 1979 So what are patterns?
  3. 3. What are Patterns, really? Patterns catalog solutions to categories of problems They consist of A name A solution to a problem A description of the solution An assessment of the pros and cons of the pattern
  4. 4. What are Patterns Not?1. An algorithm.2. An implementation.3. The same every time you see them.
  5. 5. Introduction to Design PatternsGang of Four (GOF) Erich Gamma, Richard Helm, Ralph Johnson,and John Vlissides Authors of the original Design Patterns bookProblem in software design What – business and functionality requirements How – particular design to meet the requirements Work – Actual implementation, How put into practice.
  6. 6. Principal and Strategies  Open Closed Principle  Dependency Inversion  Single Responsibility PolicyWhy ?  improve abilities as analyst and designer.  tackle situation in which no design pattern can be applied or design pattern has not been discovered yet.
  7. 7. Contextual DesignOpen Closed Principle (OCP) "Modules, methods, classes should be open for extension, while closed for modifications."  Loose Coupling  Encapsulation
  8. 8. Dependency Inversion Principle Depend on the abstractions Higher level module should not depend on lower level module. Both high and low level should depend on abstractions Abstraction should not depend on details. Details should depend on abstractions.
  9. 9. CategorizationCreational Patterns Abstract Factory, Builder, Factory Method, Prototype, SingletonBehavioral Patterns Adapter, Bridge, Composite, Decorator, Facade, Flyweight, ProxyStructural Patterns Chain of Responsibility, Command, Interpreter, Iterator, Mediator, Memento, Observer, State, Strategy, Template, Method, Visitor Single instance in the whole application/platform
  10. 10. Singleton Patterns Patterns by ExamplesProblem : Ensure a class has only one instance available in the system anytime. Output: Design Patterns Example
  11. 11. Factory Pattern Patterns by Examplesdynamically create instances of multiple classes based on runtime input. Output: This is system generated messageThis is console generated message
  12. 12. Decorator Pattern Patterns by Examplesbest suited for altering or decorating portions of an existing object’s content orfunctionality without modifying the structure of the original object. Output : The CD contains the following tracks: 1) what-it-means. 2) brr. 3) good-bye.
  13. 13. Thank you :)