Design Patterns Elements of Reusable Object-Oriented Software
Design Patterns Elements of Reusable Object-Oriented Software
Introduction
Design Patterns
Elements of Reusable Object-Oriented Software
Design Pattern
Solutions to commonly occurring
problems in object oriented
programming.
2
Purpose of Design Pattern
4
Describing Design Patterns
How patterns are described in the book of GOF
Pattern Name and Classification
Intent
Also Known As
Motivation
Applicability
Structure
Participants
5
Describing Design Patterns
(contd.)
Collaborations
Consequences
Implementation
Sample Code
Known Uses
Related Patterns
6
Design pattern
How many design patterns?
- hundreds of patterns are available
- The 23 design patterns by GOF are
well known
- more are to be discovered on the way
7
Classification of Design
Patterns
Design patterns are classified based on two criteria
Purpose reflects what a pattern does
Creational concern the process of object creation
Structural deal with the composition of classes or objects
Behavioral characterize the ways in which classes or
objects interact and distribute responsibility
9
Guide to Notation
Appendix B + Chapter 1
Guide to Notation
Three different diagrammatic notations are used
A class diagram depicts classes, their structure,
and the static relationships between them
An object diagram depicts a particular object
structure at run-time
An interaction diagram shows the flow of requests
between objects
11
Class Diagram (1)
Abstract and concrete classes
Relationships between classes (uses different
symbols)
Inheritance (triangle)
Part-of or aggregation (arrowheaded line with a
diamond at the base)
Acquaintance (arrowheaded line without diamond)
Creates (dashed arrowheaded line)
Reference to single or multiple objects (filled
circle)
Pseudocode annotations
12
Class Diagram (2)
AbstractClassName
AbstractOperation1()
Type AbstractOperation2()
ConcreteClassName
Operation1()
Type Operation2()
instanceVariable1
Type instanceVariable2
Inheritance
Aggregation
Creates Acquaintance
Class Relationships 14
Class Diagram (4)
Drawing
for each shape {
Draw() shape->Draw()
}
Pseudocode annotation 15
Object Diagram (1)
Shows instances exclusively
Provides a snapshot of the objects in a design
pattern
The objects are named aSomething, where
Something is the class of the object
16
Object Diagram (2)
aDrawing
shape[0]
shape[1]
aLineShape aCircleShape
18
Interaction Diagram (2)
aCreationTool aDrawing aLineShape
new LineShape
Add(aLineShape)
Refresh()
Draw()
20
Acknowledgement
Sajjadur Rahman Sunny
http://teacher.buet.ac.bd/sunnysajjad/
21