1
Presented by:
- Nozha KANNOUF
- Safaâ ELOUAHABI
- Sanae BEKKAR
Supervised by:
Mr. ABDALAOUI
Introduction to DesignIntroduction to Design
PatternPattern
Oujda Med First University
National College of Applied Sciences
Department of Computer Engineering
Introduction
02/06/2007 2
PlanPlan
Why design patterns ?
What is a design patterns ?
The patterns elements
Types of design patterns
Describing design patterns
The catalog of design patterns
Examples of design patterns
Conclusion
30/04/2009 3
WhyWhy Design Patterns?Design Patterns?
The DP satisfy this need for good ,simple and reusable solutions.
DP catalog common interactions between objects that
programmers have often found useful.
02/06/2007 4
Difficulties of ObjectDifficulties of Object--Oriented DesignOriented Design
Oriented-Object Design
find pertinent objects,
factor them into classes at the right granularity,
define class interfaces and inheritance hierarchies,
and establish key relationships among them.
02/06/2007 5
Difficulties of ObjectDifficulties of Object--Oriented DesignOriented Design
A reusable and flexible design is difficult if not
impossible to get “right” the first time.
Experienced OO designers do make good designs.
Whereas , New designers are overwhelmed by the
options available and tend to fall back on non-OO
techniques they’ve used before.
What’s their difference?
02/06/2007 6
PatternsPatterns
When they find a good solution, they use it
again and again – pattern.
A designer who is familiar with such patterns
can apply them immediately to design
problems without having to rediscover them.
02/06/2007 7
What is a design pattern?What is a design pattern?
02/06/2007 8
Design patternsDesign patterns
"Each pattern describes a problem which
occurs over and over again in our
environment, and then describes the core of
the solution to that problem, in such a way
that you can use this solution a million times
over, without ever doing it the same way
twice"
[Christopher Alexander]
02/06/2007 9
Design PatternDesign Pattern
Design patterns are class combinations and
accompanying algorithms that fulfill common design
purposes.
Design patterns are descriptions of communicating
objects and classes that are customized to solve a general
design problem in a particular context.
02/06/2007 10
In software engineering, a design pattern is a general
reusable solution to a commonly occurring problem in
software design. A design pattern is not a finished design
that can be transformed directly into code. It is a
description or template for how to solve a problem that
can be used in many different situations. Object-oriented
design patterns typically show relationships and
interactions between classes or objects, without specifying
the final application classes or objects that are involved
The essential elements of a patternThe essential elements of a pattern
02/06/2007 12
Pattern elementsPattern elements
Name
A meaningful pattern identifier
Problem description
When to apply the pattern
Solution description
Elements that make up the pattern, their relationships,
responsibilities, and collaborations.
Consequences
The results and trade-offs of applying the pattern
02/06/2007 13
Types of design patternTypes of design pattern
02/06/2007 14
Types of Design PatternsTypes of Design Patterns
Creational patterns
Creating a collection of objects in flexible ways.
Structural patterns
Representing a collection of related objects.
Behavioral patterns
Capturing behavior among a collection of objects.
02/06/2007 15
Describing Design PatternsDescribing Design Patterns
02/06/2007 16
Describing Design PatternsDescribing Design Patterns
Intent
short description of the pattern & its purpose
Also Known As
Any aliases this pattern is known by
Motivation
motivating scenario demonstrating pattern’s use
Applicability
circumstances in which pattern applies
Structure
graphical representation of the pattern using modified UML notation
Participants
participating classes and/or objects & their responsibilities
02/06/2007 17
Describing Design PatternsDescribing Design Patterns
Collaborations
how participants cooperate to carry out their responsibilities
Consequences
the results of application, benefits, liabilities
Implementation
pitfalls, hints, techniques, plus language-dependent issues
Sample Code
sample implementations in C++, Java, C#, Smalltalk, C, etc.
Known Uses
examples drawn from existing systems
Related Patterns
discussion of other patterns that relate to this one
02/06/2007 18
The Catalog of Design Patterns
02/06/2007 19
The Catalog of Design Patterns
Two criteria
Purpose: what a pattern does
Creational: concern the process of object creation
Structural: the composition of classes or objects
Behavioral: characterize the ways in which classes or objects
interact and distribute responsibility
Scope: whether the pattern applies primarily to
classes or to objects
02/06/2007 20
The Catalog of Design Patterns
02/06/2007 21
Examples of design patternsExamples of design patterns
02/06/2007 22
23
Intent
create families of related objects without specifying subclass names
Applicability
when clients cannot anticipate groups of classes to instantiate
ABSTRACT FACTORY object creational
02/06/2007 24
Structure
Intent
"compose" objects into tree structures to represent part-whole
hierarchies.
Applicability
when clients should ignore the difference between
compositions of objects and individual objects
02/06/2007 25
COMPOSITE object structural
02/06/2007 26
Structure
Intent
encapsulate the request for a service
Applicability
to parameterize objects with an action to perform
to specify, file, & execute requests at different times.
02/06/2007 27
Cammand/1 (object behavioral)
28
Structure
But…
02/06/2007 29
02/06/2007 30
1.Do not lead to direct code reuse
2. Complex in nature
3. They are deceptively simple
4. They are validated by experience and discussion
5. They consume more memory because of generalized
format they are written, to store any kind of data
6. Design patterns may increase or decrease the
understandability of a design or implementation
References and related resource
[Knuth] Computer Programming as an Art.
http://fresh.homeunix.net/~luke/misc/knuth-turingaward.pdf
[Columbia] Code convention.
http://nsl.cs.columbia.edu/projects/projects.html
Design pattern catalog.
http://www.dofactory.com/Patterns/Patterns.aspx#list
Introduction to Software Engineering
http://sunset.usc.edu/classes/cs377_2004/

Introduction to Design Pattern

  • 1.
    1 Presented by: - NozhaKANNOUF - Safaâ ELOUAHABI - Sanae BEKKAR Supervised by: Mr. ABDALAOUI Introduction to DesignIntroduction to Design PatternPattern Oujda Med First University National College of Applied Sciences Department of Computer Engineering
  • 2.
  • 3.
    PlanPlan Why design patterns? What is a design patterns ? The patterns elements Types of design patterns Describing design patterns The catalog of design patterns Examples of design patterns Conclusion 30/04/2009 3
  • 4.
    WhyWhy Design Patterns?DesignPatterns? The DP satisfy this need for good ,simple and reusable solutions. DP catalog common interactions between objects that programmers have often found useful. 02/06/2007 4
  • 5.
    Difficulties of ObjectDifficultiesof Object--Oriented DesignOriented Design Oriented-Object Design find pertinent objects, factor them into classes at the right granularity, define class interfaces and inheritance hierarchies, and establish key relationships among them. 02/06/2007 5
  • 6.
    Difficulties of ObjectDifficultiesof Object--Oriented DesignOriented Design A reusable and flexible design is difficult if not impossible to get “right” the first time. Experienced OO designers do make good designs. Whereas , New designers are overwhelmed by the options available and tend to fall back on non-OO techniques they’ve used before. What’s their difference? 02/06/2007 6
  • 7.
    PatternsPatterns When they finda good solution, they use it again and again – pattern. A designer who is familiar with such patterns can apply them immediately to design problems without having to rediscover them. 02/06/2007 7
  • 8.
    What is adesign pattern?What is a design pattern? 02/06/2007 8
  • 9.
    Design patternsDesign patterns "Eachpattern describes a problem which occurs over and over again in our environment, and then describes the core of the solution to that problem, in such a way that you can use this solution a million times over, without ever doing it the same way twice" [Christopher Alexander] 02/06/2007 9
  • 10.
    Design PatternDesign Pattern Designpatterns are class combinations and accompanying algorithms that fulfill common design purposes. Design patterns are descriptions of communicating objects and classes that are customized to solve a general design problem in a particular context. 02/06/2007 10
  • 11.
    In software engineering,a design pattern is a general reusable solution to a commonly occurring problem in software design. A design pattern is not a finished design that can be transformed directly into code. It is a description or template for how to solve a problem that can be used in many different situations. Object-oriented design patterns typically show relationships and interactions between classes or objects, without specifying the final application classes or objects that are involved
  • 12.
    The essential elementsof a patternThe essential elements of a pattern 02/06/2007 12
  • 13.
    Pattern elementsPattern elements Name Ameaningful pattern identifier Problem description When to apply the pattern Solution description Elements that make up the pattern, their relationships, responsibilities, and collaborations. Consequences The results and trade-offs of applying the pattern 02/06/2007 13
  • 14.
    Types of designpatternTypes of design pattern 02/06/2007 14
  • 15.
    Types of DesignPatternsTypes of Design Patterns Creational patterns Creating a collection of objects in flexible ways. Structural patterns Representing a collection of related objects. Behavioral patterns Capturing behavior among a collection of objects. 02/06/2007 15
  • 16.
    Describing Design PatternsDescribingDesign Patterns 02/06/2007 16
  • 17.
    Describing Design PatternsDescribingDesign Patterns Intent short description of the pattern & its purpose Also Known As Any aliases this pattern is known by Motivation motivating scenario demonstrating pattern’s use Applicability circumstances in which pattern applies Structure graphical representation of the pattern using modified UML notation Participants participating classes and/or objects & their responsibilities 02/06/2007 17
  • 18.
    Describing Design PatternsDescribingDesign Patterns Collaborations how participants cooperate to carry out their responsibilities Consequences the results of application, benefits, liabilities Implementation pitfalls, hints, techniques, plus language-dependent issues Sample Code sample implementations in C++, Java, C#, Smalltalk, C, etc. Known Uses examples drawn from existing systems Related Patterns discussion of other patterns that relate to this one 02/06/2007 18
  • 19.
    The Catalog ofDesign Patterns 02/06/2007 19
  • 20.
    The Catalog ofDesign Patterns Two criteria Purpose: what a pattern does Creational: concern the process of object creation Structural: the composition of classes or objects Behavioral: characterize the ways in which classes or objects interact and distribute responsibility Scope: whether the pattern applies primarily to classes or to objects 02/06/2007 20
  • 21.
    The Catalog ofDesign Patterns 02/06/2007 21
  • 22.
    Examples of designpatternsExamples of design patterns 02/06/2007 22
  • 23.
    23 Intent create families ofrelated objects without specifying subclass names Applicability when clients cannot anticipate groups of classes to instantiate ABSTRACT FACTORY object creational
  • 24.
  • 25.
    Intent "compose" objects intotree structures to represent part-whole hierarchies. Applicability when clients should ignore the difference between compositions of objects and individual objects 02/06/2007 25 COMPOSITE object structural
  • 26.
  • 27.
    Intent encapsulate the requestfor a service Applicability to parameterize objects with an action to perform to specify, file, & execute requests at different times. 02/06/2007 27 Cammand/1 (object behavioral)
  • 28.
  • 29.
  • 30.
    02/06/2007 30 1.Do notlead to direct code reuse 2. Complex in nature 3. They are deceptively simple 4. They are validated by experience and discussion 5. They consume more memory because of generalized format they are written, to store any kind of data 6. Design patterns may increase or decrease the understandability of a design or implementation
  • 31.
    References and relatedresource [Knuth] Computer Programming as an Art. http://fresh.homeunix.net/~luke/misc/knuth-turingaward.pdf [Columbia] Code convention. http://nsl.cs.columbia.edu/projects/projects.html Design pattern catalog. http://www.dofactory.com/Patterns/Patterns.aspx#list Introduction to Software Engineering http://sunset.usc.edu/classes/cs377_2004/