Design Patterns: Dr. Mani Sarma - Vittapu
Design Patterns: Dr. Mani Sarma - Vittapu
Design Patterns: Dr. Mani Sarma - Vittapu
TEXT BOOKS:
1.Design Pattern by Erich Gamma, Pearson Education
2.Pattern’s in JAVA Vol-I BY Mark Grand, Wiley DreamTech
3.Pattern’s in JAVA Vol-II BY Mark Grand, Wiley DreamTech
4.JAVA Enterprise Design Patterns Vol-III Mark Grand, Wiley
Dream Tech
5.Head First Design Patterns By Eric Freeman-Oreilly-spd..
6.Design Patterns Explained By Alan Shalloway,Pearson Education
Overview of Design Patterns 1
1 What is Design Pattern?
2 Design Patterns in Smalltalk MVC
3 Describing Design Patterns
4 The catalog of Design Patterns
5 Organizing the catalog
6 How Design Patterns Solve Design Problems
7 How to select Design Patterns
8 How to Use a Design Pattern
Design Patterns
Design Patterns in
smalltalkMVC
The below diagram shows a model and three views.
The model contains some data values, and the views
defining a spreadsheet, histogram, and pie chart
display these data in various ways.
The model communicates with it’s values change,
and the views communicate with the model to access
these values.
Feature of MVC is that views can be nested.
Easy to maintain and enhancement.
Overview of Design Patterns 13
L2
Design Patterns in
smalltalkMVC
Relative Percentages
A B C D
A
X 15 35 35 15 D
Y 10 40 30 20 B
C
Z 10 40 30 20
A B C D
A=10%
B=40%
C=30% Application data
Change notification
D=20%
Requests, modifications
Overview of Design Patterns 14
L3
Participants:
The classes and/or objects participating in the design
pattern and their responsibilities.
Overview of Design Patterns 17
L3
• Creational Patterns
• Abstract Factory Creates an instance of several
families of classes
• Builder Separates object construction from its
representation
• Factory Method Creates an instance of several
derived classes
• Prototype A fully initialized instance to be copied
or cloned
• Singleton A class of which only a single instance
can exist
Overview of Design Patterns 32
Summary of Catalog of design patterns
• Structural Patterns
• Adapter Match interfaces of different classes
• Bridge Separates an object’s interface from its
implementation
• Composite A tree structure of simple and composite
objects
• Decorator Add responsibilities to objects dynamically
• Facade A single class that represents an entire
subsystem
• Flyweight A fine-grained instance used for efficient
sharing
• Proxy An object representing another object
t
single Abstract Factory implemen
instance using
Singleton single Facade
instance
Overview of Design Patterns 43
L6
Program to an interface,
not an implementation
• Manipulate objects solely in terms of interfaces
defined by abstract classes!
• Benefits:
1. Clients remain unaware of the specific types of objects they use.
2. Clients remain unaware of the classes that implement the objects.
Clients only know about abstract class(es) defining the interfaces
Delegation
• Two objects are involved in handling a
request: a receiving object delegates
operations to its delegate
Window Rectangle
rectangle
Area() Area()
width
height
Delegation (cont.)
• Makes it easy to compose behaviors at run-time
and to change the way they’re composed
• Disadvantage:dynamic, highly parameterized
software is harder to understand than more
static software
• Delegation is a good design choice only when it
simplifies more than it complicates
• Delegation is an extreme example of object
composition
Overview of Design Patterns 57
L6
Online resources
• Pattern FAQ
• http://g.oswego.edu/dl/pd-FAQ/pd-FAQ.html
• Basic patterns
• http://exciton.cs.oberlin.edu/javaresources/Desi
gnPatterns/default.htm
• Patterns home page
• http://hillside.net/patterns/