SlideShare une entreprise Scribd logo
1  sur  35
Design Patterns – Eran Toch
Methodologies in Information System Development
Design Patterns:Design Patterns:
Talking in the Design LanguageTalking in the Design Language
Eran Toch
Methodologies in the Development
of Information Systems
Design Patterns – Eran Toch
2November 2003
AgendaAgenda
• What is a Design Pattern?
• Structural Patterns
– The Composite Pattern
• Behavioral Patterns
– The Strategy Pattern
• Creational Patterns
– The Singleton Pattern
• Human Interaction Patterns
– Go Back to a Safe Place
• Summary
Design Patterns – Eran Toch
3November 2003
What is a Design Pattern?What is a Design Pattern?
In Short, a solution
for a typical problem
“a description of a recurrent
problem and of the core of possible
solutions.“
Design Patterns – Eran Toch
4November 2003
Why do we need them?Why do we need them?
• Problems are not always unique. Reusing
existing experience might be proved useful.
• We need a common language to describe
problems and solutions.
• The Design of Object-Oriented systems limits
the scope of problems and solutions we can
talk about
Design Patterns – Eran Toch
5November 2003
History of Design PatternsHistory of Design Patterns
Christopher Alexander
A Pattern Language: Towns, Buildings Construction 1970’
1995’
2000’
Architecture
Object Oriented
Software Design
Other Areas:
HCI, Organizational Behavior…
Gang of Four (GoF)
Design Patterns: Elements of
Reusable Object-Oriented Software
Many Authors
Design Patterns – Eran Toch
6November 2003
Structure of a design patternStructure of a design pattern
• Pattern Name and Classification
• Intent
– a Short statement about what the pattern does
• Motivation
– A scenario that illustrates where the pattern would be
useful
• Applicability
– Situations where the pattern can be used
Design Patterns – Eran Toch
7November 2003
Structure of a design pattern – cont’dStructure of a design pattern – cont’d
• Structure
– A graphical representation of the pattern
• Participants
– The classes and objects participating in the pattern
• Collaborations
– How to do the participants interact to carry out their
responsibilities?
• Consequences
– What are the pros and cons of using the pattern?
• Implementation
– Hints and techniques for implementing the pattern
Design Patterns – Eran Toch
8November 2003
Classification of patternsClassification of patterns
• Structural
– Composite*, Decorator, Façade, Adapter…
• Behavioral
– Strategy*, Command, Observer, Chain of
Responsibilities…
• Creational
– Singleton*, Abstract Factory, Factory Method…
• Other
– User interface Patterns
• Go Back to a Safe Place
Design Patterns – Eran Toch
9November 2003
AgendaAgenda
• What is a Design Pattern?
• Structural Patterns
• Behavioral Patterns
• Creational Patterns
• Human Interaction Patterns
• Summary
Design Patterns – Eran Toch
10November 2003
The Composite PatternThe Composite Pattern
• Intent:
– Compose objects into tree structures to represent
part-whole hierarchies.
– Composite lets clients treat individual objects and
compositions of objects uniformly. This is called
recursive composition.
Design Patterns – Eran Toch
11November 2003
MotivationMotivation
When Processing the hierarchal
collection, we need to query the
type of the object (composite or
primitive) and act differently
Diagram reference: Design
Patterns [Gof]
Design Patterns – Eran Toch
12November 2003
Composite: ApplicabilityComposite: Applicability
• Use the Composite pattern when:
– You want to represent part-whole hierarchies of
objects.
– You want clients to be able to ignore the
difference between compositions of objects and
individual objects. Clients will treat all objects in
the composite structure uniformly.
Design Patterns – Eran Toch
13November 2003
Composite: StructureComposite: Structure
• Define an abstract base class that specifies the
uniform behavior.
• Subclass the Primitive and Composite classes of the
Component class.
Diagram reference: Design
Patterns [Gof]
Design Patterns – Eran Toch
14November 2003
Composite: ConsequencesComposite: Consequences
• Benefits
– It makes it easy to add new kinds of components
– It makes clients simpler, since they do not have to
know if they are dealing with a leaf or a composite
component
• Liabilities
– It makes it harder to restrict the type of components of
a composite
Design Patterns – Eran Toch
15November 2003
Composite: Known UsesComposite: Known Uses
1. A GUI system has window objects which can
contain various GUI components (widgets) such as,
buttons and text areas. A window can also contain
widget container objects which can hold other
widgets.
Concrete examples: Java Swing, MFC
2. Folder based file system
3. Arithmetic expressions
Design Patterns – Eran Toch
16November 2003
AgendaAgenda
• What is a Design Pattern?
• Structural Patterns
• Behavioral Patterns
• Creational Patterns
• Human Interaction Patterns
• Summary
Design Patterns – Eran Toch
17November 2003
The Strategy PatternThe Strategy Pattern
• Intent:
– Define a family of algorithms, encapsulate each one,
and make them interchangeable.
– Strategy lets the algorithm vary independently from
clients that use it.
Design Patterns – Eran Toch
18November 2003
Strategy: MotivationStrategy: Motivation
The client wants to use the algorithm
without knowing which one to use in
advance. We want to add new
algorithms without changing the
client class.
Design Patterns – Eran Toch
19November 2003
Strategy: StructureStrategy: Structure
• Encapsulate the behavior of the context class in a
separate algorithm class.
• The context class keeps a reference to the algorithm
class and passes on the messages.
• The algorithm class can be sub-classed to support
multiple algorithms.
Design Patterns – Eran Toch
20November 2003
Strategy: ConsequencesStrategy: Consequences
• Benefits
– Provides an alternative to subclassing the Context
class to get a variety of algorithms or behaviors
– Keeps the client clean from large conditional
statements
– Provides a choice of implementations for the same
behavior
• Liabilities
– Increases the number of objects
– All algorithms must use the same Strategy interface
– We still need conditional statements!
Design Patterns – Eran Toch
21November 2003
Strategy: Known UsesStrategy: Known Uses
• QSIA Learning System
• Layout Manager in Java
Swing
• Sorting algorithms,
memory allocation
algorithms and more…
Design Patterns – Eran Toch
22November 2003
AgendaAgenda
• What is a Design Pattern?
• Structural Patterns
• Behavioral Patterns
• Creational Patterns
• Human Interaction Patterns
• Summary
Design Patterns – Eran Toch
23November 2003
The Singleton PatternThe Singleton Pattern
• Intent.
– Ensure a class only has one instance, and provide a
global point of access to it.
• Motivation.
– Sometimes, an application needs one, and only one,
instance of an object. For example, we want just one
window manager. Or just one factory for a family of
products.
– We need to have that one instance easily accessible.
– And we want to ensure that additional instances of the
class can not be created.
Design Patterns – Eran Toch
24November 2003
Singleton: StructureSingleton: Structure
• Declare the single instance as a private static data
member.
• Provide a public static member function that
encapsulates all initialization code, and provides
access to the instance.
Design Patterns – Eran Toch
25November 2003
Singleton: Example CodeSingleton: Example Code
public class Singleton {
// The private reference to the one and only instance.
private static Singleton uniqueInstance = null;
// An instance attribute.
private int data = 0;
/**
* Returns a reference to the single instance.
* Creates the instance if it does not yet exist.
*/
public static Singleton instance() {
if(uniqueInstance == null)
uniqueInstance = new Singleton();
return uniqueInstance;
}
/**
* The Singleton Constructor. Note that it is private!
* No client can instantiate a Singleton object!
*/
private Singleton() {}
}
Design Patterns – Eran Toch
26November 2003
Singleton: Example Code – cont’dSingleton: Example Code – cont’d
public class TestSingleton {
public static void main(String args[]) {
// Get a reference to the single instance of Singleton.
Singleton s = Singleton.instance();
// Set the data value.
s.setData(34);
System.out.println("First reference: " + s);
System.out.println("Singleton data value is: " + s.getData());
// Get another reference to the Singleton.
// Is it the same object?
s = null;
s = Singleton.instance();
System.out.println("nSecond reference: " + s);
System.out.println("Singleton data value is: " + s.getData());
}
}
What will be the output?
Design Patterns – Eran Toch
27November 2003
AgendaAgenda
• What is a Design Pattern?
• Structural Patterns
• Behavioral Patterns
• Creational Patterns
• Human Interaction Patterns
• Summary
Design Patterns – Eran Toch
28November 2003
Human Interaction PatternsHuman Interaction Patterns
• A Pattern language to describe human
interaction situations
• Examples:
– Go Back to a Safe Place
– Form
– Control Panel
– WYSIWYG Editor
– Hierarchical Set
– Map of Navigable Spaces
– More…
Design Patterns – Eran Toch
29November 2003
Go Back to a Safe PlaceGo Back to a Safe Place
• Problem:
– How can the artifact make navigation easy, convenient, and
psychologically safe for the user?
• Forces:
– A user may forget where they were, if they stop using the artifact
while they're in the middle of something and don't get back to it
for a while.
– If the user gets into a space or a state that they don't want to be
in, they will want to get out of it in a safe and predictable way.
– The user is more likely to explore an artifact if they are assured
that they can easily get out of an undesired state or space; that
assurance engenders a feeling of security.
Design Patterns – Eran Toch
30November 2003
Go Back to a Safe PlaceGo Back to a Safe Place
• Solution:
– Provide a way to go back to a checkpoint of the user's
choice.
• Examples:
– The "Home" button on a Web browser
– Turning back to the beginning of a chapter in a
physical book or magazine
– The “undo" feature on some computer applications
Design Patterns – Eran Toch
31November 2003
AgendaAgenda
• What is a Design Pattern?
• Structural Patterns
• Behavioral Patterns
• Creational Patterns
• Human Interaction Patterns
• Summary
Design Patterns – Eran Toch
32November 2003
SummarySummary
• Patterns learned:
– Composite, Strategy, Singleton, Go Back to a Safe
Place.
• Advantages of Design Patterns:
– They capture expertise and make it accessible to non-
experts.
– Their names collectively form a vocabulary that helps
developers communicate better.
– They help people understand a system more quickly
when it is documented with the patterns it uses.
Design Patterns – Eran Toch
33November 2003
ReferencesReferences
• Design Patterns: Elements of Reusable Object-Oriented
Software, Gamma E. et el., 1995, Addison-Wesley.
• A course from Bob Tarr from UMBC University
http://www.research.umbc.edu/~tarr/dp/fall00/cs491.html
• The Design Patterns Java Companion, James W. Cooper (an
online version of the book)
http://www.patterndepot.com/put/8/JavaPatterns.htm
• A Site dedicated to Design Patterns by Vince Huston
http://home.earthlink.net/~huston2/dp/patterns.html
• Seven Habits of Successful Pattern Writers, John Vlissides
http://hillside.net/patterns/papers/7habits.html
• COMMON GROUND: A Pattern Language for Human-
Computer Interface Design, Jenifer Tidwell,
http://www.mit.edu/~jtidwell/common_ground_onefile.html
Design Patterns – Eran Toch
34November 2003
Doesn’t it go too far?Doesn’t it go too far?
• Taken from Vince Huston’s site about Design
Patterns:
Design Patterns – Eran Toch
Methodologies in Information System Development
Thanks!Thanks!

Contenu connexe

En vedette

SW development process and the leading indicator
SW development process and the leading indicatorSW development process and the leading indicator
SW development process and the leading indicator
Jean Pаoli
 
Cohr managing stress training
Cohr managing stress trainingCohr managing stress training
Cohr managing stress training
Jean Pаoli
 
Effective prioritization & zbb
Effective prioritization & zbbEffective prioritization & zbb
Effective prioritization & zbb
Jean Pаoli
 
PMC post implementation review
PMC post implementation reviewPMC post implementation review
PMC post implementation review
Jean Pаoli
 
Diversity in thinking styles (part 1)
Diversity in thinking styles (part 1)Diversity in thinking styles (part 1)
Diversity in thinking styles (part 1)
Jean Pаoli
 

En vedette (8)

SW development process and the leading indicator
SW development process and the leading indicatorSW development process and the leading indicator
SW development process and the leading indicator
 
Cohr managing stress training
Cohr managing stress trainingCohr managing stress training
Cohr managing stress training
 
Effective prioritization & zbb
Effective prioritization & zbbEffective prioritization & zbb
Effective prioritization & zbb
 
PMC post implementation review
PMC post implementation reviewPMC post implementation review
PMC post implementation review
 
PMP study TTT
PMP study TTTPMP study TTT
PMP study TTT
 
Diversity in thinking styles (part 1)
Diversity in thinking styles (part 1)Diversity in thinking styles (part 1)
Diversity in thinking styles (part 1)
 
Pmp study: time
Pmp study: timePmp study: time
Pmp study: time
 
Unified process
Unified processUnified process
Unified process
 

Similaire à Design patterns

System architecture infosheet
System architecture infosheetSystem architecture infosheet
System architecture infosheet
jeanrummy
 
Design pattern in android
Design pattern in androidDesign pattern in android
Design pattern in android
Jay Kumarr
 

Similaire à Design patterns (20)

CS6201 Software Reuse - Design Patterns
CS6201 Software Reuse - Design PatternsCS6201 Software Reuse - Design Patterns
CS6201 Software Reuse - Design Patterns
 
dotnet stuff.com tutorials-design-patterns_exploring-net-design-patterns-in-s...
dotnet stuff.com tutorials-design-patterns_exploring-net-design-patterns-in-s...dotnet stuff.com tutorials-design-patterns_exploring-net-design-patterns-in-s...
dotnet stuff.com tutorials-design-patterns_exploring-net-design-patterns-in-s...
 
Design Patterns.ppt
Design Patterns.pptDesign Patterns.ppt
Design Patterns.ppt
 
CEN6016-Chapter1.ppt
CEN6016-Chapter1.pptCEN6016-Chapter1.ppt
CEN6016-Chapter1.ppt
 
CEN6016-Chapter1.ppt
CEN6016-Chapter1.pptCEN6016-Chapter1.ppt
CEN6016-Chapter1.ppt
 
System architecture infosheet
System architecture infosheetSystem architecture infosheet
System architecture infosheet
 
Patterns Overview
Patterns OverviewPatterns Overview
Patterns Overview
 
Software Design
Software DesignSoftware Design
Software Design
 
5-CEN6016-Chapter1.ppt
5-CEN6016-Chapter1.ppt5-CEN6016-Chapter1.ppt
5-CEN6016-Chapter1.ppt
 
Interaction design patterns
Interaction design patternsInteraction design patterns
Interaction design patterns
 
Designpattern
DesignpatternDesignpattern
Designpattern
 
Object-Oriented Analysis and Design
Object-Oriented Analysis and DesignObject-Oriented Analysis and Design
Object-Oriented Analysis and Design
 
Module 2 design patterns-2
Module 2   design patterns-2Module 2   design patterns-2
Module 2 design patterns-2
 
Design pattern in android
Design pattern in androidDesign pattern in android
Design pattern in android
 
1 modeling concepts
1 modeling concepts1 modeling concepts
1 modeling concepts
 
Design Pattern - Introduction
Design Pattern - IntroductionDesign Pattern - Introduction
Design Pattern - Introduction
 
Conversational AI from an Information Retrieval Perspective: Remaining Challe...
Conversational AI from an Information Retrieval Perspective: Remaining Challe...Conversational AI from an Information Retrieval Perspective: Remaining Challe...
Conversational AI from an Information Retrieval Perspective: Remaining Challe...
 
Usability and User Experience Training Seminar
Usability and User Experience Training SeminarUsability and User Experience Training Seminar
Usability and User Experience Training Seminar
 
Patterns - More than Mere Stencils
Patterns - More than Mere StencilsPatterns - More than Mere Stencils
Patterns - More than Mere Stencils
 
Knowledge mechanisms in IEEE 1471/ISO 42010
Knowledge mechanisms in IEEE 1471/ISO 42010Knowledge mechanisms in IEEE 1471/ISO 42010
Knowledge mechanisms in IEEE 1471/ISO 42010
 

Dernier

RT Nagar Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Bang...
RT Nagar Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Bang...RT Nagar Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Bang...
RT Nagar Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Bang...
amitlee9823
 
Call Girls Basavanagudi Just Call 👗 7737669865 👗 Top Class Call Girl Service ...
Call Girls Basavanagudi Just Call 👗 7737669865 👗 Top Class Call Girl Service ...Call Girls Basavanagudi Just Call 👗 7737669865 👗 Top Class Call Girl Service ...
Call Girls Basavanagudi Just Call 👗 7737669865 👗 Top Class Call Girl Service ...
amitlee9823
 
Escorts Service Nagavara ☎ 7737669865☎ Book Your One night Stand (Bangalore)
Escorts Service Nagavara ☎ 7737669865☎ Book Your One night Stand (Bangalore)Escorts Service Nagavara ☎ 7737669865☎ Book Your One night Stand (Bangalore)
Escorts Service Nagavara ☎ 7737669865☎ Book Your One night Stand (Bangalore)
amitlee9823
 
Abortion Pills in Oman (+918133066128) Cytotec clinic buy Oman Muscat
Abortion Pills in Oman (+918133066128) Cytotec clinic buy Oman MuscatAbortion Pills in Oman (+918133066128) Cytotec clinic buy Oman Muscat
Abortion Pills in Oman (+918133066128) Cytotec clinic buy Oman Muscat
Abortion pills in Kuwait Cytotec pills in Kuwait
 
Vip Mumbai Call Girls Bandra West Call On 9920725232 With Body to body massag...
Vip Mumbai Call Girls Bandra West Call On 9920725232 With Body to body massag...Vip Mumbai Call Girls Bandra West Call On 9920725232 With Body to body massag...
Vip Mumbai Call Girls Bandra West Call On 9920725232 With Body to body massag...
amitlee9823
 
How to Build a Simple Shopify Website
How to Build a Simple Shopify WebsiteHow to Build a Simple Shopify Website
How to Build a Simple Shopify Website
mark11275
 
➥🔝 7737669865 🔝▻ dehradun Call-girls in Women Seeking Men 🔝dehradun🔝 Escor...
➥🔝 7737669865 🔝▻ dehradun Call-girls in Women Seeking Men  🔝dehradun🔝   Escor...➥🔝 7737669865 🔝▻ dehradun Call-girls in Women Seeking Men  🔝dehradun🔝   Escor...
➥🔝 7737669865 🔝▻ dehradun Call-girls in Women Seeking Men 🔝dehradun🔝 Escor...
amitlee9823
 
Anupama Kundoo Cost Effective detailed ppt with plans and elevations with det...
Anupama Kundoo Cost Effective detailed ppt with plans and elevations with det...Anupama Kundoo Cost Effective detailed ppt with plans and elevations with det...
Anupama Kundoo Cost Effective detailed ppt with plans and elevations with det...
sriharipichandi
 
Nisha Yadav Escorts Service Ernakulam ❣️ 7014168258 ❣️ High Cost Unlimited Ha...
Nisha Yadav Escorts Service Ernakulam ❣️ 7014168258 ❣️ High Cost Unlimited Ha...Nisha Yadav Escorts Service Ernakulam ❣️ 7014168258 ❣️ High Cost Unlimited Ha...
Nisha Yadav Escorts Service Ernakulam ❣️ 7014168258 ❣️ High Cost Unlimited Ha...
nirzagarg
 

Dernier (20)

Hire 💕 8617697112 Meerut Call Girls Service Call Girls Agency
Hire 💕 8617697112 Meerut Call Girls Service Call Girls AgencyHire 💕 8617697112 Meerut Call Girls Service Call Girls Agency
Hire 💕 8617697112 Meerut Call Girls Service Call Girls Agency
 
RT Nagar Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Bang...
RT Nagar Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Bang...RT Nagar Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Bang...
RT Nagar Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Bang...
 
8377087607, Door Step Call Girls In Majnu Ka Tilla (Delhi) 24/7 Available
8377087607, Door Step Call Girls In Majnu Ka Tilla (Delhi) 24/7 Available8377087607, Door Step Call Girls In Majnu Ka Tilla (Delhi) 24/7 Available
8377087607, Door Step Call Girls In Majnu Ka Tilla (Delhi) 24/7 Available
 
Call Girls Basavanagudi Just Call 👗 7737669865 👗 Top Class Call Girl Service ...
Call Girls Basavanagudi Just Call 👗 7737669865 👗 Top Class Call Girl Service ...Call Girls Basavanagudi Just Call 👗 7737669865 👗 Top Class Call Girl Service ...
Call Girls Basavanagudi Just Call 👗 7737669865 👗 Top Class Call Girl Service ...
 
Escorts Service Nagavara ☎ 7737669865☎ Book Your One night Stand (Bangalore)
Escorts Service Nagavara ☎ 7737669865☎ Book Your One night Stand (Bangalore)Escorts Service Nagavara ☎ 7737669865☎ Book Your One night Stand (Bangalore)
Escorts Service Nagavara ☎ 7737669865☎ Book Your One night Stand (Bangalore)
 
Abortion Pills in Oman (+918133066128) Cytotec clinic buy Oman Muscat
Abortion Pills in Oman (+918133066128) Cytotec clinic buy Oman MuscatAbortion Pills in Oman (+918133066128) Cytotec clinic buy Oman Muscat
Abortion Pills in Oman (+918133066128) Cytotec clinic buy Oman Muscat
 
Hingoli ❤CALL GIRL 8617370543 ❤CALL GIRLS IN Hingoli ESCORT SERVICE❤CALL GIRL
Hingoli ❤CALL GIRL 8617370543 ❤CALL GIRLS IN Hingoli ESCORT SERVICE❤CALL GIRLHingoli ❤CALL GIRL 8617370543 ❤CALL GIRLS IN Hingoli ESCORT SERVICE❤CALL GIRL
Hingoli ❤CALL GIRL 8617370543 ❤CALL GIRLS IN Hingoli ESCORT SERVICE❤CALL GIRL
 
❤Personal Whatsapp Number 8617697112 Samba Call Girls 💦✅.
❤Personal Whatsapp Number 8617697112 Samba Call Girls 💦✅.❤Personal Whatsapp Number 8617697112 Samba Call Girls 💦✅.
❤Personal Whatsapp Number 8617697112 Samba Call Girls 💦✅.
 
Sector 105, Noida Call girls :8448380779 Model Escorts | 100% verified
Sector 105, Noida Call girls :8448380779 Model Escorts | 100% verifiedSector 105, Noida Call girls :8448380779 Model Escorts | 100% verified
Sector 105, Noida Call girls :8448380779 Model Escorts | 100% verified
 
Gamestore case study UI UX by Amgad Ibrahim
Gamestore case study UI UX by Amgad IbrahimGamestore case study UI UX by Amgad Ibrahim
Gamestore case study UI UX by Amgad Ibrahim
 
Vip Mumbai Call Girls Bandra West Call On 9920725232 With Body to body massag...
Vip Mumbai Call Girls Bandra West Call On 9920725232 With Body to body massag...Vip Mumbai Call Girls Bandra West Call On 9920725232 With Body to body massag...
Vip Mumbai Call Girls Bandra West Call On 9920725232 With Body to body massag...
 
Just Call Vip call girls Nagpur Escorts ☎️8617370543 Starting From 5K to 25K ...
Just Call Vip call girls Nagpur Escorts ☎️8617370543 Starting From 5K to 25K ...Just Call Vip call girls Nagpur Escorts ☎️8617370543 Starting From 5K to 25K ...
Just Call Vip call girls Nagpur Escorts ☎️8617370543 Starting From 5K to 25K ...
 
8377087607, Door Step Call Girls In Kalkaji (Locanto) 24/7 Available
8377087607, Door Step Call Girls In Kalkaji (Locanto) 24/7 Available8377087607, Door Step Call Girls In Kalkaji (Locanto) 24/7 Available
8377087607, Door Step Call Girls In Kalkaji (Locanto) 24/7 Available
 
How to Build a Simple Shopify Website
How to Build a Simple Shopify WebsiteHow to Build a Simple Shopify Website
How to Build a Simple Shopify Website
 
Q4-W4-SCIENCE-5 power point presentation
Q4-W4-SCIENCE-5 power point presentationQ4-W4-SCIENCE-5 power point presentation
Q4-W4-SCIENCE-5 power point presentation
 
The hottest UI and UX Design Trends 2024
The hottest UI and UX Design Trends 2024The hottest UI and UX Design Trends 2024
The hottest UI and UX Design Trends 2024
 
➥🔝 7737669865 🔝▻ dehradun Call-girls in Women Seeking Men 🔝dehradun🔝 Escor...
➥🔝 7737669865 🔝▻ dehradun Call-girls in Women Seeking Men  🔝dehradun🔝   Escor...➥🔝 7737669865 🔝▻ dehradun Call-girls in Women Seeking Men  🔝dehradun🔝   Escor...
➥🔝 7737669865 🔝▻ dehradun Call-girls in Women Seeking Men 🔝dehradun🔝 Escor...
 
Call Girls Jalgaon Just Call 8617370543Top Class Call Girl Service Available
Call Girls Jalgaon Just Call 8617370543Top Class Call Girl Service AvailableCall Girls Jalgaon Just Call 8617370543Top Class Call Girl Service Available
Call Girls Jalgaon Just Call 8617370543Top Class Call Girl Service Available
 
Anupama Kundoo Cost Effective detailed ppt with plans and elevations with det...
Anupama Kundoo Cost Effective detailed ppt with plans and elevations with det...Anupama Kundoo Cost Effective detailed ppt with plans and elevations with det...
Anupama Kundoo Cost Effective detailed ppt with plans and elevations with det...
 
Nisha Yadav Escorts Service Ernakulam ❣️ 7014168258 ❣️ High Cost Unlimited Ha...
Nisha Yadav Escorts Service Ernakulam ❣️ 7014168258 ❣️ High Cost Unlimited Ha...Nisha Yadav Escorts Service Ernakulam ❣️ 7014168258 ❣️ High Cost Unlimited Ha...
Nisha Yadav Escorts Service Ernakulam ❣️ 7014168258 ❣️ High Cost Unlimited Ha...
 

Design patterns

  • 1. Design Patterns – Eran Toch Methodologies in Information System Development Design Patterns:Design Patterns: Talking in the Design LanguageTalking in the Design Language Eran Toch Methodologies in the Development of Information Systems
  • 2. Design Patterns – Eran Toch 2November 2003 AgendaAgenda • What is a Design Pattern? • Structural Patterns – The Composite Pattern • Behavioral Patterns – The Strategy Pattern • Creational Patterns – The Singleton Pattern • Human Interaction Patterns – Go Back to a Safe Place • Summary
  • 3. Design Patterns – Eran Toch 3November 2003 What is a Design Pattern?What is a Design Pattern? In Short, a solution for a typical problem “a description of a recurrent problem and of the core of possible solutions.“
  • 4. Design Patterns – Eran Toch 4November 2003 Why do we need them?Why do we need them? • Problems are not always unique. Reusing existing experience might be proved useful. • We need a common language to describe problems and solutions. • The Design of Object-Oriented systems limits the scope of problems and solutions we can talk about
  • 5. Design Patterns – Eran Toch 5November 2003 History of Design PatternsHistory of Design Patterns Christopher Alexander A Pattern Language: Towns, Buildings Construction 1970’ 1995’ 2000’ Architecture Object Oriented Software Design Other Areas: HCI, Organizational Behavior… Gang of Four (GoF) Design Patterns: Elements of Reusable Object-Oriented Software Many Authors
  • 6. Design Patterns – Eran Toch 6November 2003 Structure of a design patternStructure of a design pattern • Pattern Name and Classification • Intent – a Short statement about what the pattern does • Motivation – A scenario that illustrates where the pattern would be useful • Applicability – Situations where the pattern can be used
  • 7. Design Patterns – Eran Toch 7November 2003 Structure of a design pattern – cont’dStructure of a design pattern – cont’d • Structure – A graphical representation of the pattern • Participants – The classes and objects participating in the pattern • Collaborations – How to do the participants interact to carry out their responsibilities? • Consequences – What are the pros and cons of using the pattern? • Implementation – Hints and techniques for implementing the pattern
  • 8. Design Patterns – Eran Toch 8November 2003 Classification of patternsClassification of patterns • Structural – Composite*, Decorator, Façade, Adapter… • Behavioral – Strategy*, Command, Observer, Chain of Responsibilities… • Creational – Singleton*, Abstract Factory, Factory Method… • Other – User interface Patterns • Go Back to a Safe Place
  • 9. Design Patterns – Eran Toch 9November 2003 AgendaAgenda • What is a Design Pattern? • Structural Patterns • Behavioral Patterns • Creational Patterns • Human Interaction Patterns • Summary
  • 10. Design Patterns – Eran Toch 10November 2003 The Composite PatternThe Composite Pattern • Intent: – Compose objects into tree structures to represent part-whole hierarchies. – Composite lets clients treat individual objects and compositions of objects uniformly. This is called recursive composition.
  • 11. Design Patterns – Eran Toch 11November 2003 MotivationMotivation When Processing the hierarchal collection, we need to query the type of the object (composite or primitive) and act differently Diagram reference: Design Patterns [Gof]
  • 12. Design Patterns – Eran Toch 12November 2003 Composite: ApplicabilityComposite: Applicability • Use the Composite pattern when: – You want to represent part-whole hierarchies of objects. – You want clients to be able to ignore the difference between compositions of objects and individual objects. Clients will treat all objects in the composite structure uniformly.
  • 13. Design Patterns – Eran Toch 13November 2003 Composite: StructureComposite: Structure • Define an abstract base class that specifies the uniform behavior. • Subclass the Primitive and Composite classes of the Component class. Diagram reference: Design Patterns [Gof]
  • 14. Design Patterns – Eran Toch 14November 2003 Composite: ConsequencesComposite: Consequences • Benefits – It makes it easy to add new kinds of components – It makes clients simpler, since they do not have to know if they are dealing with a leaf or a composite component • Liabilities – It makes it harder to restrict the type of components of a composite
  • 15. Design Patterns – Eran Toch 15November 2003 Composite: Known UsesComposite: Known Uses 1. A GUI system has window objects which can contain various GUI components (widgets) such as, buttons and text areas. A window can also contain widget container objects which can hold other widgets. Concrete examples: Java Swing, MFC 2. Folder based file system 3. Arithmetic expressions
  • 16. Design Patterns – Eran Toch 16November 2003 AgendaAgenda • What is a Design Pattern? • Structural Patterns • Behavioral Patterns • Creational Patterns • Human Interaction Patterns • Summary
  • 17. Design Patterns – Eran Toch 17November 2003 The Strategy PatternThe Strategy Pattern • Intent: – Define a family of algorithms, encapsulate each one, and make them interchangeable. – Strategy lets the algorithm vary independently from clients that use it.
  • 18. Design Patterns – Eran Toch 18November 2003 Strategy: MotivationStrategy: Motivation The client wants to use the algorithm without knowing which one to use in advance. We want to add new algorithms without changing the client class.
  • 19. Design Patterns – Eran Toch 19November 2003 Strategy: StructureStrategy: Structure • Encapsulate the behavior of the context class in a separate algorithm class. • The context class keeps a reference to the algorithm class and passes on the messages. • The algorithm class can be sub-classed to support multiple algorithms.
  • 20. Design Patterns – Eran Toch 20November 2003 Strategy: ConsequencesStrategy: Consequences • Benefits – Provides an alternative to subclassing the Context class to get a variety of algorithms or behaviors – Keeps the client clean from large conditional statements – Provides a choice of implementations for the same behavior • Liabilities – Increases the number of objects – All algorithms must use the same Strategy interface – We still need conditional statements!
  • 21. Design Patterns – Eran Toch 21November 2003 Strategy: Known UsesStrategy: Known Uses • QSIA Learning System • Layout Manager in Java Swing • Sorting algorithms, memory allocation algorithms and more…
  • 22. Design Patterns – Eran Toch 22November 2003 AgendaAgenda • What is a Design Pattern? • Structural Patterns • Behavioral Patterns • Creational Patterns • Human Interaction Patterns • Summary
  • 23. Design Patterns – Eran Toch 23November 2003 The Singleton PatternThe Singleton Pattern • Intent. – Ensure a class only has one instance, and provide a global point of access to it. • Motivation. – Sometimes, an application needs one, and only one, instance of an object. For example, we want just one window manager. Or just one factory for a family of products. – We need to have that one instance easily accessible. – And we want to ensure that additional instances of the class can not be created.
  • 24. Design Patterns – Eran Toch 24November 2003 Singleton: StructureSingleton: Structure • Declare the single instance as a private static data member. • Provide a public static member function that encapsulates all initialization code, and provides access to the instance.
  • 25. Design Patterns – Eran Toch 25November 2003 Singleton: Example CodeSingleton: Example Code public class Singleton { // The private reference to the one and only instance. private static Singleton uniqueInstance = null; // An instance attribute. private int data = 0; /** * Returns a reference to the single instance. * Creates the instance if it does not yet exist. */ public static Singleton instance() { if(uniqueInstance == null) uniqueInstance = new Singleton(); return uniqueInstance; } /** * The Singleton Constructor. Note that it is private! * No client can instantiate a Singleton object! */ private Singleton() {} }
  • 26. Design Patterns – Eran Toch 26November 2003 Singleton: Example Code – cont’dSingleton: Example Code – cont’d public class TestSingleton { public static void main(String args[]) { // Get a reference to the single instance of Singleton. Singleton s = Singleton.instance(); // Set the data value. s.setData(34); System.out.println("First reference: " + s); System.out.println("Singleton data value is: " + s.getData()); // Get another reference to the Singleton. // Is it the same object? s = null; s = Singleton.instance(); System.out.println("nSecond reference: " + s); System.out.println("Singleton data value is: " + s.getData()); } } What will be the output?
  • 27. Design Patterns – Eran Toch 27November 2003 AgendaAgenda • What is a Design Pattern? • Structural Patterns • Behavioral Patterns • Creational Patterns • Human Interaction Patterns • Summary
  • 28. Design Patterns – Eran Toch 28November 2003 Human Interaction PatternsHuman Interaction Patterns • A Pattern language to describe human interaction situations • Examples: – Go Back to a Safe Place – Form – Control Panel – WYSIWYG Editor – Hierarchical Set – Map of Navigable Spaces – More…
  • 29. Design Patterns – Eran Toch 29November 2003 Go Back to a Safe PlaceGo Back to a Safe Place • Problem: – How can the artifact make navigation easy, convenient, and psychologically safe for the user? • Forces: – A user may forget where they were, if they stop using the artifact while they're in the middle of something and don't get back to it for a while. – If the user gets into a space or a state that they don't want to be in, they will want to get out of it in a safe and predictable way. – The user is more likely to explore an artifact if they are assured that they can easily get out of an undesired state or space; that assurance engenders a feeling of security.
  • 30. Design Patterns – Eran Toch 30November 2003 Go Back to a Safe PlaceGo Back to a Safe Place • Solution: – Provide a way to go back to a checkpoint of the user's choice. • Examples: – The "Home" button on a Web browser – Turning back to the beginning of a chapter in a physical book or magazine – The “undo" feature on some computer applications
  • 31. Design Patterns – Eran Toch 31November 2003 AgendaAgenda • What is a Design Pattern? • Structural Patterns • Behavioral Patterns • Creational Patterns • Human Interaction Patterns • Summary
  • 32. Design Patterns – Eran Toch 32November 2003 SummarySummary • Patterns learned: – Composite, Strategy, Singleton, Go Back to a Safe Place. • Advantages of Design Patterns: – They capture expertise and make it accessible to non- experts. – Their names collectively form a vocabulary that helps developers communicate better. – They help people understand a system more quickly when it is documented with the patterns it uses.
  • 33. Design Patterns – Eran Toch 33November 2003 ReferencesReferences • Design Patterns: Elements of Reusable Object-Oriented Software, Gamma E. et el., 1995, Addison-Wesley. • A course from Bob Tarr from UMBC University http://www.research.umbc.edu/~tarr/dp/fall00/cs491.html • The Design Patterns Java Companion, James W. Cooper (an online version of the book) http://www.patterndepot.com/put/8/JavaPatterns.htm • A Site dedicated to Design Patterns by Vince Huston http://home.earthlink.net/~huston2/dp/patterns.html • Seven Habits of Successful Pattern Writers, John Vlissides http://hillside.net/patterns/papers/7habits.html • COMMON GROUND: A Pattern Language for Human- Computer Interface Design, Jenifer Tidwell, http://www.mit.edu/~jtidwell/common_ground_onefile.html
  • 34. Design Patterns – Eran Toch 34November 2003 Doesn’t it go too far?Doesn’t it go too far? • Taken from Vince Huston’s site about Design Patterns:
  • 35. Design Patterns – Eran Toch Methodologies in Information System Development Thanks!Thanks!