Beruflich Dokumente
Kultur Dokumente
TEXT BOOKS:
1.Design Pattern by Erich Gamma, Pearson Education
2.Patterns in JAVA Vol-I BY Mark Grand, Wiley DreamTech
3.Patterns 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
UNIT-I
S.NO.
TOPIC.
Slides
PPT
1
2
3
4
5
6
7
8
L1
L2
L3
L4
L5
L6
L7
L8
39
10 13
14 18
19 28
29 30
31 59
60 61
62 63
L9
64 64
UNIT-I
L1
UNIT-I
L1
Design Patterns
Design Patterns are the best solutions for the
re-occurring problems in the application
programming environment.
Nearly a universal standard
Responsible for design pattern analysis in
other areas, including GUIs.
Mainly used in Object Oriented programming
UNIT-I
L1
L1
UNIT-I
L1
L1
L1
L2
10
L2
11
L2
Design Patterns in
smalltalkMVC
12
L2
Design Patterns in
smalltalkMVC
Relative Percentages
A B C D
X
15 35 35 15
10 40 30 20
10 40 30 20
Change notification
Requests, modifications
A
D
B
C
A
A=10%
B=40%
C=30%
D=20%
UNIT-I
Application data
13
L3
UNIT-I
14
L3
UNIT-I
15
Participants:
The classes and/or objects participating in the design
pattern and their responsibilities.
UNIT-I
16
L3
L3
UNIT-I
17
L3
UNIT-I
18
19
L4
L4
Builder:
Separates the construction of the complex object
from its representation so that the same
constriction process can create different
representations.
Chain of Responsibility: Avoid coupling the
sender of a request to its receiver by giving more
than one object a chance to handle the request.
Chain the receiving objects and pass the
request along the chain until an objects handles
it.
UNIT-I
20
L4
21
L4
22
L4
L4
25
L4
UNIT-I
27
L4
UNIT-I
28
L5
29
L5
Purpose
Creational
Scop Class
e
Factory
Method
Object Abstract
Factory
Builder
Prototype
Singleton
Structural
Behavioral
Adapter
(class)
Interpreter
Template Method
Adapter
(object)
Bridge
Composite
Decorator
Facade
Flyweight
Proxy
Chain of
Responsibility
Command
Iterator
Mediator
Memento
Observer
State
Strategy
Visitor
UNIT-I
30
L6
UNIT-I
31
L6
UNIT-I
32
L6
Builder
Adapter
Avo
hys iding
tere
sis
Iterator
cre
a
com ting
p
os i
s
te
Enumerating
children
composed
using
Composite
adding
respnsibilities
to objects
Decorator
changing skin
versus guts
Strategy
ing
shar gies
e
strat
sharing
composite
s
ad
op ding
era
ti o
n
Flyweight
sh
ter aring
sy min
mb a l
sharing
ols
strategies
defining
grammar
Interpreter
con
fi
dyn gure fa
ami
c
cally tory
Singleton
defining
algorithms
steps
single
instance
de
tra fini
ve ng
rs
a ls
in g
add ations
r
ope
Template Method
Abstract Factory
UNIT-I
def
in
the ing
ch a
in
Chain of
Responsibility
complex
dependency
management
often uses
t
implemen
using
single
instance
Command
Visitor
Mediator
State
Prototype
Bridge
Observer
Factory Method
Facade
33
L6
Interface:
Set of all signatures defined by an objects operations
Any request matching a signature in the objects interface may be sent
to the object
Interfaces may contain other interfaces as subsets
Type:
UNIT-I
34
L6
Specifying Object
Implementations
An objects implementation is defined by its class
The class specifies the objects internal data and
defines the operations the object can perform
Objects is created by instantiating a class
an object = an instance of a class
Class inheritance
parent class and subclass
UNIT-I
35
L6
Specifying Object
Implementations (cont.)
Abstract class versus concrete class
abstract operations
Override an operation
Class versus type
An objects class defines how the object is
implemented
An objects type only refers to its interface
An object can have many types, and objects of
different classes can have the same type
UNIT-I
36
L6
Specifying Object
Implementations (cont.)
Class versus Interface Inheritance
class inheritance defines an objects
implementation in terms of another objects
implementation (code and representation sharing)
interface inheritance (or subtyping) describes
when an object can be used in place of another
UNIT-I
37
L6
Specifying Object
Implementations (cont.)
Programming to an Interface, not an
Implementation
Benefits
clients remain unaware of the specific
types of objects they use
clients remain unaware of the classes that
implement these objects
UNIT-I
38
L6
Program to an interface,
not an implementation
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
Do not declare variables to be instances of particular concrete classes
Use creational patterns to create actual objects.
UNIT-I
39
L6
Black-box reuse:
Reuse by object composition
Requires objects to have well-defined interfaces
No internal details of objects are visible
UNIT-I
40
L6
UNIT-I
41
L6
Inheritance versus
Composition
Two most common techniques for reuse
class inheritance
white-box reuse
object composition
black-box reuse
Class inheritance
advantages
static, straightforward to use
make the implementations being reuse more easily
UNIT-I
42
Inheritance versus
Composition (cont.)
L6
UNIT-I
43
L6
Inheritance versus
Composition (cont.)
Object composition
dynamic at run time
composition requires objects to respect
each others interfaces
but does not break encapsulation
44
L6
Inheritance versus
Composition (cont.)
Object composition (cont.)
class and class hierarchies will remain
small
but will have more objects
45
L6
Delegation
Two objects are involved in handling a
request: a receiving object delegates
operations to its delegate
Window
Area()
Rectangle
rectangle
Area()
width
height
UNIT-I
46
L6
Delegation (cont.)
Makes it easy to compose behaviors at run-time
and to change the way theyre 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
UNIT-I
47
L6
Inheritance versus
Parameterized Types
Let you define a type without specifying all
the other types it uses, the unspecified types
are supplied as parameters at the point of
use
Parameterized types, generics, or templates
Parameterized types give us a third way to
compose behavior in object-oriented systems
UNIT-I
48
L6
Inheritance versus
Parameterized Types (cont.)
Three ways to compose
object composition lets you change the behavior
being composed at run-time, but it requires
indirection and can be less efficient
inheritance lets you provide default
implementations for operations and lets
subclasses override them
parameterized types let you change the types
that a class can use
UNIT-I
49
L6
UNIT-I
50
L6
51
L6
52
L6
53
L6
UNIT-I
54
L6
UNIT-I
55
L6
56
L6
57
L6
58
L6
UNIT-I
59
L7
60
L7
UNIT-I
61
L8
62
L8
UNIT-I
63
L9
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
64