SlideShare a Scribd company logo
1
Structural
Patterns
SolutionsProblems
Creational
Patterns
Behavioral
Pattern
Why ?
LET US UNDERSTAND DESIGN PATTERNS
Rabinarayan Biswal
Mindfire Solutions
14/05/2013
When ?
How ?
AGENDA
A brief history
What is design
pattern
When to use
design Pattern ?
Introduct
ion
Classification of
Design Patterns
Understanding
different
patterns
How to use
different
patterns ?
Overview
Data Tier
Middle Tier
Presentation Tier
MVC
Detailed
Study
A BRIEF HISTORY
Christopher Alexander Kent Beck Ward Cunningham
- Patterns originated as an architectural concept by Christopher Alexander (1977/79).
- In 1987 Kent Beck (creator of Extreme Programming and TDD) and Ward Cunningham (contributor to
Extreme Programming) began experimenting with the idea of applying patterns to programming and
presented their results at the OOPSLA conference that year
GANG OF FOUR
Erich Gamma Ralph Johnson John Vlissides Richard Helm
- Design patterns gained popularity in computer science after the book Design Patterns: Elements of Reusable
Object-Oriented Software was published in 1994 by the so-called "Gang of Four" (GoF)
- GoF established 23 patterns classified into 3 types – Creational, Structural and Behavioral
WHAT IS DESIGN PATTERN ?
solutionsReusable ProblemsCommonly
occurring DesignSoftware
- In software engineering, a design pattern is a general reusable solution to a commonly occurring problem
within a given context in software design - Wikipedia
- It is a description for how to solve a problem that can be used in many different situations
WHEN DESIGN PATTERN ?
You can consider not using any design pattern in following cases –
- The application being built will not change in future, the code accurately captures all requirements and
there are no planned enhancements on new features (the application you are building is the first and
last release )
- Your application‟s requirement is unique . No software engineer has ever built anything like your
application 
- There is plenty of time to prototype your new design ideas . No proof-of-concept is required 
- Everyone one your team has worked together for 20 years or so . You all posses a common set of design
vocabulary, so you don‟t need to learn someone else‟ 
If you don’t fall into any of the above categories – Use Design
Pattern 
THE STORY OF LIGHT, SWITCH & FAN
Fan Fancy Switch Bulb Normal Switch
BENEFITS OF USING DESIGN PATTERN
- speed up the development process by providing tested, proven development paradigms .
- Reusing design patterns helps to prevent subtle issues that can cause major problems, and it also
improves code readability for coders and architects who are familiar with the patterns.
- Design patterns provide general solutions, documented in a format that doesn't require specifics tied to
a particular problem.
- In addition, patterns allow developers to communicate using well-known, well understood names for
software interactions. Common design patterns can be improved over time, making them more robust
than ad-hoc designs
- A standard solution to a common programming problem enable large scale reuse of S/W
TYPES OF DESIGN PATTERNS
Creational •Object creation
Structural
•Build large, complex
objects
Behavioral
•Play with algorithms and
relationship with objects
DESIGN PATTERNS
Creational
• Factory Method
• Abstract Factory Method
• Singleton
• Builder
• Prototype
Structural
• Adaptor
• Bridge
• Composite
• Decorator
• Facade
• Flyweight
• Proxy
Behavioral
• Chain of Responsibility
• Command
• Interpreter
• Iterator
• Mediator
• Memento
• Observer
• State
• Strategy
• Template
• Visitor
USAGE
High
Factory
Abstract
Factory
Façade
Iterator
Observer
Medium High
Singleton
Adapter
Composite
Proxy
Command
Strategy
Medium
Prototype
Bridge
Decorator
State
Template
Medium Low
Builder
Chain of
Responsibi
lity
Mediator
Low
Flyweight
Interpreter
Memento
Visitor
Creational
Pattern
creational design patterns are design patterns that deal with object creation mechanisms, trying to create
objects in a manner suitable to the situation. The basic form of object creation could result in design
problems or added complexity to the design. Creational design patterns solve this problem by controlling
the object creation.
FACTORY DESIGN PATTERN
- This pattern is used to create concrete class instances without specifying the exact class type.
- Define an interface for creating an object, but let the subclasses decide which class to instantiate. The Factory
method lets a class defer instantiation to subclasses .
- Logical model
FACTORY PATTERN - A REAL WORLD EXAMPLE
Document
Resume Report Presentation
FACTORY PATTERN - UML
FACTORY PATTERN – HOW ?
- If you have an inheritance hierarchy that exercises polymorphism, consider adding a polymorphic
creation capability by defining a static factory method in the base class.
- Design the arguments to the factory method. What qualities or characteristics are necessary and
sufficient to identify the correct derived class to instantiate?
- Consider designing an internal “object pool” that will allow objects to be reused instead of created from
scratch.
- Consider making all constructors private or protected.
FACTORY PATTERN IN .NET
- IDbCommand.CreateParameter
- Convert.ToBoolean
- WebRequest: HttpWebRequest, FtpWebRequest
- ASP.NET Runtime
FACTORY PATTERN – WHEN ?
Do we need to have derived classes figure out what to instantiate
and decouple client from instantiated class ?
Structural Pattern
structural design patterns are design patterns that ease the design by identifying a simple way to realize
relationships between entities.
FAÇADE DESIGN PATTERN
- Used to provide a simpler interface into a more complicated portion of code.
- A facade can make a software library easier to use and understand, since the facade has convenient methods for
common tasks
- A facade can make code that uses the library more readable, for the same reason
- A facade can reduce dependencies of outside code on the inner workings of a library, since most code uses the
facade, thus allowing more flexibility in developing the system
- A facade can wrap a poorly-designed collection of APIs with a single well-designed API
- The Facade however, can itself become too complex for a huge subsystem. Also it's a good idea to actually have
an abstract Facade over the Facade. One of the most common and successful examples is using this pattern
through a webservice, making the webservice acting as the Facade or the interface to many different dll's each
representing a subsystem.
FAÇADE - UML
FAÇADE – A REAL WORLD EXAMPLE
Marriage
Decoration
Food
Procession
FAÇADE DESIGN PATTERN – HOW ?
- Identify a simpler, unified interface for the subsystem or component.
- Design a „wrapper‟ class that encapsulates the subsystem.
- The facade/wrapper captures the complexity and collaborations of the component, and delegates to the
appropriate methods.
- The client uses (is coupled to) the Facade only.
- Consider whether additional Facades would add value.
FAÇADE DESIGN PATTERN – WHEN ?
Do we want simplify, beautify or OO-fy an existing class or subsystem ?
COMPOSITE DESIGN PATTERN
- Compose objects into tree structures to represent part-whole hierarchies. Composite lets clients treat individual
objects and compositions of objects uniformly.
- Recursive composition
- “Directories contain entries, each of which could be a directory.”
- 1-to-many “has a” up the “is a” hierarchy
COMPOSITE PATTERN – UML
COMPOSITE – A REAL WORLD EXAMPLE
Category
Food
Diary
Milk
Yogurt
cheese
Non-Veg
Fish
Chicken
Veg
Potato
Onion
Sweets
Candy
Ice cream
Electronics
Audio
Digital
COMPOSITE PATTERN – HOW ?
- Ensure that your problem is about representing “whole-part” hierarchical relationships.
- Consider the heuristic, “Containers that contain containees, each of which could be a container.” For
example, “Assemblies that contain components, each of which could be an assembly.” Divide your
domain concepts into container classes, and containee classes.
- Create a “lowest common denominator” interface that makes your containers and containees
interchangeable. It should specify the behavior that needs to be exercised uniformly across all containee
and container objects.
- All container and containee classes declare an “is a” relationship to the interface.
- All container classes declare a one-to-many “has a” relationship to the interface.
- Container classes leverage polymorphism to delegate to their containee objects.
- Child management methods [e.g. addChild(), removeChild()] should normally be defined in the
Composite class. Unfortunately, the desire to treat Leaf and Composite objects uniformly may require
that these methods be promoted to the abstract Component class. See the Gang of Four for a
discussion of these “safety” versus “transparency” trade-offs.
COMPOSITE PATTERN – WHEN ?
Do we have units and groups and want to treat them the same way ?
Behavioral
Pattern
behavioral design patterns are design patterns that identify common communication patterns between
objects and realize these patterns. By doing so, these patterns increase flexibility in carrying out this
communication.
OBSERVER DESIGN PATTERN
- Define a one-to-many dependency between objects so that when one object changes state, all its
dependents are notified and updated automatically.
- You should use the pattern in the following cases:
- You have a publisher/subscriber model.
- Objects need to be notified of a change in another objects.
- You need that the object that notify its state change would not know about its subscribers.
OBSERVER PATTERN–A REAL WORLD EXAMPLE
Stock
Investor
UI
OBSERVER PATTERN - UML
OBSERVER PATTERN – HOW ?
- Differentiate between the core (or independent) functionality and the optional (or dependent)
functionality.
- Model the independent functionality with a “subject” abstraction.
- Model the dependent functionality with an “observer” hierarchy.
- The Subject is coupled only to the Observer base class.
- The client configures the number and type of Observers.
- Observers register themselves with the Subject.
- The Subject broadcasts events to all registered Observers.
- The Subject may “push” information at the Observers, or, the Observers may “pull” the information they
need from the Subject.
OBSERVER PATTERN IN .NET
Event Driven Programming
OBSERVER PATTERN – WHEN ?
Do various entities need to know about events that have occurred?
How to keep dependent object up-to-date.
STRATEGY DESIGN PATTERN
- The Strategy design pattern allows you to use multiple algorithms interchangeably.
- Define a family of algorithms, encapsulate each one, and make them interchangeable. Strategy lets the
algorithm vary independently from the clients that use it.
- Capture the abstraction in an interface, bury implementation details in derived classes.
STRATEGY PATTERN- A REAL WORLD EXAMPLE
Sorting
Merge
Sort
Shell
Sort
Quick
Sort
STRATEGY DESIGN PATTERN - UML
STRATEGY PATTERN – HOW ?
- Identify an algorithm (i.e. a behavior) that the client would prefer to access through a “flex point”.
- Specify the signature for that algorithm in an interface.
- Bury the alternative implementation details in derived classes.
- Clients of the algorithm couple themselves to the interface.
STRATEGY PATTERN IN .NET
Membership Providers
Role Providers
Site Map Providers
Session State Providers
Profile Providers
Web Event Providers
Web Parts Personalization Providers
STRATEGY PATTERN – WHEN ?
Do we have a varying rule or algorithm ?
MVC
MVC
Observer
(Behavioral)
Composite
(Structural)
Factory
(Creational)
Strategy
(Behavioral)
PATTERNS IN MVC
Observer (Behavioral Pattern)
- MVC uses the observer pattern to keep each view in sync with the model . Therefore whenever data
with in the model changes, each subscribing view (whether it‟s a webpage, a windows form or a form in
PDA) gets notified .
Composite (Structural Pattern)
- Each view uses composite pattern to make up its internal structure of visual elements (buttons, text
boxes, scrollbars etc.).
Strategy (Behavioral Pattern)
- The strategy design pattern defines the relationship between the view and controller . Hence multiple
controller can be used with a single view, depending upon the current state of the application. It allows
you to interchange the controller of a view when needed at design time and at runtime.
Factory (Creational Pattern)
- You can choose the default controller of a view when its rendered .
Let us understand design pattern

More Related Content

What's hot

Introduction to design patterns
Introduction to design patternsIntroduction to design patterns
Introduction to design patterns
Amit Kabra
 
Design Pattern For C# Part 1
Design Pattern For C# Part 1Design Pattern For C# Part 1
Design Pattern For C# Part 1
Shahzad
 
Design Patterns
Design PatternsDesign Patterns
Design Patternssoms_1
 
Design Pattern in Software Engineering
Design Pattern in Software EngineeringDesign Pattern in Software Engineering
Design Pattern in Software Engineering
Manish Kumar
 
Creational pattern
Creational patternCreational pattern
Creational pattern
Himanshu
 
Software Design Patterns
Software Design PatternsSoftware Design Patterns
Software Design Patterns
Pankhuree Srivastava
 
Factory Design Pattern
Factory Design PatternFactory Design Pattern
Factory Design Pattern
Jyaasa Technologies
 
Design pattern (Abstract Factory & Singleton)
Design pattern (Abstract Factory & Singleton)Design pattern (Abstract Factory & Singleton)
Design pattern (Abstract Factory & Singleton)
paramisoft
 
The Singleton Pattern Presentation
The Singleton Pattern PresentationThe Singleton Pattern Presentation
The Singleton Pattern Presentation
JAINIK PATEL
 
Singleton design pattern
Singleton design patternSingleton design pattern
Singleton design pattern
11prasoon
 
Design Patterns Illustrated
Design Patterns IllustratedDesign Patterns Illustrated
Design Patterns Illustrated
Herman Peeren
 
Design patterns
Design patternsDesign patterns
Design patterns
Elyes Mejri
 
Software Engineering - chp4- design patterns
Software Engineering - chp4- design patternsSoftware Engineering - chp4- design patterns
Software Engineering - chp4- design patterns
Lilia Sfaxi
 
Prototype pattern
Prototype patternPrototype pattern
Prototype pattern
Shakil Ahmed
 
GoF Design patterns I: Introduction + Structural Patterns
GoF Design patterns I:   Introduction + Structural PatternsGoF Design patterns I:   Introduction + Structural Patterns
GoF Design patterns I: Introduction + Structural Patterns
Sameh Deabes
 
Design Pattern - Factory Method Pattern
Design Pattern - Factory Method PatternDesign Pattern - Factory Method Pattern
Design Pattern - Factory Method Pattern
Mudasir Qazi
 

What's hot (20)

Introduction to design patterns
Introduction to design patternsIntroduction to design patterns
Introduction to design patterns
 
Design Pattern For C# Part 1
Design Pattern For C# Part 1Design Pattern For C# Part 1
Design Pattern For C# Part 1
 
Design patterns tutorials
Design patterns tutorialsDesign patterns tutorials
Design patterns tutorials
 
Design Patterns
Design PatternsDesign Patterns
Design Patterns
 
Design Pattern in Software Engineering
Design Pattern in Software EngineeringDesign Pattern in Software Engineering
Design Pattern in Software Engineering
 
Creational pattern
Creational patternCreational pattern
Creational pattern
 
Design Pattern
Design PatternDesign Pattern
Design Pattern
 
Software Design Patterns
Software Design PatternsSoftware Design Patterns
Software Design Patterns
 
Gof design patterns
Gof design patternsGof design patterns
Gof design patterns
 
Factory Design Pattern
Factory Design PatternFactory Design Pattern
Factory Design Pattern
 
Design pattern (Abstract Factory & Singleton)
Design pattern (Abstract Factory & Singleton)Design pattern (Abstract Factory & Singleton)
Design pattern (Abstract Factory & Singleton)
 
The Singleton Pattern Presentation
The Singleton Pattern PresentationThe Singleton Pattern Presentation
The Singleton Pattern Presentation
 
Singleton design pattern
Singleton design patternSingleton design pattern
Singleton design pattern
 
Design Patterns Illustrated
Design Patterns IllustratedDesign Patterns Illustrated
Design Patterns Illustrated
 
Design pattern-presentation
Design pattern-presentationDesign pattern-presentation
Design pattern-presentation
 
Design patterns
Design patternsDesign patterns
Design patterns
 
Software Engineering - chp4- design patterns
Software Engineering - chp4- design patternsSoftware Engineering - chp4- design patterns
Software Engineering - chp4- design patterns
 
Prototype pattern
Prototype patternPrototype pattern
Prototype pattern
 
GoF Design patterns I: Introduction + Structural Patterns
GoF Design patterns I:   Introduction + Structural PatternsGoF Design patterns I:   Introduction + Structural Patterns
GoF Design patterns I: Introduction + Structural Patterns
 
Design Pattern - Factory Method Pattern
Design Pattern - Factory Method PatternDesign Pattern - Factory Method Pattern
Design Pattern - Factory Method Pattern
 

Similar to Let us understand design pattern

Typescript design patterns applied to sharepoint framework - Sharepoint Satur...
Typescript design patterns applied to sharepoint framework - Sharepoint Satur...Typescript design patterns applied to sharepoint framework - Sharepoint Satur...
Typescript design patterns applied to sharepoint framework - Sharepoint Satur...
Luis Valencia
 
L03 Design Patterns
L03 Design PatternsL03 Design Patterns
L03 Design Patterns
Ólafur Andri Ragnarsson
 
5 Design Patterns Explained
5 Design Patterns Explained5 Design Patterns Explained
5 Design Patterns Explained
Prabhjit Singh
 
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
Saurabh Moody
 
Design Pattern Notes: Nagpur University
Design Pattern Notes: Nagpur UniversityDesign Pattern Notes: Nagpur University
Design Pattern Notes: Nagpur University
Shubham Narkhede
 
Sda 9
Sda   9Sda   9
Design patterns
Design patternsDesign patterns
Design patterns
Kolade Ibrahim Arowolo
 
Oops design pattern intro
Oops design pattern intro Oops design pattern intro
Oops design pattern intro
anshu_atri
 
Why Design Patterns Are Important In Software Engineering
Why Design Patterns Are Important In Software EngineeringWhy Design Patterns Are Important In Software Engineering
Why Design Patterns Are Important In Software Engineering
Protelo, Inc.
 
Software Patterns
Software PatternsSoftware Patterns
Software Patterns
kim.mens
 
Module 2 design patterns-2
Module 2   design patterns-2Module 2   design patterns-2
Module 2 design patterns-2
Ankit Dubey
 
Patterns (contd)Software Development ProcessDesign patte.docx
Patterns (contd)Software Development ProcessDesign patte.docxPatterns (contd)Software Development ProcessDesign patte.docx
Patterns (contd)Software Development ProcessDesign patte.docx
danhaley45372
 
Design Patterns
Design PatternsDesign Patterns
Design Patterns
Sergii Stets
 
L05 Design Patterns
L05 Design PatternsL05 Design Patterns
L05 Design Patterns
Ólafur Andri Ragnarsson
 
Design Pattern lecture 2
Design Pattern lecture 2Design Pattern lecture 2
Design Pattern lecture 2
Julie Iskander
 
Design patterns
Design patternsDesign patterns
Design patterns
Akhilesh Joshi
 
Design patterns - How much we understand and know ??
Design patterns - How much we understand and know ??Design patterns - How much we understand and know ??
Design patterns - How much we understand and know ??
Vinay Raj
 
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
 
Object Oriented Analysis and Design
Object Oriented Analysis and DesignObject Oriented Analysis and Design
Object Oriented Analysis and Design
Dr. C.V. Suresh Babu
 

Similar to Let us understand design pattern (20)

Typescript design patterns applied to sharepoint framework - Sharepoint Satur...
Typescript design patterns applied to sharepoint framework - Sharepoint Satur...Typescript design patterns applied to sharepoint framework - Sharepoint Satur...
Typescript design patterns applied to sharepoint framework - Sharepoint Satur...
 
L03 Design Patterns
L03 Design PatternsL03 Design Patterns
L03 Design Patterns
 
5 Design Patterns Explained
5 Design Patterns Explained5 Design Patterns Explained
5 Design Patterns Explained
 
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
 
Design Pattern Notes: Nagpur University
Design Pattern Notes: Nagpur UniversityDesign Pattern Notes: Nagpur University
Design Pattern Notes: Nagpur University
 
Sda 9
Sda   9Sda   9
Sda 9
 
Design patterns
Design patternsDesign patterns
Design patterns
 
Oops design pattern intro
Oops design pattern intro Oops design pattern intro
Oops design pattern intro
 
Why Design Patterns Are Important In Software Engineering
Why Design Patterns Are Important In Software EngineeringWhy Design Patterns Are Important In Software Engineering
Why Design Patterns Are Important In Software Engineering
 
Software Patterns
Software PatternsSoftware Patterns
Software Patterns
 
Module 2 design patterns-2
Module 2   design patterns-2Module 2   design patterns-2
Module 2 design patterns-2
 
Introduction to Design Patterns
Introduction to Design PatternsIntroduction to Design Patterns
Introduction to Design Patterns
 
Patterns (contd)Software Development ProcessDesign patte.docx
Patterns (contd)Software Development ProcessDesign patte.docxPatterns (contd)Software Development ProcessDesign patte.docx
Patterns (contd)Software Development ProcessDesign patte.docx
 
Design Patterns
Design PatternsDesign Patterns
Design Patterns
 
L05 Design Patterns
L05 Design PatternsL05 Design Patterns
L05 Design Patterns
 
Design Pattern lecture 2
Design Pattern lecture 2Design Pattern lecture 2
Design Pattern lecture 2
 
Design patterns
Design patternsDesign patterns
Design patterns
 
Design patterns - How much we understand and know ??
Design patterns - How much we understand and know ??Design patterns - How much we understand and know ??
Design patterns - How much we understand and know ??
 
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)
 
Object Oriented Analysis and Design
Object Oriented Analysis and DesignObject Oriented Analysis and Design
Object Oriented Analysis and Design
 

More from Mindfire Solutions

Physician Search and Review
Physician Search and ReviewPhysician Search and Review
Physician Search and Review
Mindfire Solutions
 
diet management app
diet management appdiet management app
diet management app
Mindfire Solutions
 
Business Technology Solution
Business Technology SolutionBusiness Technology Solution
Business Technology Solution
Mindfire Solutions
 
Remote Health Monitoring
Remote Health MonitoringRemote Health Monitoring
Remote Health Monitoring
Mindfire Solutions
 
Influencer Marketing Solution
Influencer Marketing SolutionInfluencer Marketing Solution
Influencer Marketing Solution
Mindfire Solutions
 
ELMAH
ELMAHELMAH
High Availability of Azure Applications
High Availability of Azure ApplicationsHigh Availability of Azure Applications
High Availability of Azure Applications
Mindfire Solutions
 
IOT Hands On
IOT Hands OnIOT Hands On
IOT Hands On
Mindfire Solutions
 
Glimpse of Loops Vs Set
Glimpse of Loops Vs SetGlimpse of Loops Vs Set
Glimpse of Loops Vs Set
Mindfire Solutions
 
Oracle Sql Developer-Getting Started
Oracle Sql Developer-Getting StartedOracle Sql Developer-Getting Started
Oracle Sql Developer-Getting Started
Mindfire Solutions
 
Adaptive Layout In iOS 8
Adaptive Layout In iOS 8Adaptive Layout In iOS 8
Adaptive Layout In iOS 8
Mindfire Solutions
 
Introduction to Auto-layout : iOS/Mac
Introduction to Auto-layout : iOS/MacIntroduction to Auto-layout : iOS/Mac
Introduction to Auto-layout : iOS/Mac
Mindfire Solutions
 
LINQPad - utility Tool
LINQPad - utility ToolLINQPad - utility Tool
LINQPad - utility Tool
Mindfire Solutions
 
Get started with watch kit development
Get started with watch kit developmentGet started with watch kit development
Get started with watch kit development
Mindfire Solutions
 
Swift vs Objective-C
Swift vs Objective-CSwift vs Objective-C
Swift vs Objective-C
Mindfire Solutions
 
Material Design in Android
Material Design in AndroidMaterial Design in Android
Material Design in Android
Mindfire Solutions
 
Introduction to OData
Introduction to ODataIntroduction to OData
Introduction to OData
Mindfire Solutions
 
Ext js Part 2- MVC
Ext js Part 2- MVCExt js Part 2- MVC
Ext js Part 2- MVC
Mindfire Solutions
 
ExtJs Basic Part-1
ExtJs Basic Part-1ExtJs Basic Part-1
ExtJs Basic Part-1
Mindfire Solutions
 
Spring Security Introduction
Spring Security IntroductionSpring Security Introduction
Spring Security Introduction
Mindfire Solutions
 

More from Mindfire Solutions (20)

Physician Search and Review
Physician Search and ReviewPhysician Search and Review
Physician Search and Review
 
diet management app
diet management appdiet management app
diet management app
 
Business Technology Solution
Business Technology SolutionBusiness Technology Solution
Business Technology Solution
 
Remote Health Monitoring
Remote Health MonitoringRemote Health Monitoring
Remote Health Monitoring
 
Influencer Marketing Solution
Influencer Marketing SolutionInfluencer Marketing Solution
Influencer Marketing Solution
 
ELMAH
ELMAHELMAH
ELMAH
 
High Availability of Azure Applications
High Availability of Azure ApplicationsHigh Availability of Azure Applications
High Availability of Azure Applications
 
IOT Hands On
IOT Hands OnIOT Hands On
IOT Hands On
 
Glimpse of Loops Vs Set
Glimpse of Loops Vs SetGlimpse of Loops Vs Set
Glimpse of Loops Vs Set
 
Oracle Sql Developer-Getting Started
Oracle Sql Developer-Getting StartedOracle Sql Developer-Getting Started
Oracle Sql Developer-Getting Started
 
Adaptive Layout In iOS 8
Adaptive Layout In iOS 8Adaptive Layout In iOS 8
Adaptive Layout In iOS 8
 
Introduction to Auto-layout : iOS/Mac
Introduction to Auto-layout : iOS/MacIntroduction to Auto-layout : iOS/Mac
Introduction to Auto-layout : iOS/Mac
 
LINQPad - utility Tool
LINQPad - utility ToolLINQPad - utility Tool
LINQPad - utility Tool
 
Get started with watch kit development
Get started with watch kit developmentGet started with watch kit development
Get started with watch kit development
 
Swift vs Objective-C
Swift vs Objective-CSwift vs Objective-C
Swift vs Objective-C
 
Material Design in Android
Material Design in AndroidMaterial Design in Android
Material Design in Android
 
Introduction to OData
Introduction to ODataIntroduction to OData
Introduction to OData
 
Ext js Part 2- MVC
Ext js Part 2- MVCExt js Part 2- MVC
Ext js Part 2- MVC
 
ExtJs Basic Part-1
ExtJs Basic Part-1ExtJs Basic Part-1
ExtJs Basic Part-1
 
Spring Security Introduction
Spring Security IntroductionSpring Security Introduction
Spring Security Introduction
 

Recently uploaded

Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Inflectra
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Product School
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Tobias Schneck
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
Elena Simperl
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
Product School
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
Product School
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Product School
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
Dorra BARTAGUIZ
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
DianaGray10
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Jeffrey Haguewood
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 

Recently uploaded (20)

Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 

Let us understand design pattern

  • 1. 1 Structural Patterns SolutionsProblems Creational Patterns Behavioral Pattern Why ? LET US UNDERSTAND DESIGN PATTERNS Rabinarayan Biswal Mindfire Solutions 14/05/2013 When ? How ?
  • 2. AGENDA A brief history What is design pattern When to use design Pattern ? Introduct ion Classification of Design Patterns Understanding different patterns How to use different patterns ? Overview Data Tier Middle Tier Presentation Tier MVC Detailed Study
  • 3. A BRIEF HISTORY Christopher Alexander Kent Beck Ward Cunningham - Patterns originated as an architectural concept by Christopher Alexander (1977/79). - In 1987 Kent Beck (creator of Extreme Programming and TDD) and Ward Cunningham (contributor to Extreme Programming) began experimenting with the idea of applying patterns to programming and presented their results at the OOPSLA conference that year
  • 4. GANG OF FOUR Erich Gamma Ralph Johnson John Vlissides Richard Helm - Design patterns gained popularity in computer science after the book Design Patterns: Elements of Reusable Object-Oriented Software was published in 1994 by the so-called "Gang of Four" (GoF) - GoF established 23 patterns classified into 3 types – Creational, Structural and Behavioral
  • 5. WHAT IS DESIGN PATTERN ? solutionsReusable ProblemsCommonly occurring DesignSoftware - In software engineering, a design pattern is a general reusable solution to a commonly occurring problem within a given context in software design - Wikipedia - It is a description for how to solve a problem that can be used in many different situations
  • 6. WHEN DESIGN PATTERN ? You can consider not using any design pattern in following cases – - The application being built will not change in future, the code accurately captures all requirements and there are no planned enhancements on new features (the application you are building is the first and last release ) - Your application‟s requirement is unique . No software engineer has ever built anything like your application  - There is plenty of time to prototype your new design ideas . No proof-of-concept is required  - Everyone one your team has worked together for 20 years or so . You all posses a common set of design vocabulary, so you don‟t need to learn someone else‟  If you don’t fall into any of the above categories – Use Design Pattern 
  • 7. THE STORY OF LIGHT, SWITCH & FAN Fan Fancy Switch Bulb Normal Switch
  • 8. BENEFITS OF USING DESIGN PATTERN - speed up the development process by providing tested, proven development paradigms . - Reusing design patterns helps to prevent subtle issues that can cause major problems, and it also improves code readability for coders and architects who are familiar with the patterns. - Design patterns provide general solutions, documented in a format that doesn't require specifics tied to a particular problem. - In addition, patterns allow developers to communicate using well-known, well understood names for software interactions. Common design patterns can be improved over time, making them more robust than ad-hoc designs - A standard solution to a common programming problem enable large scale reuse of S/W
  • 9. TYPES OF DESIGN PATTERNS Creational •Object creation Structural •Build large, complex objects Behavioral •Play with algorithms and relationship with objects
  • 10. DESIGN PATTERNS Creational • Factory Method • Abstract Factory Method • Singleton • Builder • Prototype Structural • Adaptor • Bridge • Composite • Decorator • Facade • Flyweight • Proxy Behavioral • Chain of Responsibility • Command • Interpreter • Iterator • Mediator • Memento • Observer • State • Strategy • Template • Visitor
  • 12. Creational Pattern creational design patterns are design patterns that deal with object creation mechanisms, trying to create objects in a manner suitable to the situation. The basic form of object creation could result in design problems or added complexity to the design. Creational design patterns solve this problem by controlling the object creation.
  • 13. FACTORY DESIGN PATTERN - This pattern is used to create concrete class instances without specifying the exact class type. - Define an interface for creating an object, but let the subclasses decide which class to instantiate. The Factory method lets a class defer instantiation to subclasses . - Logical model
  • 14. FACTORY PATTERN - A REAL WORLD EXAMPLE Document Resume Report Presentation
  • 16. FACTORY PATTERN – HOW ? - If you have an inheritance hierarchy that exercises polymorphism, consider adding a polymorphic creation capability by defining a static factory method in the base class. - Design the arguments to the factory method. What qualities or characteristics are necessary and sufficient to identify the correct derived class to instantiate? - Consider designing an internal “object pool” that will allow objects to be reused instead of created from scratch. - Consider making all constructors private or protected.
  • 17. FACTORY PATTERN IN .NET - IDbCommand.CreateParameter - Convert.ToBoolean - WebRequest: HttpWebRequest, FtpWebRequest - ASP.NET Runtime
  • 18. FACTORY PATTERN – WHEN ? Do we need to have derived classes figure out what to instantiate and decouple client from instantiated class ?
  • 19. Structural Pattern structural design patterns are design patterns that ease the design by identifying a simple way to realize relationships between entities.
  • 20. FAÇADE DESIGN PATTERN - Used to provide a simpler interface into a more complicated portion of code. - A facade can make a software library easier to use and understand, since the facade has convenient methods for common tasks - A facade can make code that uses the library more readable, for the same reason - A facade can reduce dependencies of outside code on the inner workings of a library, since most code uses the facade, thus allowing more flexibility in developing the system - A facade can wrap a poorly-designed collection of APIs with a single well-designed API - The Facade however, can itself become too complex for a huge subsystem. Also it's a good idea to actually have an abstract Facade over the Facade. One of the most common and successful examples is using this pattern through a webservice, making the webservice acting as the Facade or the interface to many different dll's each representing a subsystem.
  • 22. FAÇADE – A REAL WORLD EXAMPLE Marriage Decoration Food Procession
  • 23. FAÇADE DESIGN PATTERN – HOW ? - Identify a simpler, unified interface for the subsystem or component. - Design a „wrapper‟ class that encapsulates the subsystem. - The facade/wrapper captures the complexity and collaborations of the component, and delegates to the appropriate methods. - The client uses (is coupled to) the Facade only. - Consider whether additional Facades would add value.
  • 24. FAÇADE DESIGN PATTERN – WHEN ? Do we want simplify, beautify or OO-fy an existing class or subsystem ?
  • 25. COMPOSITE DESIGN PATTERN - Compose objects into tree structures to represent part-whole hierarchies. Composite lets clients treat individual objects and compositions of objects uniformly. - Recursive composition - “Directories contain entries, each of which could be a directory.” - 1-to-many “has a” up the “is a” hierarchy
  • 27. COMPOSITE – A REAL WORLD EXAMPLE Category Food Diary Milk Yogurt cheese Non-Veg Fish Chicken Veg Potato Onion Sweets Candy Ice cream Electronics Audio Digital
  • 28. COMPOSITE PATTERN – HOW ? - Ensure that your problem is about representing “whole-part” hierarchical relationships. - Consider the heuristic, “Containers that contain containees, each of which could be a container.” For example, “Assemblies that contain components, each of which could be an assembly.” Divide your domain concepts into container classes, and containee classes. - Create a “lowest common denominator” interface that makes your containers and containees interchangeable. It should specify the behavior that needs to be exercised uniformly across all containee and container objects. - All container and containee classes declare an “is a” relationship to the interface. - All container classes declare a one-to-many “has a” relationship to the interface. - Container classes leverage polymorphism to delegate to their containee objects. - Child management methods [e.g. addChild(), removeChild()] should normally be defined in the Composite class. Unfortunately, the desire to treat Leaf and Composite objects uniformly may require that these methods be promoted to the abstract Component class. See the Gang of Four for a discussion of these “safety” versus “transparency” trade-offs.
  • 29. COMPOSITE PATTERN – WHEN ? Do we have units and groups and want to treat them the same way ?
  • 30. Behavioral Pattern behavioral design patterns are design patterns that identify common communication patterns between objects and realize these patterns. By doing so, these patterns increase flexibility in carrying out this communication.
  • 31. OBSERVER DESIGN PATTERN - Define a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically. - You should use the pattern in the following cases: - You have a publisher/subscriber model. - Objects need to be notified of a change in another objects. - You need that the object that notify its state change would not know about its subscribers.
  • 32. OBSERVER PATTERN–A REAL WORLD EXAMPLE Stock Investor UI
  • 34. OBSERVER PATTERN – HOW ? - Differentiate between the core (or independent) functionality and the optional (or dependent) functionality. - Model the independent functionality with a “subject” abstraction. - Model the dependent functionality with an “observer” hierarchy. - The Subject is coupled only to the Observer base class. - The client configures the number and type of Observers. - Observers register themselves with the Subject. - The Subject broadcasts events to all registered Observers. - The Subject may “push” information at the Observers, or, the Observers may “pull” the information they need from the Subject.
  • 35. OBSERVER PATTERN IN .NET Event Driven Programming
  • 36. OBSERVER PATTERN – WHEN ? Do various entities need to know about events that have occurred? How to keep dependent object up-to-date.
  • 37. STRATEGY DESIGN PATTERN - The Strategy design pattern allows you to use multiple algorithms interchangeably. - Define a family of algorithms, encapsulate each one, and make them interchangeable. Strategy lets the algorithm vary independently from the clients that use it. - Capture the abstraction in an interface, bury implementation details in derived classes.
  • 38. STRATEGY PATTERN- A REAL WORLD EXAMPLE Sorting Merge Sort Shell Sort Quick Sort
  • 40. STRATEGY PATTERN – HOW ? - Identify an algorithm (i.e. a behavior) that the client would prefer to access through a “flex point”. - Specify the signature for that algorithm in an interface. - Bury the alternative implementation details in derived classes. - Clients of the algorithm couple themselves to the interface.
  • 41. STRATEGY PATTERN IN .NET Membership Providers Role Providers Site Map Providers Session State Providers Profile Providers Web Event Providers Web Parts Personalization Providers
  • 42. STRATEGY PATTERN – WHEN ? Do we have a varying rule or algorithm ?
  • 44. PATTERNS IN MVC Observer (Behavioral Pattern) - MVC uses the observer pattern to keep each view in sync with the model . Therefore whenever data with in the model changes, each subscribing view (whether it‟s a webpage, a windows form or a form in PDA) gets notified . Composite (Structural Pattern) - Each view uses composite pattern to make up its internal structure of visual elements (buttons, text boxes, scrollbars etc.). Strategy (Behavioral Pattern) - The strategy design pattern defines the relationship between the view and controller . Hence multiple controller can be used with a single view, depending upon the current state of the application. It allows you to interchange the controller of a view when needed at design time and at runtime. Factory (Creational Pattern) - You can choose the default controller of a view when its rendered .

Editor's Notes

  1. Source from - http://www.codeproject.com/Articles/98598/How-I-explained-Design-Patterns-to-my-wife-Part-1