Rochester Institute of Technology
RIT Scholar Works
Theses
Thesis/Dissertation Collections
5-1-1998
Exploring design patterns with the Java
programming language
Stephanie Burton
Follow this and additional works at:
http://scholarworks.rit.edu/theses
This Thesis is brought to you for free and open access by the Thesis/Dissertation Collections at RIT Scholar Works. It has been accepted for inclusion
in Theses by an authorized administrator of RIT Scholar Works. For more information, please contact
ritscholarworks@rit.edu.
Recommended Citation
EXPLORING DESIGN PATTERNS WITH
THE JAVA PROGRAMMING LANGUAGE
by
Stephanie Burton
A thesis submitted
in
partial fulfillment of the
Requirements for the Degree of
MASTER OF SCIENCE
In
Computer Engineering
Approved by:
Principal Advisor
Michael
J.
Lutz, Motorola Professor of Software Engineering
Committee Member
_
Roy S. Czemikowski, Professor
Committee Member
_
Charles
K.
Shank, Adjunct Professor
Department of Computer Engineering
College of Engineering
RELEASE PERMISSION FORM
Rochester Institute of Technology
Implementation
of Design
Patterns
in
the Java Programming Language
I,
Stephanie Burton, hereby grant permission to any individual or organization to reproduce
this
thesis in whole or in part for non-conunercial and non-profit purposes only.
Stephanie P.
Burton
ABSTRACT
This
projectdescribes
anddiscusses
the
concepts ofdesign
patternsgiving
ahistorical background
as well asciting
contributionsto the
softwaredevelopment
field
andcurrent research efforts.
In
addition,
the
advantages anddisadvantages
ofusing design
patterns and efforts
to
encouragedesign
pattern usagein
software organizations arediscussed.
Seven design
patterns(Builder, Adapter,
Composite,
Template
Method, Facade,
Mediator
andStrategy)
were chosen asthe
basis for
example concrete applications.The
concrete applications are given
in
the
form
ofdesign
documentation,
source code andexecutable software.
The
applicationsdemonstrate
the
use ofdesign
patternsin
developing
objectoriented software applications.The
applications areimplemented in
the
Java programming
language.
The
Java programming
language
was usedbecause it is
a popular objectorientedprogramming language. An
aspect ofits
popularity
comesfrom its ability
to
execute withJava
enabledbrowsers
on avariety
ofcomputing
platforms.Noted
researchersin
the
areaof
design
patterns assertthat
design
patternsarelanguage
independent, however,
much ofthe
implementation
in
the
area ofdesign
patternshas been
writtenin
the
C++
language.
The
contribution ofthis
projectlies
in
implementing
selecteddesign
patternsin Java
andnoting
experiencesthat
supportor refutethe
conjecturethat
design
patterns arelanguage
TABLE OF
CONTENTS
Table
ofContents
ii
List
offigures
iv
Glossary
vNotation Definition
vii1 Introduction
1
2
Background
andConcepts
4
2.1
Software Development
4
2.2 Christopher Alexander
6
2.3
Patterns
in
Software
7
3 Contributions
to
theSoftware
Community
12
3.1
Object
Interaction
12
3.2
Abstraction
14
3.3
Vocabulary
15
3.4 Design
Expertise
16
3.5
Repositories
17
3.6 Process
/Organization
19
4 Advantages
andDisadvantages
21
4.1
Software
System Description
21
4.2
Software Design
22
4.3 Design Pattern
Novelty
23
4.4
Training
23
4.5
Software
Development Processes
24
5 Acceptance
andAdoption
26
5.1
Training
Efforts
26
5.2 Pattern
Mining
28
5.3
Pattern
Advocacy
30
6 Pattern community
Activities
32
6.2
Conferences
34
6.3
Noted
Community
Figures
35
6.4 Extended Communitv Support
37
7
Sample Applications
38
7.1
Builder
Pattern Application Documentation
39
7.2
Composite
Pattern
Application Documentation
46
7.3
Adapter Pattern Application Documentation
52
7.4
Mediator Pattern Application Documentation
58
7.5
Strategy
Pattern Application Documentation
64
7.6
Template
Method Pattern Application Documentation
70
7.7 Facade Pattern Application Documentation
75
8
Conclusion
82
8.1
Theory
Summation
82
8.2 Java
vs.C++
Implementation
83
8.3 Next
Steps
86
Bibliography
88
Related References
90
APPENDIX
B Composite Application
Source Code
92
APPENDIX
C
Adapter Application
Source Code
93
APPENDIX D Mediator Application
Source Code
94
APPENDIX
E
Strategy
Application
Source Code
95
APPENDIX
F
Template
methodApplication
Source Code
96
LIST
OF FIGURES
Number
Page
Figure
0.1
Class Diagram
Notation
viiFigure
1
-Structure Class
Diagram
for Builder
Pattern
39
Figure
2
-Class
Diagram
for HTML Text
Converter
41
Figure
3
-Structure
Class
Diagram
for Composite
Pattern
46
Figure 4
-Class
Diagram
for
Dependency
Traverser
47
Figure 5
-Exampleof"Makefile.txt"
48
Figure 6
Structure Class
Diagram
ofthe
Adapter Pattern
52
Figure
7
Class
Diagram
for
Image Button
Adapter
53
Figure 8
Structure Diagram
for
Mediator Pattern
58
Figure 9
Class
Diagram
for
Font Displayer Applet
59
Figure 10
MediatorApp
GUI Window
61
Figure 11
StructureClass
Diagram
for
Strategy
Pattern
64
Figure 12
Class
Diagram
for Graph
Manipulator
65
Figure
13Structure
Class
Diagram
for Template Method
Pattern
70
Figure 14
Class
Diagram
for
Shortest Pathfinder
71
Figure 15
Structure Class
Diagram
for
Facade Pattern
75
Figure 16
Class
Diagram
for
Graph
Request
Handler
77
GLOSSARY
Abstract
class,
page vii"A
class whoseprimary
purposeis
to
define
aninterface. An
abstract classdefers
some orall of
its implementation
to
subclasses.An
abstract class cannotbe
instantiated"
[4,
p.359].
Aggregate
object,
page46
"An
object composed of subobjects.The
subobjects are called aggregate'sparts,
andthe
aggregateis
responsiblefor
them"
[4,
p359].Black-Box,
page8
"Composed
objects revealnointernal details
to
eachother"
[4,
p.359].
Class,
page1
"A
classdefines
an object'sinterface
animplementation,
their
internal structure andoperationsand
the
static relationshipsbetween"
[4,
p.359].
Concrete
class,
page vii"A
classhaving
no abstract operations.It
canbe
instantiated"
[4,
p.359].
Design
pattern,
page2
"A
design
patternsystematically
name, motivates,
and explains a generaldesign
that
addressesarecurring design
problemin
objectorientedsystems.It
describes
the
problem,
the
solution,
whento
apply
thesolution,
andits
consequences.It
also givesimplementation
hints
and examples.The
solutionis
ageneralarrangementof objects andclasses
that
solvethe
problem.The
solutionis
customized andimplemented
to
solvethe
problem
in
a particularcontext"
[4,
p.360].
EuroPLoP,
page34
European Pattern Languages
ofProgramming
an annual conferenceduring
whichissues
concerning
patterns and patternlanguage development
arepresentedanddiscussed.
Gang
ofFour
(GOF),
page33
The
name givento the
four
authors ofthe
book,
Design Patterns:
Elements
ofReusable
Object-Oriented Software
GUI,
page59
Graphical User
Interface;
A
display
methodallowing
userto
interact
with an applicationusing
visualdevices
suchaswindows,
buttons,
checkboxes,
sliders,
etc.Hillside
Group,
page33
HTML
page29
Hyptertext
Markup
Language;
A
textual
format
usedto
describe
pagesdisplayed
onthe
World
Wide
Web.
Inheritance,
page17
"A
relationship
that
defines
oneentity
of another.Class inheritance defines
a new classin
terms
of one or moreparentclass.The
new classinherits it interface
andimplementation
from its
parents.The
new classis
called a subclass orderived
class.Class
inheritancecombines
interface inheritance
andimplementation
inheritance.
Interface
inheritance
defines
a newinterface in
terms
of one or moreexisting interfaces.
Implementation
inheritance defines
a newimplementation
interms
of one orexisting
implementations"[4,
p.
360].
Interface,
page viii"The
set of all signaturesdefined
by
anobject's operations.The interface describes
the
setofrequests
to
whichand object canrespond"
[4,
p.361].
Object,
page viii"A
run-timeentity that
packagesboth data
andthe
proceduresthat
operate onthat
data"[4,
p.361].
OMT,
page viObject
Modeling
Technique. A
notational convention usedto
represent object-orientedclasses,
objects andtheir
relationships.OOPSLA,
page32
Object Oriented
Program
Systems
andApplications,
an annual conferenceduring
whichissues
of softwareengineering
and softwaredevelopment
arediscussed
and presented.Override,
page39
"Redefining
an operation(inherited
from its
parentclass)
in
asubclass"
[4,
p.361].
PLoP,
page34
Pattern Languages
ofProgramming
(PLoP),
an annual conferenceduring
whichissues
concerning
patternsand patternlanguage development
arepresentedanddiscussed.
Subclass,
page viii"A
classinherits from
anothergroup
of classesthat
collaborateto
fulfill
a set of[4,
p.361].
Subsystem,
page8
"An
independent
group
ofclassesthat
collaborateto
fulfill
a set ofresponsibilities"^,
p.361].
Type,
page viiiNOTATION DEFINITION
The
notation used inby
Erich
et al[4]
serves asthe
standard notationfor
this
paper.
Figure
0.1
displays
the
notation conventionsusedin
the
classdiagrams appearing in
this
paper.AbstractQassName
^
ConctreteQassName
OperationQ
(a)
Abstract
and concrete classesClient
Gieni
(b)
Participant Client
(left)
andImplicit Client
class(right)
Drawing
<^
?
Shape
4
CreationTool
^pLineShape
^wColor
(c)
Class
relationship
Drawing
-^
For
each shape{^^
E rawQ
o
Shape- >DrawO )
(d)
Pseudocode
annotationFigure
0.1
-Class Diagram Notation
[image:10.560.134.415.179.496.2][4,
p.365]
Figure 0.1a
showsthe
notationfor
the
abstract and concreteclasses.According
to
OMT (Object
Modeling
Technique)
notation,
abox
with aclass nameatthe
top
denotes
aclass.
The
class operations arelisted below
the
class name.The
abstract classhas
a [image:10.560.147.411.323.484.2]"In
somedesign
patterns it'shelpful
to
see where client classes referenceParticipant
classes.When
a pattern includes aClient
class as one ofits
participants(meaning
the
clienthas
someresponsibility
in
the
pattern),
the
Client
appears as anordinary
class.When
the
patterndoes
notinclude
a client participant(i.e.,
clienthas
noresponsibility
in
the
pattern),
but
including
it
nevertheless clarifies which patternparticipants
interact
withclients,
then the
Client
classis
shownin
gray"
[4,
p.364],
asshown
in
Figure 0.1
b.
"Figure
0.1c,
shows various relationshipsbetween
classes.The OMT
notationfor
class
inheritance
is
atriangle
connecting
a subclass(LineShape in
the
figure)
to
its
parentclass
(Shape).
An
object referencerepresenting
a part-of or aggregationrelationship it
indicated
withby
an arrowheadedline
with adiamond
atthe
base.
The
arrow pointsto
the
classthat
is
aggregated(e.g.,
Shape).
An
arrowheadedline
withoutthe
diamond
denotes
acquaintance(e.g.,
LineShape
keeps
areferenceto
aColor
object).A
namefor
the
reference
may
appearnearthe
base
to
distinguish
it from
otherreferences"
[4,
p.364].
The
"creates"relationship
shows which classesinstantiate
other classes.A
dashed
arrowheaded
line
denotes
this
relationship.The
arrow pointsto
the
classthat
is
instantiated.
In Figure
0.1c,
the
CreationTool
createsLineShape
objects[4,
p.364].
"OMT
defines
afilled
circleto
mean'more
than
one'.When
the
circle appear atthe
head
of areference,
it
means multiple objects arebeing
referenced or aggregated.Figure
0.1c
showsthat
Drawing
aggregatesmultiple objects oftype
Shape"[4,
p.364].Pseudocode
annotationlet
thedesigner
sketchthe
outline of a method'simplementation.
Figure O.ld
showsthe
pseudocode annotationfor
the
Draw
operationon1
INTRODUCTION
Software
has
provided solutionsto
avariety
of problemsin many
industries.
During
the
discovery
ofthose
solutions,
softwaredevelopers have learned
a greatdeal
about a
variety
of problemdomains
and application requirements.Developers
useknowledge
gainedfrom
previous projects whenexploring
solutionsto
new problems.Recognition
and application ofexisting
solutionsis beneficial
to
softwaredevelopers.
Throughout
the
history
of softwaredevelopment,
developers have
endeavoredto
capture
the
essence of a problem solution.However,
the
means ofcapturing
neededinformation
waslimited
to
the
basic
components ofthe
chosen methodology.The
structured
programming
methodology,
representedin languages
such asFortran
andC,
divided
the
problemsinto
ahierarchy
offunctional
tasks that
workedtogether to
producethe
desired
output.Developers,
using
structuredprogramming techniques,
capturedtheir
solutions
through
the
creation of usefulfunctions
that
were essentialto
the
problemsolution and as compact as possible.
The
Object-Oriented
(OO)
programming
methodology,
representedby
languages
such aEiffel,
C++,
andPascal,
group data
andfunctions into
modular units which exhibit abehavior
that
is
essentialto the
solutionanddistinct.
OO
developers
capturethe
essential parts ofthe
solutionin
well-defined classesand class
hierarchies.
Regardless
ofthe
chosenmethodology,
alldevelopers do
not encounterthe
sameproblems or
have knowledge
ofthe
same set ofexisting
solutions.For example,
newsoftware
developers lack
the
experience gainedthrough
and solutions.
So many
times,
they
rediscoverexisting
solutionsthroughthe
applicationofbasic
principles.The rediscovery is
oftendifficult
andtime
consuming.A
methodto
capture problem solutions
is
still neededin
the
softwaredevelopment
community.Research in
the
area ofdesign
patternsis exploring
a useful means ofcapturing
softwaresolutions
to
reoccurring
problems.Design
patterns presentthe
essential components of aproblem solution as well as
the
relationship between
the
components andthe
constraintsof
the
solution.The
solutions are presented in generalterms
leaving
the
concreteimplementation
details
to the
implementor.Design
patterns researchhas
the
potentialto
provide valuablecontributions
to
the
software community.This
projectdescribes
anddiscusses
the
concepts ofdesign
patternsgiving
ahistorical
background
as well asciting
research efforts and contributionsto
softwaredevelopment field.
Examples
of concrete applications are givenin
the
form
ofdesign
documentation,
sourcecode and executable software.The
applications areimplemented
in
the
Java programming
language.
The
applicationsdemonstrate
the
use ofdesign
patterns
in
developing
object oriented software applications.The
concept ofdesign
patternshas
existedfor
over adecade;
however,
it has been
slow
to
gain widespread use until recently.Much
ofthe
widespread usehas been among
experienced software engineers.
This
project presents example applicationsusing design
patterns as a
tutorial
for inexperienced
softwaredevelopers.
The
sample applicationsencourage new programmers
to
take advantage ofexisting
expertisein design
patternsearly in
their
careersand expose new programmersto the
Java programming language.
The
Java
programming language
was usedbecause it is
a popular objectoriented
Java
enabledbrowsers
on avariety
ofcomputing
platforms.Noted
researchers inthe
areaof
design
patterns assertthat
design
patterns arelanguage
independent,
however,
much ofthe
implementation in
the
area ofdesign
patternshas been
writtenin
the
C++
language.
The
contribution ofthis
projectlies
in
implementing
selecteddesign
patternsin
Java
and2
BACKGROUND AND
CONCEPTS
2.1
Software
Development
A
software systemis
a productof adevelopment
process.Many
models existsthat
attempt
to
capturethe
essence ofthe
softwaredevelopment
process.One
ofthe
mostwidely
known
modelsis
the
Waterfall
model.The
Waterfall
model of softwaredevelopment identifies
the
major phases of softwaredevelopments
as requirementsgathering
analysis,
design, implementation,
and maintenance.The
stages aredepicted
assequential steps
in
aprocessbeginning
with requirements andending in
the
maintenancephase.
Each
phasehas
adefined
beginning
and end.In
addition,
the
next phasedoes
notbegin
untilthe
previous phasehas been
completed.Other
modelsexist,
such asthe
Spiral
model
that
follows
similar views with additions.The
Spiral
model suggeststhat
development
proceedin iterations
ofthe
Waterfall
model.A
completediteration
producesa
working
versionofthe
systemcontaining
a subset ofthe
completefeature
set.Remaining
features
are addedto the
systemduring
subsequentiterations
untilthe
systemis
complete.These
models aid alllevels
of a software project.At
the
highest
levels,
these
models
help
executivesdetermine
the
enddate
ofthe
project.Managers
usethe
modelsinassessing
resources.At
any
given pointin
the
project,
developers
are aware ofthe tasks
that
they
shouldbe
performing.This
highly
organizeddescription
of softwaredevelopment
modelsonly
scratchesthe
surfaceoftoday's
softwaredevelopment
practices.According
to
Gabriel,
"...the
truth
is
that
today
the
production of softwareis
software
development
process.In
large-scale
systems,
there
are numerous and sometimesconflicting
requirementsthat
mustbe designed into
a single system.Also,
ad-hocdesign
practicesutilized
by
variably
skilleddevelopers may lead
to
deficiencies
indifferent
areas ofthe
system.These
instabilities arising in
the
design
phase,
for
example,
may
alsonegatively
affectother
phases,
such as implementation and maintenance.Chaos in
the
softwaredevelopment
process affects thefinal
software product.Historically,
large-scale
software systemshave been delivered behind
schedule andbeyond
budgetary
plans.The
chaoticdevelopment
processleads
to
erroneousplanning
andresource allocations.
In
addition,
the
quality in
some systemhas
been
less
than what waspromised at
the
beginning
ofthe
project.Systems
have
been
delivered
with numerousdefects.
Multiple
releases are expectedbefore
the
system isdeemed reasonably
stabled.Developers
arekey
assetsin
the
production of software.However,
there
exists agap between
academictraining
andindustry
practice.Students
develop
most oftheirskillson small-scale projects and
isolated programming
examples.Through
these
examplesonly
limited
experienceis
gained.The study
oflarge-scale
systems is alsolimited.
Gabriel
assertsthat
"In
schools,
there
is
no suchthing
asstudying
successfuldesigns
andimplementations
of
large
systems"[l].He
goes onto
suggest that evenamong
experienceddevelopers,
there
is
no agreement of a"good"
design
orimplementation.
Thus,
novicedevelopers
gain most of
their
experiencethrough
practice ratherthan training.
The
accumulation ofexperience
through
practicetakes
time
and alarge
number andvariety
of projects.In
light
ofthe
difficulties,
softwarehas become
an acceptedrisk in many
industries.
The
potential gains somewhatoffsetthe
difficulties.
Many
software systemslast
its
environmentto
incorporate
newtechnological
advances and changesin
societal needsand requirements.
The
returns of softwarehave increased
the
demand for it.
As
industries
increase
the
use ofsoftware,
many
researchershave
endeavoredto
discover
waysto
introduce stability into
the
development
processto
insure its
longevity.
Some
researchershave
concentrated on thedesign
phase ofthe softwaredevelopment
process.
In
such ashorttime,
software'spopularity has
grownimmensely resulting from
its
usein
avariety
ofindustries.
Thus,
some researchershave
endeavoredto
capturethe
design knowledge
gainedthus
far in
the
software community.With
the reuseof tried andtested
designs,
other phases ofthe
development
processmay be positively
affected.In
addition,
newdevelopers
canbe
exposedto the
existing
expertiseearly in
their
careers,
which
positively
affects thedevelopment
process.2.2 Christopher Alexander
In
thesearchfor
stable practicesin
design,
some researchershave looked
to
otherlong-standing
engineering
disciplines
as a guide.Researchers
seeking
to
improve
the
design
phase of softwaredevelopment have focused
onthe
works ofChristopher
Alexander.
"Christopher Alexander
is
anarchitect,
builder,
and professor of architecture atthe
University
ofCalifornia,
Berkley"
[1,
p.5].
He has
writtenathree-book
seriesthat
presentstheories of
architecture,
building
and planning.The titles in
the
series areThe Timeless
Way
ofBuilding,
A Pattern
Language,
andThe
Oregon
Experiment (all
from Oxford
Alexander
used patternsto
describe
structuresthat
werevisually pleasing
andprovided
functionality
characteristicsfor
their
intended use[6,
p.20].
The
patternsthat
he
developed describe
solutionsto
problemsreoccurring in
design
interms
ofthe
forces
involved in solving
the
problem.Patterns
aidedin
thedesign
of each project segment.Alexandrian
patternsdid
notrevealexactly how
to
constructthe
structure.This
enablescreativity
within thebounds
ofdefined
constraints.Alexander
compiled a collection ofpatterns
into
a patternlanguage.
"Alexander
has formulated
whathe
calls a patternlanguage for
building
andcities"
[3,
p.1].
Each
entry in
the
patternlanguage is
patternthat
describes
a solutionto
areoccurring design
problem.Alexander
orderedhis
patternsin
such away
that
afinite
number of options are presented at each
step in
the
design
project.An Alexandrian
pattern contains
the
following
information:
the
definition
ofthe
problem,
definition
ofthe
problem
context,
description
ofthe
forces
involved,
description
ofthe
solution,
resolutionof
the
forces
and adesign
rationale.2.3 Patterns
in Software
"A little
imagination
revealsrich
analogiesbetween
these
architecturalpatterns andthe
structure ofprograms"
[2,
p.20].
Buildings
evolvein
piecemealfashion
asthe
needsof
the
inhabitance
change overtime
[1,
p.2].
Programs
evolve and change overtime
asnew technologies are
discovered
or new requirements areintroduced.
Requirement
changes are
incorporated
into
the
existing
structure ofthe
programintroducing
changesto
specified areas ofthe program
just
as additional rooms are addedto the
structure anexisting
building. Both
areas are concerned withthe
"access between
the
p.
20].
The
softwarecommunity is
interested in
the
architecturaldevelopment
of patternsbecause both
areashave
similar structural concerns andlike
architecture,
some problemsreoccur
in
many
projects.Members
ofthe
software communityhave
adoptedthe
notion of patterns andtailored
patternsto
meetthe
needs of software.One
ofthe
most noted effortsto
gatheraset of patterns
for
softwarebegan
as a part ofErich
Gamma's
Ph.D.
thesis.
Following
the
introduction,
three
additional peopleRichard
Helm,
Ralph
Johnson,
andJohn
Missides
joined Gamma
to
continuedevelopment
of a catalogue of software patterns.To
distinguish
software patternsfrom
Alexander's
architecturalpatterns,
the
software patternswere given
the
namedesign
patterns.Gamma
et aldefined
adesign
pattern as:"A
design
pattern
systematically
names, motivates,
and explains a generaldesign
that addresses arecurring
design
problemin
object oriented systems.It
describes
the
problem,
thesolution,
whento
apply
the
solution and its consequences.It
also givesimplementation
hints
and examples.The
solution is a general arrangement of objects and classes thatsolvethe
problem.The
solutionis
customized andimplemented
to
solvethe
problemin
aparticular
[4,
p.360].
The
qualifying
term
"design" emphasizes"the
capturing
ofdesign
expertiseas opposedto
othersoftwaredevelopment
skills such asdomain
analysisor
implementation"
[5,
p.37].The
definition
and presentation ofdesign
patternsby
Gamma
et al[5]
has far
reaching
implications
in
software.Gamma
mentionsthat
the solutions are applicablewithina particular context.
Software
has different
levels
of views orgranularity.One
canview software on a system
level
where a systemis
treated
as ablack-box
andonly
the
where cooperation subsystems provide
functionality
within alarge
system.Software
canbe
viewedonthelevel
ofits internal behavior
or codelevel
implementation. Each
oftheseviews
is
adistinct
contextwhere solutionsmay be
applied.Since
the
design
patterndefines
its
context,
design
patterns candescribe
solutionsfor different
granularities of software.Patterns
candescribe
solutions applicableto
a completesystem,
a component within asystem,
or animplementation
detail,
like
iterating
through
alist.
The
representation of a patternin
aliterary
document is very
useful.The
text
provides a wealth of
information
to
which graphical representations complement.Neglecting
implementation
dependencies
whendescribing
the elements of a solutionenables
the
implementation
ofthe
solutionin any
object orientedlanguage.
In
addition,
the
solutionsmay
alsobe
appliedin
non-object oriented systemsbecause
the solution ofthe
problemlies
withinthe
components and theirrelationshipsto
each otherratherthan
the
structures,
such as classdiagrams,
thatthey
are presented.Each
patternis
presentedin
a prosedocument. Gamma describes
each patternin
a thirteen-section
format containing both
text
anddiagrams.
The
format is
structured asfollows:
Name, Intent,
Also Know
As, Motivation, Applicability,
Structure, Participants,
Collaborations, Consequences, Implementation,
Sample
Code,
Known
Uses,
andRelated
Patterns.
The
thirteen sections canbe
groupedbased
onthe
information
that
they
provide.
"The first
three
sectionsidentify
the
pattern.Section four
approximatesthe
contents of an
Alexandrian
pattern:It
gives a concrete examplethat
illustrates
the
problem,
its
context,
andits
solution.Sections
five
through
ninedefine
the
patternSections
ten
and eleven give a concrete example ofthe
implementation
ofthe
As
the
softwarecommunity has
tailored
the notion ofpatternsto the
needs ofsoftware,
the application of patternsis
alsoslightly different
than
the
Alexandrian
application.
Alexandrian
patterns are appliedin
sequence;
however,
the
Gamma
patternsare presented
in
no particular order.There is
notdirection
to the
"right" pattern.In
contrast
to
Alexander's
brief
patterndescriptions,
Gamma
patternsinclude
the
Alexandrian
pattern characteristics andincludes
additional abstractdescriptions
andimplementation
examples.The
chosenformat
enables"quick
referencein
the
heat
ofdesign
orimplementation"[5,
p.37].
The implementation
presentedcanbe followed
as arecipe
for
similarimplementation
projects.However,
it
shouldbe
noted thatthe
implementation
presentedin
the
patterndescription is only
an example of one possibleimplementation
and shouldnotbe
confused asthe
sole representation ofthe
pattern.Design
patterns are usefultools
for developers
atany
stage of theirpracticing
careers.
For
novices,
design
patterns presents expert experience gatheredby
otherpractitioners over
time
andhas been
tested
through usein
numerous applications.They
encourage
creativity
and exploration withdefined
constraints."Design
patternsbuild
them
[novices]
up
to the
expertsway
ofthinking"
[2,
p.66].
For
experienceddesigners,
design
patterns serve as a reminder ofthe
currentknowledge
that
already
exists.Design
patterns
help
these
designers
concentrate on other aspects ofdesign
ratherthan
spending
time
rediscovering existing
knowledge.
For
domain
experts,
design
patterns represent abody
ofexisting
knowledge
to
whichthe expertmay
augment.Domain
expertshave
the
experience and
knowledge
to
recognizedeficiencies
and omissions withinthe
existing
knowledge base.
To
the
softwarecommunity
atlarge,
design
patternsrepresent
the
information
"in
a setformat
under a standardnomenclature"
[3,
p.1].
In
summary:Although
the
Waterfall
andSpiral
models existto
theoretically
describe
the
process of softwaredevelopment,
the
softwaredevelopment
process proceedsalong
anapparently
chaotic path.The resulting
software systems aredelivered
late
andover
budget due
to
the
lack
of sufficientplanning for
such a chaotic and unpredictableprocess.
The delivered
systemshave low quality due
to
existing
errors.Novice
developers
are introduced
to the
process withlimited
training
and experience.In
an effortto
harness
existing
knowledge
about various softwaresystems,
researchers
have
looked
to
architecture and adoptedAlexander
Christopher's
notion ofpatterns that
describe
the
solutionto
recurring
problems.In
software,
design
patterns canintroduce
somestability
when appliedduring
the
design
phase ofthe
softwaredevelopment
processby
outlining
orinjecting
stable solutionsinto
new orexisting
projects.
They
may
alsopositively impact
the
other phases ofthe
softwaredevelopment
process
by
representing
arepository
ofknown
solutionsfor
reuse,
providing
guidanceduring
implementation
and maintenance phase ofthe
development
process,
andpositively
affecting
the
developers participating in
the
process.Design
patterns are usefultools
atany
stage of a
designer's
career.Since
parallels existbetween
architecture andsoftware,
adopting
some ofthe
concepts
is
not such asfar-fetched
notion.Software design
patternsdescribe recurring
software
design
problemsin
a prosedocument
that
containsthe
characteristics ofAlexandrian
patterns augmentedby
concreteimplementation
details
and examples.Software
design
patternslack
the
sequentialapplication ofthe
Alexandrian
patternsbut
the
3
Contributions
to
theSoftware
Community
The
concept ofdesign
patterns was slowto
be
acceptedby
the
softwarecommunity.
At
first,
only
small groups withinthe
softwarecommunity
reapedthe
benefits
of
the
design
pattern concepts.As discussion
and practical useincreased,
many
realizedthat
design
patterns could make valuable contributionto
thesoftware community.Six
suchcontributions
that
design
patterns offerthe
softwarecommunity
arediscussed.
3.1
Object
Interaction
The
objectmethodology
focused
ondeveloping
good classes and classhierarchies
to
capturebehavior. Coplien
assertsthat
"adopters
ofthe
object paradigmfocused
on the'find-the-object'
exercises,
deferring
orforever
loosing
the
system perspective ofinteractions between
objects"[6,
p.36].
Objects
(or
classes andtheir
hierarchies)
arealmost never used
in isolation.
Also,
it is
very
rarethat
a single object would containthe
behavior
of an entire system.Software
systemsencompassing
multiple concerns arebest
addressed with more
than
one object.However,
the participantsin
thesystem are notthe
only
important
factors
whenexpressing
the
behavior
of a system.Interactions
between
the
objectsin
the
systemdistinguish
a systemfrom
amerecollectionofisolated
objects.Design
patterns encapsulatethe
protocol ofinteraction
between
objectsthat
couldnot
be
expressedby
a single object[7,
p.48]. Individual
design
patterns capturethe
solutions
to
recurring
problemsin
softwaredesign.
In
this
case,
the
solutionto
a specificobjects.
Interaction between
the
objectsmay
be creating
one another orpassing
messagesto
one another.On
alarger
scale,
the components ofthe
solutionmay be distinct
subsystems
interacting
together."Such
composition provides and abstract view of asystem,
so thatadesigner
cando
system-level analysis and reason about systemintegrity
constraints"
[7,
p.46]. At
this
level,
interactions
between
the
components or sub-systesmsform
some globalfoundations
ofthe
overall operations of the systembeing
designed.
Individual
patterns canbe
organizedinto
groups called patternlanguages.
Pattern
languages
represent a collection of solutionsto
reoccurring design
problems within adomain.
According
to
Alexander
patternlanguages
provided a guidefor
the
application ofindividual
patterns.Pattern
languages demonstrate
the
interactions
(in
the
form
ofdependencies)
between
individual
patterns asthey
relateto
constructing
a system.This
represents yet another scale upon which patterns can
convey interaction between
objectsin
a system.Although
identifying
the
components of a systemis
important,
the
interactionbetween
the
components ofa system contributesgreatly
to
describing
the
behavior
of asystem.
In
the
collection of patterns presentedby
Gamma,
some ofthe
patternshave
asimilarstructure of components
in
the
solution ofthe
problem.However,
cleardistinction
between
the
purposeandintent
ofthe
patterns canbe
made oncethe
interactions between
the
components are understood.From
individual
patternsto
patternlanguages,
patternsdescribe
interactions between
components regardless ofhow
the
integration
scale changes3.2
Abstraction
The
expression of abstractionis
one ofthe
founding
principles ofthe
objectmethodology.
Abstraction
allowsdevelopers
to
defer
the
considerations ofthe
detailed
implementation
untillate
inthe
design
stageby
representing
thecomponentsinthe
systemas
interfaces.
In
somecases,
this enables adequate management ofcomplexity
by
minimizing
the
overload ofdetails.
Design
Patterns
lends
supportto
the
concept ofabstraction.
Design
patternsdescribe
a generalway
ofsolving
a problem.The
documentation
of
the
pattern canbe
viewed as thedescription
of aninterface
ofthe
solution.The
interface
ofthe
solutionis
presentedin
theform
oftext
anddiagrams.
Together
these
approaches
convey
the structure ofthe solution'sinterface,
in
the
form
of a general viewof what each component's
interface
shouldcontain,
andthe
behavior
ofthe
solution,
in
the
form
of explanations and examples.Design
patterns give athorough
explanation ofthesolution's
interface
whileleaving
the
developer
to
solidify
the
solution.The developer
For
systemsthat
incorporate
multiplesolutions,
design
patternshelp
the
developer
to
organize solutionsin
away
to
achieve a system with somedesired
behavior.
Design
patterns can represent a modular
abstraction,
whichhides
the internal objects.Dealing
with
larger
modular abstractions enablesdevelopers
to
concentrate onorganizing
the
solutions
into
a sensible system.The
modular viewlets
the
developer
temporarily
circumvent
the
total
number of actual objectsthat
mustbe
presentin
the
system.Temporary
deferral
of some smallerdetails may
resultin
a systembetter
organized andeasier
to
maintain and extendbecause
the systemdesign
was notdriven
by
its
implementation.
3.3
Vocabulary
The
softwarecommunity is
afairly
dynamic
community.The community
evolvesand changes as new
discoveries
andinnovations
are made.Over
time,
newbuzzwords
become
popular whiletraditional
terms take
on new meanings.The
constant changein
terminology
canbecome confusing
evento
the
practitioners who arefaced
with theimplications
ofthe
terminology
ondaily
basis.
Design
Patterns
introduce
a consistentvocabulary among
it
users.Design
patternsintroduce
anddefine vocabulary in
avariety
of ways.Like
Alexander,
patterns producedby
Gamma
and othershave
a name.The
name serves as anidentifier for
the
conceptsdescribed in
the
pattern.In
the
descriptions
ofthe
conceptsin
the
pattern otherterms
areintroduced.
These
terms
may be
specificto the
pattern orsignify
acommonlink between
one ormoredesign
patterns.In
any
case,
the
words usedIntroduction
of a consistentvocabulary
facilitates
easier communicationbetween
users of
the
same set of patterns.The
mere mention of a pattern namemay
immediately
conjure
up
the
underlying
concepts ofthe pattern.Since both
partieshave
acceptedthe
same vocabulary
base,
the
unspoken conceptsthat
each envisionsis
consistent with oneanother.
Over time
with continueduse,
the
patternlanguage
vocabulary
becomes
secondnature
to the
users.The vocabulary becomes
aform
of abstraction.Patterns
give riseto
avocabulary
that enablesdevelopers
"to
talk about structureslarger
than
modules,
procedure,
orobjects"[6,
p.37].
The
users can concentrate onissues
of ahigher
level
while
maintaining
ties
to the
underlying
concepts.Working
toward
amoreeffective meansof communication
between
usershelps
to
moreclearly
convey
conceptsbetween
team
members while
minimizing
misunderstandingsdue
to
differing
foundations
andassumptions.
3.4 Design Expertise
Software
is
usedin
numerous productsin
avariety
ofindustries.
Through
the
development
of sucha widevariety
ofproduct,
valuableknowledge
and expertisehas been
gained
in
the
software community.A
popularway
oftransferring knowledge is
through
examining
source code.Design
patterns capturethe
subdeties ofsoftwaredesign
solutionsthat
may
notbe
apparentfrom examining
source code.The design
patterndocumentation
presentsthe
solutionto
adesign
problemin
diagrams
andtextual
explanations.The
textual
explanations reveaLfor
example,
the
problem
motivating
the
solution.It
may
also presentvariations ofthe
problemfor
whichrelationships and
interactions between
the
components ofthe
solution.Together,
this
information
provides
astrong foundation
for
understanding
andincorporating
the
solution
into
one's own work.This documentation
also provides a cleardirection
that
is
useful
for initial development
and can serve as ahigh level
overviewfor
maintainers.Implementation
issues pertaining
to
the
application ofthe
patternis
presented asconsequences.
The
consequences representdiscoveries
made throughthe
variousapplications ofthepattern.
The
consequences presenttrade-offs
andlimitations
that setthe
boundaries for
the
solution.This
enablesdevelopers
to
makeinformed
choices asto
whether
the
solution meets the needs ofthe
applications now andin
the applicationsfuture.
In
additionto
providing
information
to
makegooddesign
choices,
design
patternsaide
in
building
confidence.Design
patterns representinformation
gatheredduring
severalapplications.
Thus,
the user canfeel
somedegree
of surenessin
justifying
its
use.In
addition
developing
confidenceamong developers
encouragesthem to
proceedto
the nextlevel
ofpractice wherethey
may discover
newinnovations.
Design
expertiseis
astep beyond merely
knowing
the
concepts of specific subjectmatter.
It
entails certainknowledge
ofapplying
the
conceptsin
an efficient andlogical
manner.
Design
patterns areinstruments
to
gatherthis
preciousknowledge
so that allmembers of
the
softwarecommunity
canbenefit
and moreforward.
3.5
Repositories
Design
patternshave
sparked a surge ofinformation sharing among
members ofthe software community.
Buschmann
et al write"
the
patternform
makesit
possibleto
newcomers and novices
in
softwareengineering"
[8,
p.418].
The
centralfocus
ofthe
discussions
is
the
prosedocuments
describing
the solutions.To
date,
numerousdesign
pattens
have been identified in
avariety
of areas[8,
p.423].
Collections
ofdesign form
repositories
that
preservethe
existing design
solutions.Popular
repositories of softwareknowledge
arelibraries.
Some
softwarelibraries
contain collections ofcommonlyusedprocedures or collections of class
hierarchies.
One
difficulty
withthese types
of repositoriesis
that
they
are implementationdependent
It
would
be difficult if
not impossibleto
incorporate
entitiesfrom
repositories writtenin
different languages into
one application.Design
patterns repositories consist of prosedocument
describing
design
solutions.Although implementation
examplesmay
be
givenin
a specificlanguage,
thedocument describes
the
solutionin
terms
ofthe
componentsinvolved.
The
notation usedin
the
design
patternsmay
notbe
the
notationto
whichthedeveloper
is
accustomed,
but
the
notation usedin
different
object oriented repositoriesrepresent solutions
using
the
basic
relationships presentin
object orientedlanguages.
Thus,
users ofdifferent
object orientedlanguages
could understandthe
solutionsdescribed
in
the
pattern.Leaving
the
implementation
to
the
developers,
enablesthe
incorporation of solutions
from
different
repositoriesinto
a single application writtenin
one
language.
Repositories
here
referonly
to
collections ofdesign
patterns.There
exist severalbooks
that
present a collection ofdesign
patterns.These
canbe
viewed as smallrepositories.
These
repositonesdescribe
patternsin
adefined
notation accompaniedby
discussion
in
adefined format.
Some
books have
adoptedformats from
otherbooks.
In
the
community
can understandthe
patterns on somelevel
despite
their
language
background.
Repositories
represent a means ofpreserving
the
valuableinformation
available
in
acommunity; so,
many
researchers areworking
to
bring
thevastsets of smallerrepositories
together
into
a singlerepository
that
is readily
accessibleto
allpractitionersin
the softwarecommunity.
3.6
Process /Organization
Software
design
andimplementation
arekey
aspectsto
developing
a softwaresystem.
However,
workplaceissues
alsoinfluence
the
development
of a software product.Some
adopters ofthe
design
pattern concept areapplying
it
to
the organizational andprocess side of software
development
to
maketheprocessmoreeffective and efficient.Studies
into
the
process and organizational side of softwaredevelopment have
revealed patterns.
It
wasdiscovered
that
avariety
of sound software organizations sharesimilar characteristics.
Identification
ofrecurring
characteristics and processesthat
encourages stable software
development
is
a valuablefind. As
softwareis in high
demand,
the
needfor
strong
softwaredevelopment
organizationsis
crucialto
many industries.
James Coplien
and othershave
focused
their research effortsinto
identifying
process andorganizationalpatterns.
Coplien
wrotehis first
process patternin
1993.
Since
then, he has
authored a collection of organizationalpatterns,
including
apatterndescribing
how
organizational structure can support software projectmanagement[8,
p
421].
Steve
Berczuk
has been
credited withcreating
a patternlanguage
that
demonstrates how
processandarchitecture work
together
[6,
p.39].
Many
other researchershave
contributedto the
In
summary:design
patterns contributeto
many
areas of the softwaredevelopment
community
andto
the softwarecommunity
as a whole.It
enables thecapture of system
behavior in revealing
the
interaction between
objects.Design
patternsupport
the
concept of abstractionby
presenting
a general solution without cumbersomeimplementation
details
and enablesdevelopers
to
concentrate on arrange multiplesolutions
into
a stabledesign
that
facilitates focused development
and easier maintenance.They
introduce
a consistentvocabulary
among
developers.
Design
patterns capturevaluable
design
expertise gainedby
various practitioners and encourages efficienttransfer
of
design
expertiseamong
developers.
Repositories
ofdesign
pattern preserve availabledesign
knowledge
in
aform
understandableto
developers
ofdifferent
language
backgrounds.
Research
in
the area of process and organization patternshas identified
4
ADVANTAGES AND DISADVANTAGES
The design
pattern movement represents aninnovative
means ofcapturing
andsharing
valuable software solutionsamong
software practitioners.Since
the
introductionof
design
patterns,
theirproliferationthrough the
softwarecommunity has
sparked muchdiscussion
anddebate.
Among
the
issues
being
discussed
arethe
advantages anddisadvantages
of them.Noted
namesin
area ofdesign
patternshave
cited advantagesin
software system
description
and softwaredesign
[9], [10], [11],
[12].
Disadvantages have
been
citedin
the
overallnovelty
ofthe movement andthe
area oftraining
[10],
[13].
There
are advantages and
disadvantages
the
softwaredevelopment
process area withthe
use ofdesign
patterns[9],
[10].
4.1
Software System Description
A
software systemis
collaboration ofcomponentsworking
together to
provide asolution.
As
discussed
in
the previouschapter,
a software system canbe
viewed atdifferent
granularlevels.
The
components atdiffering
levels may be
subsystems, objects,
etc.
Design
patterns capturethe
interaction
between
system components at a chosengranularity.
Capturing
the
interaction
and relationshipsamong
system componentshelps
to
describe
the
function
being
providedby
a set of components.Design
patterns"describe
a system architecturethat
is broader
than
an object or class hierarchy"[9,
p.8].
Using
design
patterns as an architecturaltool, "we
candescribe important
structures andthem"[9,
p.9]. As
software evolves overtime,
understanding
the
underlying
architecturehelps in
effortsto
maintainthe
system'sintegrity.
4.2
Software
Design
During
softwaredesign,
users ofdesign
patterns caninject
the
system withfavorable
characteristics thatwillmake it more valuable overtime.
The
modularnature ofdesign
patterns enablesthe
incorporation ofadaptability
into
the
systemearly in
the
systemdevelopment.
Design
patterns assistdevelopers in
designing
hooks into
the
software;
software
hooks
are areasin
the
softwarewhere new software canbe easily
added withoutmuch change
to
the
surrounding
modules[10,
p
47].
In
addition,
they
supportkey
principles of object oriented
design,
for
example,
separating
aninterface
from
its
implementation
[11,
p.59]. Design
patternsdefine distinct
separationsbetween
solutionsthat
resemble aninterface. Within
the
documentation,
the
patterndescribes any necessary
input
structuresanddescribes
structures producedby
the
pattern.In
this
case,
the
internal
operationof
the
solutionmaybe
viewedas ablack
box.
Designing
toward
interfacesratherthan
implementation
minimizesthe
side effects of changesin
one module on othermodules.
The
use ofinterfaces decreases
the
cost of somefixes
and changeslater in
thesystem
life.
Design
patternsdescribe
an orderly means ofimplementing
a solutionbv
representing
the
component,
relationshipsamong them,
key
issues
andtrade-offs.
Understanding
the
relationshipsamong
the
components withinmodules makesit
easierto
add
functionalitv;
understanding
the trade-off
assistsin maintaining
the
integrity
ofthe
design. The
applicationsthat
incorporate design
patternsmay be
easierto
extend while4.3 Design Pattern
Novelty
The design
pattern movementis
the
first large-scale
attemptto
formally
captureexisting
expertisein
a consistentformat
However,
the
movementis
stillin its
early
stagesand
undergoing
rapid change.The novelty
of thedesign
pattern movementhas been
viewed as a
disadvantage.
Some
neededinfrastructure is
stillin developmental
stages.Coplien
writesthat
the
patterncommunity has
not matured enoughto
command astandard review committee
[13,
p.84].
Issues preventing
theformation
of such abody
deal
withdeciding
onthe
breadth
anddepth
ofknowledge
that the committee shouldrepresent.
Since
the
introduction
ofthedesign
patternmovement,
practitioners withinin
the
community
have
authored numerous patterns.The
patterns provide solutionsto
various problems
representing
expertisein
variety
of applicationdomains.
The
increasing
volume of patterns requires some sort of organization.
Clines
statesthat
"Design
patternsclassification
is
not yet usefulto
practitioners"
[10,
p.49].
Current
classification schemesare useful
in
determining
whether new patterns aretruly
unique.However,
the
classifications are not as
intuitive
to
the
average practitioner whois
learning
design
patterns.
4.4
Training
Effective
use ofdesign
patternrequires carefultraining.
"Some
design
patternsareunnecessarily
hard
to
learn"
[10,
p.49].
The
solutionmay
consist ofsubtleimplication
that
is
notreadily
apparentto
the novice user.The documentation
usedto
expressthe
recommended
that
training
proceedfirst
by
presenting
the
design
patternsin
simplifiedterms.
Then,
proceedto
presentthe
more generaldesign
pattern.Design
patterns aremany
times
presented incatalog fashion.
The catalog
contains a number ofindependent
solutions.
However,
there
is no guiderevealing
which patterns arenecessarily
the
"right"pattern
to
be
usedin
aspecificsituation.Thus,
novice userslearn
by
practicewhichdesign
patternswork
in
differing
situations.Developing
the skillsto
makethese
determinations
takes
sometime.
Thus,
theremay be
atime
learning
curveinvolved from
the
first
introduction
ofdesign
patternsto
making
effective use of them in applications.Continued
mentoring
through the
initial
applicationsis
helpful
inproviding
some explanation andinsight
thatmay be
initially
lacking.
4.5
Software
Development Processes
Some
softwaredevelopment
projectsextend over along
period oftime
and utilizethe talents
ofmany individuals.
The
processesinvolved
insupporting
such an effortprovide an
important infrastructure for
the success ofthe
project."Design
patternscoordinate
the
entire process andcommunity"
[10,
47].
Cline
[10]
writesthat
design
patterns provide a consistent
vocabulary
that
enables communicationamong
practitionersthroughout the
software'slife
cycl