Presentation onDesign Patterns By Samundra Shrestha
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?
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
What are Patterns Not?1. An algorithm.2. An implementation.3. The same every time you see them.
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.
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.
Contextual DesignOpen Closed Principle (OCP) "Modules, methods, classes should be open for extension, while closed for modifications." Loose Coupling Encapsulation
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.
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
Singleton Patterns Patterns by ExamplesProblem : Ensure a class has only one instance available in the system anytime. Output: Design Patterns Example
Factory Pattern Patterns by Examplesdynamically create instances of multiple classes based on runtime input. Output: This is system generated messageThis is console generated message
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.