patterns what are patterns? software patterns design ...utdallas.edu/~chung/sa/pattern.pdf ·...

22
Dept. of Computer Science, The University of Texas, Dallas Lawrence Chung Patterns J2EE Patterns: Still Evolving ... What are Patterns? Software Patterns Architectural Patterns Design Patterns

Upload: ngonhu

Post on 10-Sep-2018

228 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Patterns What are Patterns? Software Patterns Design ...utdallas.edu/~chung/SA/pattern.pdf · Facade Memento Flyweight ... Design Patterns Catalog Pattern Data Access Object Fast-Lane

Dep

t. of

Com

pute

r S

cien

ce, T

he U

nive

rsity

of T

exas

, Dal

las

Law

ren

ce C

hu

ng

Pat

tern

s

J2E

E

Pat

tern

s: S

till

Evo

lvin

g ..

.

Wh

at a

re P

atte

rns?

So

ftw

are

Pat

tern

s

Arc

hit

ectu

ral P

atte

rns

Des

ign

Pat

tern

s

Page 2: Patterns What are Patterns? Software Patterns Design ...utdallas.edu/~chung/SA/pattern.pdf · Facade Memento Flyweight ... Design Patterns Catalog Pattern Data Access Object Fast-Lane

Law

ren

ce C

hu

ng

Wh

at a

re P

atte

rns?

"Eac

h pa

ttern

des

crib

es

a pr

oble

m w

hich

occ

urs

over

and

ove

r ag

ain

in o

ur e

nviro

nmen

t,

and

then

des

crib

es

the

core

of t

he s

olut

ion

to th

at p

robl

em,

in s

uch

a w

ay th

at y

ou c

an u

se th

is s

olut

ion

with

out e

ver

doin

g it

the

sam

e w

ay tw

ice.

"

a m

illio

n tim

es o

ver,

Chr

isto

pher

Ale

xand

er

Page 3: Patterns What are Patterns? Software Patterns Design ...utdallas.edu/~chung/SA/pattern.pdf · Facade Memento Flyweight ... Design Patterns Catalog Pattern Data Access Object Fast-Lane

Law

ren

ce C

hu

ng

So

ftw

are

Pat

tern

s

✈A

Dic

tio

nar

y D

efin

itio

n

A d

isce

rnib

le c

oher

ent s

yste

m b

ased

on

the

inte

nded

inte

rrel

atio

nshi

ps

✈K

ind

s o

f S

oft

war

e P

atte

rns

(Sw

) A

rch.

Des

ign

(Sw

) D

etai

led

Des

ign

Sys

tem

s E

ngin

eerin

gC

onte

xtSy

stem

s Sp

ec.

(Sw

) R

eqs.

Ana

lysi

sP

robl

em

SAD

S

SRS

SDD

S

SA

D

(SD

) D

esig

n

Impl

emen

tatio

nPr

ogra

mId

iom

s

of c

ompo

nent

par

ts[W

ebst

er C

olle

giat

e]

Page 4: Patterns What are Patterns? Software Patterns Design ...utdallas.edu/~chung/SA/pattern.pdf · Facade Memento Flyweight ... Design Patterns Catalog Pattern Data Access Object Fast-Lane

Law

ren

ce C

hu

ng

Des

ign

Pat

tern

s

✈A

key

so

urc

e

[Eric

h G

amm

a, R

icha

rd H

elm

, Ral

ph J

ohns

on, J

ohn

Vlis

side

s] (

GoF

)

✇E

lem

ents

of R

eusa

ble

Obj

ect-

Orie

nted

Sof

twar

e

✈C

ateg

ori

es o

f d

esig

n p

atte

rns

✇B

y pu

rpos

e (w

hat

doe

s a

patt

ern

do?

)

✜C

reat

iona

l:

✜S

truc

tura

l:

✜B

ehav

iora

l:

conc

erns

the

proc

ess

of o

bjec

t cre

atrio

n

conc

erns

the

com

posit

ion

of c

lass

es o

r obj

ects

conc

erns

the

ways

in w

hich

cla

sses

or o

bjec

ts in

tera

ct

and

dist

ribut

e re

spon

sibilit

y (e

.g.,

algo

rithm

s an

d flo

w of

con

trl)

✇B

y sc

ope

(Is

the

patt

ern

for

clas

ses

or in

stan

ces?

)

Nam

e, P

robl

em, S

olut

ion,

Con

sequ

ence

s

✈F

ou

r es

sen

tial

ele

men

ts

A c

atal

ogue

of 2

3 de

sign

pat

tern

s

Page 5: Patterns What are Patterns? Software Patterns Design ...utdallas.edu/~chung/SA/pattern.pdf · Facade Memento Flyweight ... Design Patterns Catalog Pattern Data Access Object Fast-Lane

�����

�����

�����

�����

�����

�����

�����

�����

�����

�����

�����

�����

�����

�����

�����

�����

�����

ab

c

ab c

view

Hvi

ew P

mod

el M

a =

50%

b =

30%

c =

20%

con

trol

ler

Cview

= H

view

= P

keyb

oard

mou

sem

icro

phon

e

Law

ren

ce C

hu

ng

Des

ign

Pat

tern

s: A

n E

xam

ple

✈M

VC

(M

od

el-V

iew

-Co

ntr

olle

r) c

lass

es f

or

UI (

in S

mal

ltal

k-80

)

❁M

odel

: app

licat

ion

obje

ct

❁V

iew

: scr

een

pres

enta

tion

❁C

ontr

olle

r: th

e w

ay th

e U

I rea

cts

to u

ser

inpu

t

✇A

dvan

tage

s

✜de

coup

ling

of v

iew

s fr

om m

odel

sap

plic

able

to a

mor

e ge

nera

l pro

blem

: dec

oupl

ing

obje

cts

so th

at c

hang

es to

one

can

affe

ctan

y nu

mbe

r of

oth

ers

with

out r

equi

ring

the

chan

ged

obje

ct to

kno

w d

etai

ls o

f the

oth

ers

= O

bser

ver

Page 6: Patterns What are Patterns? Software Patterns Design ...utdallas.edu/~chung/SA/pattern.pdf · Facade Memento Flyweight ... Design Patterns Catalog Pattern Data Access Object Fast-Lane

Whe

n an

abs

trac

tion

has

two

aspe

cts,

one

dep

ende

nt o

n th

e ot

her

....

lets

you

var

y an

d re

use

them

inde

pend

ently

✜ ✜W

hen

a ch

ange

to o

ne o

bjec

t req

uire

s ch

angi

ng o

ther

s,an

d yo

u do

n’t k

now

how

man

y ob

ject

s ne

ed to

be

chan

ged

✜W

hen

an o

bjec

t sho

uld

be a

ble

to n

otify

oth

er o

bjec

ts w

ithou

t mak

ing

assu

mpt

ions

abo

ut w

ho th

ese

obje

cts

are

Law

ren

ce C

hu

ng

OB

SE

RV

ER

Obj

ect B

ehav

iora

l

Inte

nt Def

ine

a on

e-to

-man

y de

pend

ency

bet

wee

n ob

ject

s so

that

whe

n on

e ob

ject

chan

ges

stat

e, a

ll its

dep

ende

nts

are

notif

ied

and

upda

ted

auto

mat

ical

ly.

Als

o K

no

wn

As

Dep

ende

nts,

Pub

lish-

Sub

scrib

e

Mo

tiva

tio

n

... Y

ou d

on’t

wan

t to

achi

eve

cons

iste

ncy

by m

akin

g th

e cl

asse

s tig

htly

cou

pled

,be

caus

e th

at r

educ

es th

eir

reus

abili

ty ..

.

Ap

plic

abili

ty

Use

the

Obs

erve

r pa

ttern

in a

ny o

f the

follo

win

g si

tuat

ions

:

Page 7: Patterns What are Patterns? Software Patterns Design ...utdallas.edu/~chung/SA/pattern.pdf · Facade Memento Flyweight ... Design Patterns Catalog Pattern Data Access Object Fast-Lane

for

all o

in o

bser

vers

{o-

>U

pdat

e()

}

Law

ren

ce C

hu

ng

OB

SE

RV

ER

Obj

ect B

ehav

iora

l

Str

uct

ure

Atta

ch(O

bser

ver)

Su

bje

ct

Det

ach(

Obs

erve

r)N

otify

()

Co

ncr

eteS

ub

ject

Get

Sta

te()

subj

ectS

tate

retu

rn s

ubje

ctS

tate

Ob

serv

erU

pdat

e()

Co

ncr

eteO

bse

rver

Upd

ate(

)

obse

rver

Sta

te

obse

rver

Sta

te =

subj

ect-

>G

etS

tate

()

obse

rver

s

subj

ect

Par

tici

pan

ts

✜S

ubje

ct: k

now

s its

obs

erve

rs. A

ny n

umbe

r of

Obs

erve

r ob

ject

s m

ay o

bser

ve a

sub

ject

prov

ides

an

inte

rfac

e fo

r at

tach

ing

and

deta

chin

g O

bsev

er o

bjec

ts

✜O

bser

ver:

def

ines

an

upda

ting

inte

rfac

e fo

r ob

ject

s to

be

notif

ied

of c

hang

es in

a s

ubje

ct

✜C

oncr

eteS

ubje

ct: s

tore

s st

ate

of in

tere

st to

Con

cret

eObs

erve

r ob

ject

s;se

nds

a no

tific

atio

n to

its

obse

rver

s w

hen

its s

tate

cha

nges

✜C

oncr

eteO

bser

ver:

mai

ntai

ns a

ref

eren

ce to

a C

oncr

eteS

ubje

ct o

bjec

t;st

ores

sta

te th

at s

houl

d st

ay c

onsi

sten

t with

the

subj

ect’s

impl

emen

ts O

bser

ver

upda

ting

inte

rfac

e to

kee

p its

sta

te c

onsi

sten

t w s

ubje

ct’s

Page 8: Patterns What are Patterns? Software Patterns Design ...utdallas.edu/~chung/SA/pattern.pdf · Facade Memento Flyweight ... Design Patterns Catalog Pattern Data Access Object Fast-Lane

Law

ren

ce C

hu

ng

OB

SE

RV

ER

Obj

ect B

ehav

iora

l

Co

llab

ora

tio

ns

... T

he fo

llow

ing

inte

ract

ion

diag

ram

illu

stra

tes

the

colla

bora

tions

bet

w a

sub

ject

& tw

o ob

serv

ers:

aConcreteSubject

aConcreteObserver

anotherConcreteObserver

SetState()

Notify()

Update()

GetState()

Update()

GetState()

Co

nse

qu

ence

s✜

Abs

trac

t cou

plin

g be

tw S

ubje

ct &

Obs

erve

r: A

ll a

subj

ect k

now

s is

that

it h

as a

list

of o

bser

vers

.

✜S

uppo

rt fo

r br

oadc

ast c

omm

unic

aito

n✜

Upe

xpec

ted

upda

tes:

one

sub

ject

ope

ratio

n m

ay c

ause

a c

asca

de o

f upd

ates

to o

bser

vers

& th

eir

depe

nden

t obj

ects

Imp

lem

enta

tio

nM

appi

ng s

ubje

cts

to th

eir

obse

rver

s; O

bser

ving

mor

e th

an o

ne s

ubje

ct;

Who

trig

gers

the

upda

te?;

Dan

glin

g re

fere

nces

to d

elet

ed s

ubje

cts;

...

Page 9: Patterns What are Patterns? Software Patterns Design ...utdallas.edu/~chung/SA/pattern.pdf · Facade Memento Flyweight ... Design Patterns Catalog Pattern Data Access Object Fast-Lane

������

������

������

������

������

������

�����

�����

�����

�����

�����

ab

ca

b c

view

Hvi

ew P

mod

el M

a =

50%

b =

30%

c =

20%

con

trol

ler

Cview

= H

view

= P

keyb

oard

mou

sem

icro

phon

e

❁M

odel

: app

licat

ion

obje

ct❁

Vie

w: s

cree

n pr

esen

tatio

n❁

Con

trol

ler:

the

way

the

UI r

eact

s to

use

r in

put

Law

ren

ce C

hu

ng

Des

ign

Pat

tern

s: A

n E

xam

ple

✈M

VC

(M

od

el-V

iew

-Co

ntr

olle

r) c

lass

es f

or

UI (

in S

mal

ltal

k-80

)

✇A

dvan

tage

s

✜de

coup

ling

of v

iew

s fr

om m

odel

sap

plic

able

to a

mor

e ge

nera

l pro

blem

: dec

oupl

ing

obje

cts

so th

at c

hang

es to

one

can

affe

ctan

y nu

mbe

r of

oth

ers

with

out r

equi

ring

the

chan

ged

obje

ct to

kno

w d

etai

ls o

f the

oth

ers

= O

bser

ver

✜ne

stin

g of

vie

ws

(con

trol

pan

el o

f but

tons

of b

utto

ns o

f ...)

appl

icab

le to

a m

ore

gene

ral p

robl

em: g

roup

obj

ects

& tr

eat t

he g

roup

like

an

indi

vidu

al o

bjec

t =

Com

posi

te✜

Con

trol

ler

for

chan

ging

the

way

a v

iew

res

pond

s to

use

r in

put

with

out c

hang

ing

the

visu

al r

ep.

appl

icab

le to

a m

ore

gene

ral p

robl

em: r

epla

ce a

n al

gorit

hm s

tatic

ally

or

dyna

mic

ally

= S

trat

egy

✜sp

ecify

a d

efau

lt cl

ass

(for

con

trol

ler)

= F

acto

ry M

eth

odad

d sc

rolli

ng to

a v

iew

= D

ecor

ator

Page 10: Patterns What are Patterns? Software Patterns Design ...utdallas.edu/~chung/SA/pattern.pdf · Facade Memento Flyweight ... Design Patterns Catalog Pattern Data Access Object Fast-Lane

Law

ren

ce C

hu

ng

Co

mp

osi

teO

bjec

t Str

uctu

ral

Inte

nt Com

pose

obj

ects

into

tree

str

uctu

res

to r

epre

sent

par

t-w

hole

hie

rarc

hies

.C

ompo

site

lets

clie

nts

trea

t ind

ivid

ual o

bjec

ts a

nd c

ompo

sitio

ns o

f obj

ects

uni

form

ly.

Mo

tiva

tio

n

... G

raph

ic a

pplic

atio

ns li

ke d

raw

ing

edito

rs a

nd s

chem

atic

cap

ture

sys

tem

s le

tus

ers

build

com

plex

dia

gram

s ou

t of s

impl

e co

mpo

nent

s. T

he u

ser

can

grou

pco

mpo

nent

s to

form

larg

er c

ompo

nent

s, w

hich

in tu

rn c

an b

e gr

oupe

d to

form

stil

lla

rger

com

pone

nts

...

Ap

plic

abili

ty

Use

the

Com

posi

te p

atte

rn w

hen

you

wan

t to

repr

esen

t par

t-w

hole

hie

rarc

hies

of o

bjec

ts✜ ✜

you

wan

t to

clie

nts

to b

e ab

le to

igno

re th

e di

ffere

nce

betw

een

com

posi

tions

of

obje

cts

and

indi

ficua

l obj

ects

. Clie

nts

will

trea

t all

obje

cts

in th

e co

mpo

site

stru

ctur

e un

iform

ly.

Page 11: Patterns What are Patterns? Software Patterns Design ...utdallas.edu/~chung/SA/pattern.pdf · Facade Memento Flyweight ... Design Patterns Catalog Pattern Data Access Object Fast-Lane

Co

mp

on

ent

Ope

ratio

n()

Add

(Com

pone

nt)

Rem

ove(

Com

pone

nt)

Get

Chi

ld(in

t)

aCo

mp

osi

te aCo

mp

osi

teaL

eaf

aLea

faL

eaf

aLea

faL

eaf

Law

ren

ce C

hu

ng

Co

mp

osi

teO

bjec

t Str

uctu

ral

Str

uct

ure

Com

pose

obj

ects

into

tree

str

uctu

res

to r

epre

sent

par

t-w

hole

hie

rarc

hies

.C

ompo

site

lets

clie

nts

trea

t ind

ivid

ual o

bjec

ts a

nd c

ompo

sitio

ns o

f obj

ects

uni

form

ly.

A ty

pica

l Com

posi

te o

bjec

t str

uctu

re m

ight

look

like

this

:

Co

mp

osi

te

Ope

ratio

n()

Add

(Com

pone

nt)

Rem

ove(

Com

pone

nt)

Get

Chi

ld(in

t)

Ope

ratio

n()

Lea

f

Clie

nt

fora

ll g

in c

hild

ren

g.O

pera

tion(

);

child

ren

Page 12: Patterns What are Patterns? Software Patterns Design ...utdallas.edu/~chung/SA/pattern.pdf · Facade Memento Flyweight ... Design Patterns Catalog Pattern Data Access Object Fast-Lane

Law

ren

ce C

hu

ng

Co

mp

osi

teO

bjec

t Str

uctu

ral

Mo

tiva

tio

n (

con

tin

ued

)

Co

mp

osi

te

Ope

ratio

n()

Add

(Com

pone

nt)

Rem

ove(

Com

pone

nt)

Get

Chi

ld(in

t)

fora

ll g

in g

raph

ics

g.D

raw

();

Gra

ph

ic

Dra

w()

Add

(Gra

phic

)R

emov

e(G

raph

ic)

Get

Chi

ld(in

t)

add

g to

list

of g

raph

ics

Dra

w()

Rec

tan

gle

Dra

w()

Lin

eD

raw

()T

ext

grap

hics

Page 13: Patterns What are Patterns? Software Patterns Design ...utdallas.edu/~chung/SA/pattern.pdf · Facade Memento Flyweight ... Design Patterns Catalog Pattern Data Access Object Fast-Lane

Law

ren

ce C

hu

ng

ST

RA

TE

GY

Obj

ect B

ehav

iora

l

Inte

nt Def

ine

a fa

mily

of a

lgor

ithm

s, e

ncap

sula

te e

ach

one,

and

mak

e th

em

inte

rcha

ngea

ble.

Str

ateg

y le

ts th

e al

gorit

hm v

ary

inde

pend

ently

from

clie

nts

that

use

it.

Als

o K

no

wn

As

Pol

icy

Mo

tiva

tio

n

Man

y al

gorit

hms

exis

t for

bre

akin

g a

stre

am o

f tex

t int

o lin

es. H

ard-

writ

ing

all s

uch

into

the

clas

ses

that

req

uire

them

isn’

t des

irabl

e fo

r se

vera

l rea

sons

:

✜In

clus

ion

of th

e lin

ebre

akin

g co

de in

the

clie

nt m

akes

it m

ore

com

plex

bigg

er a

nd h

arde

r to

mai

ntai

n, e

sp. i

f to

supp

ort m

ultip

le li

nebr

eaki

ng a

lgor

ithm

s

✜D

iffer

nt a

lgor

ithm

s w

ill b

e ap

prop

riate

at d

iffer

ent t

imes

✜di

fficu

lt to

add

new

alg

orith

ms

and

vary

exi

stin

g on

es w

hen

lineb

reak

ing

is a

nin

tegr

al p

art o

f the

clie

nt

Ap

plic

abili

ty

Use

the

Str

ateg

y pa

ttern

whe

n

✜m

any

rela

ted

clas

ses

diffe

r on

ly in

thei

r be

havi

or

✜ne

ed d

iffer

ent v

aria

nts

of a

n al

gorit

hm, i

mpl

emen

ted

as a

cla

ss h

iera

rchy

✜an

alg

orith

m u

ses

data

that

the

clie

nt s

houl

dn’t

know

abo

ut

Page 14: Patterns What are Patterns? Software Patterns Design ...utdallas.edu/~chung/SA/pattern.pdf · Facade Memento Flyweight ... Design Patterns Catalog Pattern Data Access Object Fast-Lane

Co

ncr

eteS

trat

egyC

Alg

orith

mic

Inte

rfac

e()

Law

ren

ce C

hu

ng

Str

ateg

yO

bjec

t Beh

avio

ral

Str

uct

ure

Par

tici

pan

ts

Str

ateg

y

Co

ncr

eteS

trat

egy

Co

nte

xt

Co

nte

xtC

onte

xtIn

terf

ace(

)S

trat

egy

Alg

orith

mIn

terf

ace(

)

stra

tegy

Co

ncr

eteS

trat

egyA

Alg

orith

mic

Inte

rfac

e()

Co

ncr

eteS

trat

egyB

Alg

orith

mic

Inte

rfac

e()

(Com

posi

tor) (Sim

pleC

ompo

sito

r, T

eXC

ompo

sito

r, A

rray

Com

posi

tor)

(Com

posi

tion)

decl

ares

an

inte

rfac

e co

mm

on to

all

supp

orte

d al

gorit

hms.

Con

text

use

s th

is in

terf

ce to

cal

l the

alg

orith

m d

efin

ed b

y a

Con

cret

eStr

ateg

y

impl

emen

ts th

e al

gorit

hm u

sing

the

Str

ateg

y in

terf

ace

conf

igur

ed w

ith a

Con

cret

eStr

ateg

ym

aint

ains

a r

efer

ece

to a

Str

ateg

y ob

ject

may

def

ine

an in

terf

ace

that

lets

Str

ateg

y ac

cess

its

data

Page 15: Patterns What are Patterns? Software Patterns Design ...utdallas.edu/~chung/SA/pattern.pdf · Facade Memento Flyweight ... Design Patterns Catalog Pattern Data Access Object Fast-Lane

Law

ren

ce C

hu

ng

Des

ign

Pat

tern

Sp

ace

Sco

pe

Cla

ssF

acto

ry M

etho

dA

dapt

er (

clas

s)In

terp

rete

r

Cre

atio

nal

Str

uct

ura

lB

ehav

iora

l

Pu

rpo

se

Tem

plat

e M

etho

d

Cha

in o

f Res

pons

ibili

tyO

bje

ctA

bstr

act F

acto

ry

Bui

lder

Ada

pter

(ob

ject

)

Brid

geC

omm

and

Pro

toty

peC

ompo

site

Itera

tor

Sin

glet

onD

ecor

ator

Med

iato

r

Fac

ade

Mem

ento

Fly

wei

ght

Obs

erve

r

Pro

xyS

tate

Str

ateg

y

Vis

itor

Page 16: Patterns What are Patterns? Software Patterns Design ...utdallas.edu/~chung/SA/pattern.pdf · Facade Memento Flyweight ... Design Patterns Catalog Pattern Data Access Object Fast-Lane

Law

ren

ce C

hu

ng

Arc

hit

ectu

ral P

atte

rns

✈R

ecal

l:

A =

<C

om, I

, Con

, P, S

, R>

✈P

atte

rn M

atch

ing

in IQ

Tes

t

choo

se th

e cl

oses

t mat

ch to

B.

C.

D.

A.

✈T

op

olo

gic

al V

iew

of

Arc

hit

ectu

ral P

atte

rns

P (

A)

= <

Com

, I>

Mo

del

ing

Vie

w o

f A

rch

itec

tura

l Pat

tern

s✈

P (

A)

= <

Com

, I, C

on, S

, R>

Page 17: Patterns What are Patterns? Software Patterns Design ...utdallas.edu/~chung/SA/pattern.pdf · Facade Memento Flyweight ... Design Patterns Catalog Pattern Data Access Object Fast-Lane

Law

ren

ce C

hu

ng

J2E

EJa

va 2

Pla

tform

Ent

erpr

ise

Edi

tion

✈V

isio

n✦

an o

pen

stan

dard

✦an

ythi

ng J

ava-

rela

ted

✦fo

r im

plem

entin

g an

d de

ploy

ing

com

pone

nt-b

ased

ent

erpr

ise

appl

icat

ions

✈C

om

mer

ical

pla

tfo

rms

✦W

ebLo

gic

(BE

A S

yste

ms)

✦W

ebS

pher

e (I

BM

)

✦iP

lane

t (S

un &

Net

Sca

pe)

✦JB

oss

(ope

n so

urce

)

✈R

efer

ence

ap

plic

atio

n

✦P

et S

tore

✈S

ervi

ces

EJB

com

pone

nts

✦ ✦JD

BC

AP

I

✦C

OR

BA

tech

nolo

gy✦

Java

Ser

vlet

s A

PI

✦X

ML

tech

nolo

gy

Page 18: Patterns What are Patterns? Software Patterns Design ...utdallas.edu/~chung/SA/pattern.pdf · Facade Memento Flyweight ... Design Patterns Catalog Pattern Data Access Object Fast-Lane

Law

ren

ce C

hu

ng

http

://ja

va.s

un.c

om/j2

ee/tu

toria

l/1_3

-fcs

/doc

/Ove

rvie

w2.

htm

l#68

378

J2E

E D

istr

ibu

ted

Mu

ltit

iere

d A

pp

licat

ion

s

App

licat

ion

J2E

EA

pp

licat

ion

1J2

EE

Ap

plic

atio

n2

Clie

nt/A

pple

t

En

terp

rise

Bea

ns

En

terp

rise

Bea

ns

Dat

abas

eE

RP

/TP

/...

Clie

nt

Tie

r

Web

Tie

r

Bu

sin

ess

Tie

r

EIS

Tie

r

Clie

nt

Mac

hin

e

J2E

E S

erve

r M

ach

ine

Dat

abas

e Se

rver

Mac

hine

JSP

pag

esJa

va S

erve

rlet/

(Dyn

amic

) H

TM

L/W

ML/

.. W

ebpa

ges

✈E

JB:

serv

er-s

ide

com

pone

nt c

onta

inin

g th

e bu

sine

ss lo

gic

of a

n ap

plic

atio

n.T

he a

pplic

atio

n cl

ient

s in

voke

thei

r m

etho

ds

Page 19: Patterns What are Patterns? Software Patterns Design ...utdallas.edu/~chung/SA/pattern.pdf · Facade Memento Flyweight ... Design Patterns Catalog Pattern Data Access Object Fast-Lane

Clie

nt T

ier

Reso

urce

Tie

r

Inte

grat

ion

Tier

Busi

ness

Tie

r

JMS/

JDBC

/...

DB/e

xter

nal-r

esou

rces

Pres

enta

tion

Tier

5-T

ier

Mo

del

Law

ren

ce C

hu

ng

http

://ja

va.s

un.c

om/fe

atur

es/2

001/

03/p

atte

rns.

htm

l

J2E

E 5

-Tie

r M

od

el &

Des

ign

Pat

tern

s

* JM

S =

Java

Mes

sage

Ser

vice

API;

* JDB

C =

Java

Dat

abas

e Co

nnec

tivity

API

;

App

licat

ion

J2E

E

Ap

plic

atio

n1

J2E

E

Ap

plic

atio

n2

Clie

nt/A

pple

t

En

terp

rise

Bea

ns

En

terp

rise

Bea

ns

Dat

abas

eE

RP

/TP

/...

Clie

nt

Tie

r

Web

Tie

r

Bu

sin

ess

Tie

r

EIS

Tie

r

Clie

nt

Mac

hin

e

J2E

E S

erve

r M

ach

ine

Dat

abas

e Se

rver

Mac

hine

JSP

pag

es

Java

Ser

verle

t/

(Dyn

amic

) H

TM

L/

WM

L/..

Web

page

s

J2EE Design Patterns

Page 20: Patterns What are Patterns? Software Patterns Design ...utdallas.edu/~chung/SA/pattern.pdf · Facade Memento Flyweight ... Design Patterns Catalog Pattern Data Access Object Fast-Lane
Page 21: Patterns What are Patterns? Software Patterns Design ...utdallas.edu/~chung/SA/pattern.pdf · Facade Memento Flyweight ... Design Patterns Catalog Pattern Data Access Object Fast-Lane

Web

ser

vice

XM

L-b

ased

Law

ren

ce C

hu

ng

J2E

E D

esig

n P

atte

rns

http

://ja

va.s

un.c

om/j2

ee/b

luep

rints

/des

ign_

patte

rns/

cata

log.

htm

l

Cla

ssic

Web

Cus

tom

erB

2B a

gent

Sup

plie

rC

usto

mer

Wire

less

Adm

inis

trat

or

view

JFC

/Sw

ing

view

view

WM

LH

TM

L

Info

rmat

ion

Syst

emE

nter

pris

e

The

prob

lem

: Sup

porti

ng M

ultip

le E

nter

prise

Clie

nts

✈D

esig

n P

atte

rns

Cat

alo

g

Pat

tern

Dat

a A

cces

s O

bjec

t

Fas

t-La

ne R

eade

r

Fro

nt C

ontr

olle

r

Pag

e-by

-Pag

e Ite

rato

r

Inte

nt

Ses

sion

Fac

ade

Val

ue O

bjec

tP

rovi

de a

uni

fied,

wor

kflo

w-o

rient

ed in

terf

ace

to a

set

of e

nter

pris

e be

ans

A So

lutio

n: M

odel

-Vie

w-Co

ntro

ller A

rchi

tect

ure

Acc

eler

ate

read

-onl

y da

ta b

y no

t usi

ng e

nter

pris

e be

ans

Page 22: Patterns What are Patterns? Software Patterns Design ...utdallas.edu/~chung/SA/pattern.pdf · Facade Memento Flyweight ... Design Patterns Catalog Pattern Data Access Object Fast-Lane

Law

ren

ce C

hu

ng

Pat

tern

s: S

till

Evo

lvin

g ..

.

✦N

ot

abo

ut

det

aile

d d

esig

n:

Arc

hit

ectu

ral P

atte

rns:

cf. t

he S

trat

egy

desi

gn p

atte

rn fo

r al

gorit

hms

✈✦A

nti

-Pat

tern

s:

Tho

se th

at d

escr

ibe

a ba

d so

lutio

n to

a p

robl

em w

hich

res

ulte

d in

a b

ad s

ituat

ion.

✦T

hose

that

des

crib

e ho

w to

get

out

of a

bad

situ

atio

n an

d ho

w to

pro

ceed

from

ther

e to

a g

ood

solu

tion

✈P

rob

lem

Pat

tern

s:

orga

niza

tiona

l/ent

erpr

ise,

bus

ines

s ru

les/

logi

c, a

gent

inte

ract

ion,

goa

l int

erac

tion

task

, res

ourc

e us

age

stru

ctur

al (

entit

y, a

ctiv

ity, c

onst

rain

ts),

beh

avio

ral,

nfr

✈O

O S

oft

war

e F

ram

ewo

rk [

Go

F]:

a se

t of c

oope

ratin

g cl

asse

s th

at m

ake

up a

reu

sabl

e de

sign

for

a sp

ecifi

c cl

ass

ofso

ftwar

e

✈ ✈

Pat

tern

Min

ing

:

QW

AN

(Q

ual

ity

Wit

ho

ut

A N

ame)

[A

lexa

nd

er]:

univ

ersa

lly r

ecog

niza

ble

aest

hetic

bea

uty

and

orde

r;re

curs

ivel

y ne

sted

cen

ters

of s

ymm

etry

and

bal

ance

life

and

who

lene

ss; r

esili

ence

, ada

ptab

ility

, and

dur

abili

tyhu

man

com

fort

and

sat

isfa

ctio

n; e

mot

iona

l and

cog

nitiv

e re

sona

nce