design patterns complete notes (natraz)

48
JavaEra.com A Perfect Place for All Java Resources Core Java | Servlet | JSP | JDBC | Struts | Hibernate | Spring Java Projects | FAQ’s | Interview Questions | Sample Programs Certification Stuff | eBooks | Interview Tips | Forums | Java Discussions For More Java Stuff Visit www.JavaEra.com A Perfect Place for All Java Resources

Upload: sunil-soni

Post on 21-Jul-2016

60 views

Category:

Documents


4 download

DESCRIPTION

Design Patterns Complete Notes (Natraz)

TRANSCRIPT

Page 1: Design Patterns Complete Notes (Natraz)

JavaEra.com A Perfect Place for All Java Resources

Core Java | Servlet | JSP | JDBC | Struts | Hibernate | Spring

Java Projects | FAQ’s | Interview Questions | Sample Programs

Certification Stuff | eBooks | Interview Tips | Forums | Java Discussions

For More Java Stuff Visit

www.JavaEra.com

A Perfect Place for All Java Resources

Page 2: Design Patterns Complete Notes (Natraz)

Oesign pa$e'rn '. -

Ith;ch cornes a$ -fest soltnhidn

De$ign filfcr n S a"re 6u.St praoi ceS lO

dgloj,rrrTy .

----t D€5i0h pdrteln av[

-) -7he $(rst Soltr ticn

Aon - WlIetn

-) the Cr{Lri"fuV1(h TSo rrrcq n tcrl n5 leorb desl I h

pla.ce inDes)$n f8H,e!n5 a.re

Geracrqrltr pLITL dcrtlopeog

pt4'n arJ

c"J 1"3 f },"s" o?

,rPeciBad rhe

a there 6yg Eog+ Jesign pet&o nJ in Java kntt;rcnt*'t'J '

-) pesl gn plkrns cc.n be impler',evrled rr5 t^t;n1 to"X slur fcchnoloSU ' [or) pmSronn;"8 Lo"iJ",?e

-i JdF wr-@r--!9ry!li-'Singie fdn java c lass

69'*hroni xJ $nglet-on jaua clc'ss

[-aLrort Yoerlod I *n*l

Absi"au Fad-ar $

T€Ynplarc rnerho d

Et-.itdel Prtc'n

pmtfrne P&rn

flg c,:eifhr lzrErn

f 0c (rnvigidn of runFr o I ) P'rltn h

clc!(9

"<trd e {

JDro iias osic^r

- '" hre,o lera.l d es ; 3n

Vielo llel()e'l

Crrn06sii V ia(,

Vci mve3M\,(a

Fnnt (rmrr o lltr

lnLrncephnt BfuuAb gh acr acr'^ tYo \\ e1

priic{ n

frr rt "t n-e prob)e/Ds

use Slto le}ndogieS

value oblcd cle\5 lr;n f,.*"tfu sLfui ckt '

,I'fr lat | >ot:-

o? aff,t'tahctY, dt*brr*nt .

ePfer; uEJt ln pn j€d 6( a14'Lraa,t)oa

$.pr-riry cale arbtte J-.6png slq, Pro,.r'ers by "s;g pb:, leolrradogies,

f^ '%l -" pvob\ero 6:f pyD.ie.tl' 6/ a?pljcai 6h derxUy*,r is c-ojxe./ os

iol pleoen l.atita +..Kes

derign g $e +asu +!'(

l&9'c;n ;srlfi n9 and dadcnc s c,r) tt irnP)lment rhem talut" J'1"6

ahii-Faflcrn"

pra.lec Jorl" Prt elf '

neeJ ttnd a16l ;za't'lon oP

TatV C*tPtiioo '

AdctPftr

Fesn li h e

v. o o(r},o&4

Page 3: Design Patterns Complete Notes (Natraz)

foltgrdtifn laqC-. Der;€n Pr:.fftYn 3 : -

Sessiqn Prrc.(d e

t'\ es sag gF.,rc. d 3

-> *nior Jnv"lol.os JuriSr,s Sol,'H o', s +- no,j..'^ti',J -t

w6I.ns a( *cl,nolop9 dti lizotjoor .ollt,"e os l"e 1t^nicn -,Jetr)oye's 'laie hst Sduitns a't4 4'"n o' )

2gs tl^.t a! d*,6"J frLk'ns'$trvteLa-cf<1

&sines Sl)cli$a-hc

,". i.toOet Layr"i ;-

DA o ( tlla lt{ esl

Ab6tYac,r DDo

obi )

-P S,*otn Java class

!4I:i--&$sHn3hlqb de merftn q

,J

@'+ rn,u''ple jirns3 .

ry:- Use singlera n iavo. clcrls -

f.atThe joua c\al6 '- ollcrrs d€

-, the logge* clors d r|'e

---. Ahe Se.!v lce k# locilcY

0 iU must l'"tte or,l,J fri 'J al-t aon sl.rkc]rctrs .

rr.rsr L* *'in o'. -P*\'r*['J ho'i"6 rde lu6i' u( $okr-. t".-'" ilj ;flj:'il

fr\ {crc vtr{es closc orr 4t J'--s + C*"h"A odttFs + j*oclb*" c^) op"'r unt6one

h" h o-s< otic4t.e. Tn 4)%J nk* St^f,ean l3r'i' pl""r)'

1e ,ocrlod og o clos i.e " 6c.po-ble 4 37eoling On J <rol'i n5

f,nslca/ oP (YEdir,$ rru lhYie

, degtc,d," X fxrrf6 eaqlp-

6qjecm oP ;hoa cla-n

f+ is recomende J tro

lo.,,"U &-"&r. o'd

Cl{a.l.. b.r)< 64at 6" J

^ a r bn;ra,<

CJ nous t hdr,{r Sla}i c qtf1rt.te Vadd$le

gVe{ 'r ilg Clc'neL) to Scrrpre lS

tn 5z.me clavsrc /onln 3 prore rs .

€r

0

fu c"recl.lt One oqj€d F,( Jvm ls Cq-r ted ar Sf13lef.", "ia^:a_

cla11 .

Los+j Ap: is diwn as gqllet _ jaLT4 daa-

jw" c,luuclc.x toitl 5e irnplzren rcd aS 3;r6l*"n

a,-

a

6611t I &s ft.ro.1 rcrl'".\

9*t ar od\c.( clcds

Page 4: Design Patterns Complete Notes (Natraz)

t

,-z llstttic {-aC."g nerlloJ

lllblic S lali c $r.st crqg( )\v.

L

\v

a <ftJurrl h 't\-'J l/clas s

prblic c-lcnq f,;ngreronTes f

Lf Sw,nlU o'rs )P s vrn

i$f..rr

llow c*"a"n lo)t^6 9a6lrr,,

iPIn==n,,11;

n =h.!t) STe*tt )

h

_ ll S;oileTanlcsr.JavA

Cld95 STes+{7

/lgotlc r.efetore varta-bte

plivcrt€ Sl-ati c $Tesr b=nqt,

/, Irnvotr Ct ttshuetw

.!,7 ftllcltse Srestt IJL

l'4;c

s'o' P ( '' sresr : o -paxern , &r6h.!rr4 (a;vat )' ),'

1, =$Terr' ctaJ< C );

s.o ,p ( 6, trbj lrrashcode i5 '' + t' 'l^rt3;" t x) ,'

fi-:16=

s'D,P L" t> t, ,,'+b.harlGrec) ) j

g.o.f (" tl tl ,,.+g.h"shCode() j,.

Stest t+ = ( Sresr) t3. ctone();

S.o,n ( L', oL, n+tu hartro'{c(r-

\--l5-r

-- ir.r./a c S inglr L0on lest 'iau^

7 jr*o Stn1ll. hnTctr.

\'J

Page 5: Design Patterns Complete Notes (Natraz)

-) iav6' lang. Qantirre c lass iS2!:lYV

o ple-d€g bed Jdk ter€l Slngle fon jaraclc.ss-

p*I}- u<inl - ne,{ k€{rrord (x. ca,'r r cr€a$e cbi4r urrr}' 'Pr^iu; ut5 ar:d \ afdgn3 .'e< r';tlcos

grurlcrn i- (Jse fatrrrg nerld / ro.r.5 Utrt ..,

ile yrrtfiod 6f a javrr clt c5 i'e '

orlrer cltss ohject is CottPd 05 taclrrl pethod " ,

lte,e a'e koo rgrr5 6( t"cn 9 trr *,od

r) Srotic frcJor5 rubo d l) -3.6ic"nca Iorfon3 meiroct .

er"-O"r - ffilal.t8{trn€thods:

t= -Thvud. carrc Ttwad { ) j

6-- fra35'.fi:oNa-. I Test-1;

Qr.r,H-e vt = Qendme '6.1i)r.n6rr. e Ct ;

fat.',aen cl : Ca Lnde'r ' gtfnsru^ ce (t:"

L it ig not crt.''Jt't 'lois o$ecl ' iF i5 o$er "P yt'F""- Cc'tend<x clar5 p[cl" it c'["t"rs 4

\ _-/

(Te4,| o6eet 4 jdla ctc'vl a*s;de al i ts cLaN ) l'\t clatt cantaaa

ar\o vkfut ,Lr. dcuX;I S^Xlu-- io'a cJa+sce'

abgrraLt Ctossna"'u J inu tc're' rpme > petho cl [ rrrarn rovne)

olule rrrctrt"l n3

i5 rczorntnded tD

anJ ,rkr DJ€^

lrs ocon c lars(o{ )

-lt tea d

cl&6s

$rc'\dcr rtass (aSshacl c/4ss).

-) Ste'-c -fa,ro1 rrrrtrodf art Lrc& \

on\fl ptvaLt Gmsrr'-dqJ 'fhes' a'ft

probrjf.t og 5toti c 'ft<nx5 r'.uho d

pu5liC Sk tlc z clas S rome

i5 1€.cl'{qd€ I

Exomples 6', lmtonu -p.u,tt3 tncrhod : -

$t tng s? ne,.d Q't"g [-ov- );

3r - 5. ccnc o]rr ['t.ir d) I il Ok\et\o

-.Qg.,c1,ron; ze d SiDgleto n java .lasg :-

,j:kn muldpte rtrreads a.jg dt't siogle o \kcJ- rkn fia'e i$ a pss;5;ltt'J "f €.16"1 rnrrfr$read;n3 -.

iS:[€s , this chans€ iS olso tht,e

Cla55 . -TO orr o"rne ttL.is poblem ir

Thar rrrorrrg he 6h$ c &.i.r"1 *rma

ab S6hchYDrnzed merloJt

@) F".*t **r. / e**f po* t

gr,ltr,Ole { Corst'c.chnJ anJ etep'r"in 3

oirh tbe tt*ods o, S"61u * icroa

Lcsr 3n S;.,cbnai rx d Sr"g)er.- iooa clas< '

rle P;ne.l r.rrlrods 6( n-r d-s*\ vaust Ie la Lcm

f,tr;n'1

Page 6: Design Patterns Complete Notes (Natraz)

4,rrorg rrxrbo d '

t-

i

$x'ng&pput et = oero 6rcn6BuPf.' ('h"llD" ):'S*r"g 5a = sb'fcr.bSi.rog [o,e),. /f t"rr

prrc l=ierc \)aPt1 )

. $r"rnX s3 = J , 16 $wrn6 tl ;

LP u tnaot fo c.reax trol ' "U,iect

6trrn1 3r = nerl $r'rng ("or'):

$d.5 5r = 5r. corrot ( "herro ") :

f$'n3 .lors i5 imYrtriaile cl.(gs )

n',eficd ( sk;ng cl,br -*ft me (tdnX"lar: c&i

bj t6f"g e.lsrln$ oti d*a atA belollio<"'r *ren usc Dosl-6rrf€

&.to.

i

// ornerro

+ Fur-trrt Yr0ho d GdYr {€Jtrr n e.i*rn its oan c,b.rs ohictr (-s, otk, clc"rs ohlG ta') 6*cbx a8+

.._. e rhe c\pat gilr'n by &,tn ,*.a r€arr€ty+s cetw, Vrr-eNl lytc i'e'e^cdt'elio **yl

2,frd'ds *lxttn; n-6 enen1 o4rts- ( ol"tc''ts '"^*ft d'&ti*&)

* M\'tjl9i

5b' ofrcnd (- hert 0') :

[gung6"?Ft ctdc\4 i6 llctd,l€$r:"gl},t?e< ori ' 't

., l

clttl )

5rroto tgpe of Tnskarnce kcfdnj n:noA Z -

pblic Zc\elsname, aint<r &.e rwr c> f zattftatt cla$ naF'e> *tnol (-\

SnLq&ero, sb-- oero Sr""gB,ee. t-ol" ):

ci{ *st*u" d<rlel'ra i a"vo clavt-l

r.o6t cf rht pn&Rrtd ,atltf" U.*ar3

m,,laHe classcr'

Page 7: Design Patterns Complete Notes (Natraz)

// tfst'ia$r^( la{J ft(r-L int q',

+t6f ,b ',

ierr(ior a, ;nr u )I rl.;r'o-- ^ ;

l-hs L=b l

dprrS

ohliTe

coill fDf

ryI! l- p[an obytt

9me ou1at. -t a it i' cottd "

"*1"'9!e o!|t!'1irs tk+t it

cutA ,tt'*le cJet) ,

* oW dsd' i< 'n&h€L lP il i( \^'t *llott\ *"1' n&^t,

&,e*r dbj&f b"t ue!t'ts1 \' o '*lA (& objt'r *'a

,.(t,o^n b( ftja'*\ ^r.'";;'il 4- "* B ,o94

0t inm;*(c "LW (r*" c['as i' c-JtA ^ l'*-;*')'

or I oq lrorr

objcd-s . Dcre t'o *tjs oh1ecls a'Eib6i i i l-Y

.--. 'IO deu€bPe ttsc" - dehne d

{r ".r*iniq cldsses thj s kioJ o? Canstan 1- pools o'e

8i\En 0.5 ruhuble classes '

ttr, s Srrir5 cnnorant pot rhe jovo'lang ' Sr'in3 clals i5 dil'crD as irnrxr rarblt c1"!5 v

mF aval table ' gs ' rl-r5 aYe

cl&!9 rrust L€ ft not C lc'sS '

ffi hr rjari ouleS rn srbe 1ec\ce'n ab

c-o\,rr, &..fa nodi ficarrcm i 5 re1*r"cd

l,irri''1 lr6ic h .rerat n ntlD obars'

,,l

-)

pnrrrle I $"A

io it sinura- ue

1**@ @ rs4ip4e.

tgric Void "nafgD,rac;t

5

), *-n*' Tarl'ro''o)'

1' 4'^?1")j .u^ !,oar*toect". -+r' La:tcoac () )l

a'-"'j6i6p*t ct)

t:fit l''l*^ r*r^':'lF ra:Lc'art)) I

\llro^n

-> SniT Cqn6tant Pcbl

rrr.r)

---a 16

d? a*-a;

b=b*b)\

IL$uc Vdid d;tpr)is.o.f,('a="s+"5=.+)l

9

llctas

pl&\;c claL6 nddblcl;\r,t ., ^^n

,ru-[5'1Ii *lr)

ll auN

bt'*ry'*r6nr;6t-cln 3 3U4

be crtoled *tli

i mrrLtab\e .lava' c lctss I

"*de l.J ot:rYn'ble

pirr be occesfed

&tu ;' n"el)kt| i{ tt i.l ve{ltrfin3 ord r/< ^

\v

Van a-bte

.tD'-dane thr.,t3h {,1- r.er{."di

\J

Rom Poot aa need d

Page 8: Design Patterns Complete Notes (Natraz)

t'/l imrn ura.ble TegJ- 'Jav6.

9i.o I clast -Iee r

{ ,h'opr;v"r/iq-I.ai.

Pt;uoIt/ bmoS b"

//C*tw'"ro' s ,"

puu\;c -l.sr (t' ",bXi1 t)

{thv ' a ' a"

tlrc'b z t>"

5 o' I L'Tcst " ?-Qataw Co's w c'cttr " J ;

X*,.J .qr.a mtrffod oL<-,, D't6 'K,.l'h'"ba 3 *a1t;n I '

"^'1rl,,i--Li1- .ArqDr^ 1;", o'5r'n9 b)

{"

tctu.{n hed 'Ie5J (6' b ) '

5

p4rir 16y rod{iA (r^r "-){'**ln rreld T€lt (althis'b);

t .'-,

ptu. rest rno&fuS dll' ol

trtotn Y)c,^' Iell (rhis'a' I ))

,*n rY tft,{

<o 'P 1"a=

d/sP( )

,' *o*'5= " t.b),'

W_? o"16 4'*l clarscs o.'. vtot- I'nlntrtaltq ela

W S6."-r,er"rjB. llk,, x,,rcnar eLu-st.+

*o $not clat's. s b* t\ ^'"^ tiw,muta-Lle elntntt.

.j.\ ltctr'r s

Fr5ti6 c las6 lYnrn(k61e1f s t

sL," P. u."f5r'';1[l arls)t

t.rrt et=rle- mt tlo

"'YoJ

a" ) I

s'o ? ( - t oql has hcode '+5''ho..s}'9odec) );

t' dl:r(: i

r(Jr t'=g( ao'" rc'r'€:h" )l

t"- n i:O, rri h&s|.coh"'rtl'lokc"detl l'

t1 dise tr '-i &sr cl i

lerr rr- ' f 't',1F 1 !,11"t +tr.h,ib cod<())is'D't'L" 5r- obi [":ht

tr- 'J istL) 'L'A:sr L)l

ll ri"n"'

/l > iata

Irn,",(,-tdrlelat .lrvd

:;trntt-roAe '

3 /'u't".iU.t'lA

Page 9: Design Patterns Complete Notes (Natraz)

rnY Tetnprctrc o€$'od pesigo parkr n i ' '-J

\Jiastt ------) o.c) i

\_,/b(i;

::]; bere tocompler( Ibe ia,cl.t:e oeed fD rn-rlriple ,r:\o$ L1 )xt)l .rrrryrr bezinj rrrrbod rrorrps atd *xt'{ sel*q'Le o(

. )\--)

inVCr.tian, ,,--z-

use ltrr)rlole roe6o d _)

prbtic V6id rr6nerho d ( ) \{ \-/

&c); \btr; \)

cL) t \-/\d( )jII): Jt\

\-/t0$\a1 : mgrrerhoi()l

nooD cn\t cne rne,rbd needS to be colr bcornplere t&slc ' J

'\

The pyocers .n€tl,.,d 4 or3' ot!.che . S6c.ts . 6ricrr,. @atPoceosc,t .c-lc"'s culrs l{ pccess X^^c > llvmeb"dS in a qlrnce tb Ccrrdetc lhe +&sl.

.-)6or nurg rnp:ho d i5 co[ed Tcrnplo]e met+]o d '

-J &riirn S"uret slnurd c2lt oI' 6i5 lq roerhocts &"etrt Lo) Pcryst Pr,ccts da]" oL'iett 16 \-/

Cwn9t61y W"rtW. Eur i8 cdlrr o,r1 o"e n'r-rAoJ I e' p'*xO \-/

ri\ -a-- J

9FY FasrLine Rea&'r '.-

6^*--,"t'o"u oRv\ sl-s ll;re l'ru'nort) to c\aaog ?eTslsrcnLe

logc ;n ac'v sr"al\;

co''l medrtrro gale a{p6 -q deXo"de fl'e pe&""ance }ecarse /tere oPn tf(I]s J

infanat\ Se"erare jduc aede to cc'"net# r{p PQd6sff,','

lTic deu"lqw* :

DG slo, >_t d\l(I

litser ni're

EgS t"'lrjlgeo torn?

| 1on;c

rGffiA3i"-'rnog &3rc.de tle Pe'r{zrr"a*'ce

Use F*. L''e R"dc. cles;3n pcrrk'' n ,,

Page 10: Design Patterns Complete Notes (Natraz)

rhe \and tn &..rn Scale c4pliaorianS b inlercrf- cr) lrf)

hlrin jdbc 6otr. d;'..rl.J

db elto io ;rnPr# rhe

iq (r r Srmll

Rlfs" tt"t^ tt '

crbEtrc..cl:- h; Jtog rhe impltrntrialic'4

rar AbstraCr Facfar g gUrnrn i-

q19. t,hrte

|a&va rnslcr r1

d0'! i.;ot lL'irh the ohjeLl cteo-hL and t"l<t'n"l bj

cl&ss nortres of rloseb)a need h ePa,fo rhe

.hrt"1 nrth"A ecie*

o\ie.rS.

- !a* rJSe obotadcl fau*"tr 6'orrc'n tpluch ;o grirtnsicn DP Nt'n*1 gn.." '

'intt^r.ftre [rr) s]$crt d e.\thd Fra,n &rrroun clals 6 6bstraat clar '

\.-,, cbskdoic.n r'e&n s hiarng irnp{evrrenloltcn . eb6fo4t '&tr'x l"*t 'ttt class na'rs ol r$e

-,,, o{oett dbre venlvinX anJ utiti zin3 ttse ohietts

enHre f,dbc spd p;ca-6on Obc d+wrs ctevabryfr* and Ltdtizint flpse ddvctrs in octv

\.-- ldbc code 's hq'r'ehiq3 based cro obsrro* -t'o"t1 cleslgned portcro '

Gnnecti<rna-=D'naYb*g"''6tt(rn*tF*(&bc:odbc:oraAsr"]'#[*'";ggt')"

I-,encsnlsiduconr'hi*s-l-ltlstttohlttrc(idbcd"iuo{s'trTuaJjauactaxrl1al-

: irnplerr*r,ts jarn' srur ' G'"rtr"ion its

hL,re uf,are ooo,b,nl Loirh idbc "ccro' obj eoithou'h €)( P05;ng 66 d Lncrt'ln3 'i6

clax rnr"e

e!rr^ il.xrg h D",u.N4ongtL{ . get&nrerdon (-'- '- ) "p.11tr ris &eR^{'f clavet obr'ttt

\v' !,oru d cm jduc dviuw omd jclbc tot u.)a us( Ihis is

'srtr;ng Lu-l. 6l"swa* &'amj

: lhltt{n imp\errunr1tu-ti

cm'

:

Page 11: Design Patterns Complete Notes (Natraz)

y*.! Exarople 6n 6bA) ic,( r +i,u'..!11 irnCe'nenhCri-i('n).

ll cor*o. innr ft,1 a

inrtyR.re Aoc

t/]lbt,c vojd xyz();

.t

JJ i.Ple''r"t .ia3sr6 .!

Cldss Testt iroplercotS A(3 c

{P&b\id lesil ( ){

6.c p (' resir ").&

[tr'5llc Vo;d /4r z( )

S.c' P I x/. 69 Test] ' ):T

? 1f.",

/ ;'nnl*ne*raf ..n cl6.?-s a

Clats -Jbst?, irplcn're'r-l S +tsc

L

?&b\ic -las+at )

tt ".p I reva');

3

fr.uf iic Vcid xYz(){

e o.pf" xyr 4 fesrL"),'

1.

] 71resr1

CidcS De"no

t rzr \

\'<we pub\i( 6k.-hc Ats" t'(-Sil"6 '.'o-L )

l)4**X p*,if ( ',o,r'.' eyas ('a ' ))

' *n,,n neo"l lrrl t l:

eite if (rurv.1c. eX,,.olr l*.b")).rt.tltIn MLLu -Te:fa t) ;

{ l5r

3 1 .r€ttt\r'r 4u\l i

Page 12: Design Patterns Complete Notes (Natraz)

ll aw,t

clc's

uAc

{U.r'o.rE rtlt"tr

s v !n (Sn,, o'6e | 1

ll oLrv*"+ -1",r"7 y"tt ^

45. otr = D,'^o''"r, f""n't"l )'a tt. xyz() l

1ll","L,.r fl cIM

2lauac -AL"r*'*frtt"7T"'t- 'it' ^

Ziott^ -*tn"*t-c'*\ iaL

fn"Uttc

fL

P

slJ6,':;a^1

>J*uo *-tb"'&-d.\

& *lu^ ;^{.".orr- a^ I dot'J €xamlle o'^ ' o!'u"*t-'n1 S^*n 'YLfcr{ fvfQ^bs" z

Pr[!g: C,,rdlloj ner.,J Prcrn Scr.rrt), le''tl ho';'-'3 *rc ex;srin3 ohir-rl dc+r. h^s

d.id

;-':;,,: ff"ffi] .,,.- ntnohkt conlzdns u*t;"6-&nr,ra

':=:'

i";raa! d"$- |nl @sr,utllr/ 6ill nd Lt a'<eoutd 1,,'tn6 oblttt ''l€d-f,ton '

-7 plrn o 6iars ue c*"l'aA " na' Vtr'a^l Clflsfrultals /]lu k e^eeu4l -f- "U'eo J.fa

;hJrra-fi 2""44, :'2 6fu'r' oLJ€rt-s G{c c'd'a k cb';1 Ce'tro.l'o6 tcitt nof Je

ebun)&I . pecorre 'i{t', ;t vo n(el '( oLtffi i';uc'Lt;^n ^<L' 6Ft3 tLol t*

c**d h, ctoc,-^t^'6 (* +rf oV eoi'u^'UN&'*a a't In)+;^L O:.)-, ^-*^^

-=7 icort-^6 orrl ;; s ^'tk^, L't' **t,7 ,,{ ?*+o\r' a..u'i'''.d Fk"" '

lr -i/ Clo'rc.Ule lest' java

Che s Dlrno innplemeni6 java'lar6' cloneable

c7

int 0rb i

ftub)ic &*of )nrx,lnr r)\L ' ifl*S$arn Ccrsr'Llcrzd ") I5 o' P ( uemg

A-- X;b=r'

\ ,,

Page 13: Design Patterns Complete Notes (Natraz)

Ptblic Dtrmt )

fs'o 'r ( nrrrr: o-?avorn 6cn-si't'tt<r

' ),'I

BA);c 1hlt+ -gCtonc [) n"^t E,rc(pHoh

f

J //aots

"pdlic closs Clo,cdbleTes t{

d", Jirpcr;

\ I*"I lL"^

ll *" Ct^e'''bleTe*' Y''^

ll t'"" ()uullel<xr

.-z lcrnJuved t6 rrryrrsr cUlrr| cgrri on

Leoru se ltrrre p no ccr Swcrc-F<rt

---e Fle.^ objelrS Orc a.r€.r5ed fin",.3 h

{xe ctrFd

-1?r tdored

Ohi* o6j = &pt'chrt O; llp'|.-.-e clonln3 e'a''ftrLf invobu oE1<l.t-

oqj ;

B&tic vdid d+( )t5 o p (" 4 ='+ot

" b:'+u) '

\

P 5 vm(srtrqtl c.r911i{rnos E<cg*tonl

I l,rn^* D,rr obs:<a

Doilo*I, = n,^'D-o (to, "t'1

"

Sc, p t- 'd1

hoskcr,dc ; n r Jr . h.sht de C)}

d r. drspc) ;

/r*.P.- ,t-nD*o 4" = ue(&m")a,' ryCl*a

[]f .".eL" J= l^o^lc"ae ; ' +dz. [*tGl.c))7

hdrk^? > p,le6 > At$s > Dertrt ltorlcrn -' F ohkYre> io-oat (lo"eolL;rar -';1* -'-''

ltx fit".

tta.

rle o\p+ omriao thvotrSlr ctot'i5 47LvP3

exeuurit'n '- a,on,',, usrd Dest'nral,zorr

on {a arornauhx

rqtrosS9

',oitl nri,- b.

1o&n* ofi<rn on grotorgne peslgned puton

Page 14: Design Patterns Complete Notes (Natraz)

- .--Q",'dr.y D€sigb pd$ern""-

\-

PrGbleYb:-

Pto.€ v! .

06laqb^o

cbnsi, .(*tc,a 4 Couelex odie.rs dl-ct3 h *"y one Ccrnple* cluvs is lot- rcco.r,ienJe I

.g[ub'cn:' C-"r'...* conpk x obictt3 !'ot n''"ltl glt 9-ple obje'+s skf -{ ' tF"( as neeJ'J ' -76' ' '

*, !,rra.' J.r,4n fdcrn ' uoliol i'np'orT r tle *'sobitt Q mubple inLoi&'"J o{t'+sJy

C-st^,"c.t","tr il"" G"nder eUe'ls '

':""t:- / B,.irJ";T.rr -.i^vo

4las s &ng et;

ft^bllc inr Pti ce C )

{ .ftt<-\rn eS;LJ

3

cl&(s F"rcr

I}'Ltic int frx-cc( )

lvLfirv4 l5-;

13

Clc,js !rt't<.(t

Pr,-b lic ;n* liritec )i xtttn 30 )

\3

C lats f-leot&'tldcn{

Pulli c ir'ft

D;nvt)'frrcQ;nrrr 6bua,' ;mcet)

*ntra

arrcPvice t )

llLu;teu Potlu" lo6;'

*tn r^*

Ku'y,0 'Prce()+

1

c lcJ! f,"oa' BuiJcn

{ ,*"' lni .olcPtscrL)

t ,rt,r* ;r-*+ern fo6ic

Yrn norri hegt)' gnte(J + rtr^t

\'

Ddnui)'f'crt) i

Page 15: Design Patterns Complete Notes (Natraz)

.p-bl t t c l&r\ Bu ta,rT- rL ". -- -\" ,' t "(e t"6r: *6'>

Illc'^rt"^ ouYrl

Ple^lLu;du 2L=n<'ra YIe"IE"qAct()'

t , O.,..t'tin* Y41 :mL ' c'A''?s< Ll '

s'o ft' 4. ^^L Pi'e is "+vat )' \-''l

J

ll C'"'\Nlc,. oLfuk a

e"'otl'[9cld"t sL=ueA e ^"*lLad-()'/ :i^t Val1,=sL.crkP;cet)"

J

r. o.rC' +4,< sno,.l, (h.. iJ n +W t ) : \-/

1 fL.r t&. Pr-Sfa n \'r'i

'a&'tr> NAPI3> *iw> D"vft"lur&'n > El;.t!'n?o\u^ \

l>.huac &'l U tTttt i"':o '.J

/, fuo lk;lJe,'lerr ,^t I .-

-+. .he Au^t,u, 7 ",x;-;;;: ;*,,,. s:T h:-Xr 12

>-lIt- ttllL\?rT t "ftsfaflie oW "tr

*::::"':#" - Kai*u*sr r{ '&ex rol<nrt" Q I b 11 :

f,&,pret clace ; - , n ll as flwi le ; tyln a'totl-'

v

------""-=- &' o'(#'8- &'4 ingler'1l,^ts i'n@twe I ' \J

A; o\,^ cto,. e,n'.f,:: #\"-*; 'ui *t i^l<''.'A<j to lr'roo'det*'w:,-r:::::-t r 'J, '9 & ltrc?ae €'u

4" olx &t 6tP -.r+oos + '* JJo7 g"t*^ ^gl,A^ intetlac€ x'| 2'

,-i o*" "'* -18,!;. goiJ L); I V

"purtic vold c'L)" a)?._

a 1 .,,' ]t" i'nf ir'vrrrJs x 1 z- v

n,*1," {oid tc ) '-I-

=-J

-.Jrrc vo;d *) ll ntr( ^uiu'l \t^vr' " Jt

,1' \

-_lLq-I

Page 16: Design Patterns Complete Notes (Natraz)

,v, 'T"rr' ;, ,tf inl.rz<kl to yr"vld'

it at nqtl nt+Ld Aekar:'n ,

,,A* Jit< oo\

inplz*un\$a 4.n -uLl 'q L',t- i1i.- ]-tt"J h J.B;;,uo

9. '--:- trv" o)opte' claus ;-elw'z^h1 i *<^k'ce c'n<l ymvid< nalt mcsl.oJ

"'-ih^u"* +, l^R,l-a,< -*bh ' so +!'t c)t^ 4 1't'*+'- caq owat.ide

- cLottc m<tl,*A LX e*e^L"'4 -n"- Aa"yla clats '

-' ok;\..u,."* C

r,'^' [ \l2'r^ inPlcm.*rs t'! z

\---2 N

PcrJ'tlc rlaid a() t 1

Yrltjc rtoiJ t() L \'.-,/ p#tr . \lr,rd cf) f.3

3

c\c'ra TuY eav-n)'t flyol*^,t

" n*"t VaiJ aL);-"a

,, t()Y'bllc

Vatd

L.\J'

3z

- clt ̂ T-" erK^lr WN*^s

- t Yulv' tJo;A t L)

tz, | | t,

- 3 ' ^t"t" o R" tl*L c lo6es d'o"c n '

- qpmera( t4 fu o[4vt cbN"s pirt [c -{z)'a og 'atsna'nt

c to'I4s ., B'

- 'u l -- . l.r'^. 1-r-'-uide &"e4t 1 '1"9;iu't)

' n-' L'r':-:---- Qo*dn S;ou t lo6i, t (aa"s r\Ql merT'o<

' i ntratngl a*i cn J^ /d^7 .tt'< cl-*s

' A ,1t l;(F net< in"t- f-cz

)- davrr . c,ul t ' e.uen'F . fi;'Aotofidoyt<"t ;( a'n olot* fu {* s et'

It Le 6;adow l)nl"i , Lo:nlor CJonEnT^ s" ,l'lindoo?cLL\L\tfe"'u t"*.*y','ff*

--)Jo,ual- ge,nru.(Jvne^ic6rlc-r- ctc&\ rr pa'r'n{ dn ada+tu'bN 1- i"'f;::#t:'W'ffia

- g- oLo* 4lp^ ure inltkces uni M*ptt clntsu.)n ,rr Pwig< '. ,.*u ,-*Alg::'- ry e'\ ?L des/gns Arr speuAcad.,n ff t&e pxiex ),-,n3 #,'ffi'AJ;:1J-"\-. IrrD $rame"{ " flts ywtttt 13( urcq alerrcrl- clc^y.5 !'lfli es bfl r,r lr'c arrA

6<..ide|t^o o^A

- pe r.rre9 l",lr, &ace s fo Eqoh o"l;1 ,rt"s{-at^"I &16-.^+'-'").

fr,-^n w.f(ro \(i-rY' \Ti,,^e! &D- qre.i(;cc'l''o Lllte ]t'/ yw\* \ac'- ") fu Vn l' G^f^'l+ lu'''

Page 17: Design Patterns Complete Notes (Natraz)

'rutes ^nA brL)l;ftt )a Ac':t'( rl-'t f"i;" J"i*o c^) 6'nr<a'"a)' t -rk'

.P'* !t:"",*?"*,,, * *U i *f-8 utl^ ""ler a^J Y*'o o-l t'+c'{o'-s ot't Lc *"J &atl'tJ

j^g ..-lo

-, ,l-t" Aa''he;'1 oAoyv t6*"t ^

Uny"** LoiLt Le 1a-v<"1 ' -L;1" J"'"t'7;O

fia"us Cenynz*6

't'n*"u f^pVc<: H it"^ 9'-t-%'< '

.-'--. y''vicl" 9g<';^l V'oq-F^e O+dL; li$2 fb oLi* k 3VE moo^el i't<r (oo": c'n

-'

y<f wr\ '

= w7 od;,.V )"t:o clw ot eyer;"t c"'^Y "a t'*tt L"

nwtt i"^plutnouJs SP;J&'/< ;19aA:tta* elalq

98.*,.1 DTo c\c'ss

:!tYY-&nd it drr"etrq 6tr"n he t)ttLov{

i s oot 91idi zalte olqiecl ' So, lt)e CAr| tQesul't 5(} objecl-

SoluHoD:-

Agprta<,L r .:

inskad

ase qbwtets @

fart PYas*e o*

o{ f2esurr$ts

.Q",ic.\izat\e ohie'x r3 Je&-rr)

t'.,*-e data-Svnto*uu *'rd ed AafCop5 &r.,4 Pesurr&+ a'i h ol\e'ucm

DaraSk rtl'e t" ilt nelcoo{r ' L+n

florF i^ $.,,.o 'no"t Q i a' kw" i d,,a t14I

.t==='+L" ^Ior" ynac'"" '

S',#","" -"n &,5^ s. e qe -lrgt-'.4La to sot'x

*'.d {1b ,!__43jS I d s ) jl 6o.-.

r.,"c 1r"t",.6 {o px &"',r e -,,11-o",er<.s Qr^lq*.*ttu*

03L non-<;nc}'vowx dufo Cftt"f""" l;pe *r7l;'+,h\-rlw -+d L*"" ro'4*-"n'e' e

lmouin1 Ja--to Lallech'on l.***I, drt^sv"*'^n il 6'-a'* to"kl l"P&-^ Ul"

u.) 6; t-e Qr.,altons 9r,, ltaneou t -$t rse f6^t/'' tztJ J'unsv""*''l liL<- \tt''tvt

c.tlcrr.lo'r $"-'-lU D*'" 'i:.ff:f' :

-a APU'I

{"t^

--> AP+<n

*"J

l, ++*l e"e"tr'

ln $e abrc Gar;o

iv'jd,*a-e .

A^e, rc^.I".i fr,n Sye-o! tL,Nes,

rc p*l* ,o,lrn orrl *t1 l'.,r D&S''"'r*'

Page 18: Design Patterns Complete Notes (Natraz)

1",,1 4t A^n- 4 -..u;'\e wwls

s,iu, y-no 1k' Qw)"k*)

Pr<"rle

^"4&)&

uulz t',tulr;el" obj"n h U s'^ - (Lp;'eA clt"\

' ' t ^t l"'n It: mul't-p')u e'le''r'1J't< 4 h\L'Vs-'Jk'*J

\/r, rlan IOro "1"'l(*[;"; 1 t (nd^r''-u olt'.*

7

aA) 1Les" oLjetrt

cLo+s \, Called c'g

Ex^.plc Q*9;

V.o clars J n''' o tr^s f j^v"B*" )

E^pBenn ' iav a l- tp&bl;c class EnpBe"n iqiltnu,^ls iav ' io ' S*oA'*t"

P{ivat'e inr no;

Fuok S-"J nam? ,

f-!oJ. Q.* SG{;

/J *'* QtXxx[-) o.J

pssgllSet t's -- 5t . e"ecure0uevy f' stttr.t * F<rr'\ €mPlolee ');al

q.rQX*"t- ) ,'tl"tt

ll ud,, J-d c,rtr Pes.ttG+ oqn au''\ +" h"'lU'r

lrraglisr al: n trD /V"1L;sr tl;

r.oh te, [ts' next( I )

t" /l c.r5 et cJ., +trv, I I-o ore btgBean abj

f,op0er,n tb : nu,l En^fB.a,n t) ieb. sttNo (rs,Xttlnt6)) irb. Srt\\rlns (65. gerSrrrng (>l) Ieb. r| Sor lns . gerFLo"J t:r ) i

uDdel3randinj $e yro utem ,.',ld,ca h col,inJ l2rsar r&t &6 f" -4'"t6 Lt f

t5cro[i )I (Arro9L5t oli ) QTTL TS ( Ses{tr

t<.lot tct'-i,esl', qbooo

2ol Yd'yts| tooo o

ALB.

---z La<\ ,eto'td o? P.."rt fu Coaknns

*A--aq L"t olLow ah one oLPt ' So,'ilv

eiu**,+ -/n'',/L,tU

-10 ','oie 4e qb'o gY,,oho.

mc,lHrle volt..es

Ae Ce,'o'+ r^d,'<

i".L&ffitu/e "tj* '

euj, vzcn^J 4 &ttt'Sr.+

E ,,1, e {.-",.r "P

dr,.rl6 h z*I

An.o.rlLis r obj ) rs (Res'us<;

Page 19: Design Patterns Complete Notes (Natraz)

llaaA uJ" En7Bu".,

al , add (eb ) ,'

oheu a *"ybtr

't llrc\"iteJ rr- '

.-4 xq t\e obatt goneri o "eb' i' 'r'r'*'|t"J\ ant 3rn3[e 6i5 v.r|"e 11 G^U- "1 t-"lrlc L

\a.[!zr' so, rl^e clc'o 4'eV" is ioilLd ar' ! o' ct"r't

S,-itterl; 's5' i' also ldo'^f, *o -* l^t d*^ 8'- pgfl$zu"

*H'+*-t"w k

-A**L;.. dt,v,r*t t'Y;' t< "fro c'L,a az D"I'o crt'u

0

d- ,. n..i-n rmp{c,,'r^f, ^k'- d*6'&n ",' tt *\, "'U^-t^'.k* + h-11,ir i,nlltmrfall cn is wot *t1'li " J wke nttu'1

''tl' ,9f""'t ' Wnal'

:

)._/

&w;rt *'ru'"n L::t )"ra 6lr.*!ray

D*r5"P"ttt"T^d* clasS i-

m*ttiPl c ctarats

!,'.tr^ - +Le

4 S',." calcT-6 -t''"'' S"*d' tuel hLt tl,, tet'ttAtt;1

p'S\e.";- D'xl"pt-X:==: LJ

*I incc.,-ie: IL'

^*d 4r', V8*^ l*r,,q *ft o^l

k^jW cl"u

yil&"<2.

-'['1/"'

g1 Fwlarat<S Canfid ^ +t^'

f lr,*rlos" 'l*s [J;te,v.L

Ilg-t"r''n

fuSuc 'tv'r s"| i"'t-

[ *'t^ atb)

\il Y'l e

luJlic l|cdo*

]

o,;rrt L)

ll g*^ton t n T^Ptt*t .l".vl

.lo)J ,L'R''ttO* *t);

clotj Scn.r lJ"' rc'l

f.

ffiranu* '

JcA,e *k;' c\''x+

]o i\ot< do:v,ct o^e P-"\ ,.fuwu\ clauu '

E"o*r(o :-..=-.---

tn\V'/Y iaoa' iO' t' i

&*ton* clc'*

L

exftn l! \HR,L

Page 20: Design Patterns Complete Notes (Natraz)

'.-, [rr,6tic VaiJ "L^P.*u(;.rt*)5

\J (.r.ptt r);3

3 \\tu'L"blrPJ{ '

ilfrwt;o"Z h 'Ta.r,lorc cbt's\-

clotA Fre l'J;rc"-r Lxgnd s Qlr+t L\* t

"" uo'' 'l'P'*vti*

* 2{.

\-' E#*v \o= ua)

EA+o"aUan't

\/ 3l*a'\- tt ck^uJ'

JA$'il'#I:ui.[L",r, -(* Fu0u+"*\tn'-( orc' +xr'))'

E"e&t*tLfn6'

4

\-/ to.r^c,irclS,; ;

\--, ya'.flo.tLt Y,

Iu, ctoSa g1 .

3 il'v\! caH^ff*ot' ") t 3

|It',l..r\--'l J" u*

' T-uUntt'nV'Ilt' ald6

t o ' u* ( si'o-1lJ -rt ) *o'^' frePu^^

: t **u'o sL--v\e'n

9*"^wP'/L\:

it* ves = cc's'm (ro'z'") i

\r gc' slnaQetutt | '.l) l

v Ft"fJ;ra- J^'-'*t FeAswtO;

,^-- %.<.r'(to,-)'-l*,,b^Wl@');

Page 21: Design Patterns Complete Notes (Natraz)

7 O ta,f *+e^&*,x',,i"acn,;-6qlo q l,:o tt-

ry:t U^en_9:- tlry*"d.,,'1 b"u"p o{ rt,aurte i< 6el;ni ;rs &,,&* -,!@* h Se.o,chi^1 1^ *rr- uTli\ x ca-tted a.t D*e"t t ,^f . j,., h.^l-,rl",tf*f $e Pr.* I^ t, Id fh" va.!.ne gnplitriS b.kne vhti?;\ fl"r,"_.

W er,^Je"rf fl*s l',e+t"tra.l .,1 ,A^ L" Jr^,or,Js _l-_ ,,

9 lte hs',l ryn*",

oht"+ it fl-a'*t l"- La*a3 s/r': tl'-,y" JNot:c,J.sd*tio-- l)tf,*d*rq \]rriatl.". I (n.\ \-,.

\--,'

W d@w vim{a, .-&pna,"q fnlt*i on t- r t

'\-./

Afsr6n< ValLk s ro \rort{Te thpn ir ts latJs *laFnde"rt

f,uu* "

--, m Dqurbe,*1Jrj€ct'c.n undortalin3 grt,"' I OrJo),.t'o' ' ' ' F,6hu 7lp y6luel n W' to' J

,6h" ^ru*"q need drnt n*Aar,n *, fime lo frtrk.d rh'" ,t"tuesu"G

g- -. L.r'rl JUn eteu"rs constua'tz:tc cultaYtart;o&3 1a \'nfiz'uze tl'e obiY* d o\y tt ts

' .'',,'J4, l€P'.- 'lLt,a,t Aa*S"'lu m;vts '&^lnr' n 1u^ue*n :;=-=

F@; -fhe Mt *",t^z G,tkql,trt p".kr,l;s 9et+t',Cant"tz't d'A furc'l.r'eSnu;'os f.a' snXkt -==-0'0

4 'ke @^ obie* it 11"iuo.!-;u +[,"u4L co^'t"tfur ues"x]on c'*'et u *L >fi*1?"y"';*t '

u - iHa.L u tn'-{ n , ca tl l t

:*-l\" @tI ohlu* ls 6tcuye-d ,nA d*^ l''*4L *u!''d aJl-s cunzz tL'nde'r u7^fitd"tP''-'

v,

&., YW*go .J

. -/

Page 22: Design Patterns Complete Notes (Natraz)

no: l0 I

rnmc @,'@9

Flg rc.'gh* p.fkrn i-

Prcdcrnt- E dhpus oP €mp)a,1ee C I ads

eba

rtPr?trudoq +

e'b3

emplo,leel dt-t-all s

eb+

9ol ut1c,o ,"-

ryY"^; D).rn yocr 6rea-br rnurr;ple ode*ts 4. o ch's Lttnt drffcttlr Vcheg 6Hll

thtre is cr q:stibi lihj cf '\o1-1rng $me Shrne , cornrna\ d"r..lvofu"es in Glttd h faDFttE

off- tkne rnrr,lHple oqje*5 . InsFcad o$eu- tlrroL ah:u-S allocarlnl &rnmcn *^ttJ

anJ uSlnll *tnrc!-fu'Le O6wa,

-) -rhe Ct.nen A^+- 4 rnt,lHele obeus cftalLl !t' ^'1"^ is &-tred

;"Htd"o

$.nrtat1 lAe fuo ilrat Is sW(1 t lo eod'' obie* i! CdJle d €xl-rln sic Ja-t.q '

-frr *u oLow Jofl'oh Yro na''v"ra V&q in e'L<"A ObJo+ Cctnu un)w

q(hlhslc drjo onA "dt" Gnct unAu ihhi nsJ( d'to'

yyy; e+8- frlr)nsic duro i'' 'M'X

oLiet an)

.tu*'A (w^ cti ) nnd ure it ir sl'o'eJ elxl oLJ?w

patk, n i^pl cne,n*otl ou, .

f,n e*u"nl. ayp\;cz^Hun on ?\ua1t't pesix'r ?aj+<r{n ' )<P<n flh't'^ fuyhw^lw,

lnjr;n glc Aua \n tunno'1

fl^*"11. PlXce,3w Dat1a

'no*{G\

,air t@9,,

gx+rinsJc f,a1a, tuPanren JaI

infytn s ic edf:r'/. --)c"t rn"^ ee-<

l^ Aou+^

Page 23: Design Patterns Complete Notes (Natraz)

r)*Vieco

flobterD:- Nr}inj Java cod e C sc{ipt ) io f,sp is ku,ro 3 -Brraoi''3 lin'llc'li ao5

kills . *,e recddbili i3 ol

Kils the .rerrgobit; Q o(

sbl'J t-ia7l :- -fmplerneot viuo

P.leb leve I D4;1n pnxt n *

lwf-{ ",-o

@ Ccmt,sri vierc DslS; fr}rkn l-

Yyv'1lo6;c

mcii n (l)nKr* loSl c

op oebruge r

FooK! looic

(*'*'oo' "trb4|ad)

4f* 'ilre 61,-1a," lo6;c o(

^r*Ape he,e', kq,:l kc*un

Thz mutlt1le &'Lb tbX'|s 4^ ec.L .?a1e I

van Can*t& of atbrcle

4" rl,isJova ccde less Jsf prD3ram '

ftP b&i rf -r n f&d s e(ef

Jsrl taXs

J5P

J..r..code -

helpe't 6lss;9n

grlpt le*

{t}ka o nkth ;s no'}"A b

ttx need la u3e *r f,orrot'i n3

dedomll oo , exf, esgian +nE '

--ft,:rd po'rrX 9qpiizd to6s

Cujtaro XUP kfla

G"tar I i,p pnq t k^w.Ii.r'l''91

t

oa

0

(:l

(e

o

YftM.5

kod?! l'{i c

rrA n co'.r"r- lltc og

ryry::,

FooFs totl c

(6cro.are.r -c41ez) (54e"+"r wd'4aaez)

mt,rhple cr)cb \.t14 coce\ fncga'rn Qre rro f ye ura-6te loSi<

rLcl d,n @ L,u'd coaAed )n etfi be6 YLsok)cE v"s#-"

ueb gllt coo,jei n grne hadt' o A 'l*f- cv't<nta ' Bc'l-

tt &lk'e*

yn ^ovrfu cu-^- l,6,rt il, &r*dile l"to \ hn'V rlu^ i' ery'"n e,al"ws"o'vw

{-e lk- natn 1,gl""*ou"t P,f-tl itt)nc

0+,t*f-S ,"d t"^de +{*.ar ou4"*"

il;t Wneed h usep^ott *"LW1,*

€@g Jsp p?Dgra'a q.s

JsP qS

n"utas 1 Jry p"r"

Setlu b6tc

pur" Cuntenr tqic"{

6ctgele:

n ra [,ntt

,a. va,a$!-) p6p : i"clade >

-fi)! p[a f e grure D ' i( C".rle d irnplenn * oxa

"P &'npslic Viao WTh Petttn-

Page 24: Design Patterns Complete Notes (Natraz)

ll€odLr sYv

P;n Ar.*cf|t lB;c

,,f "rclf"{e

f"r.aj^O'nk*

Jd . i"tftrde Ct

u. iiqrude (-, -)Lor)Zio: iXcu,ae >ficrin Coy!t1* lo;ic

4- ,^xt"fqcz

a.1a-i.f-, ) Lr')

forr 1"6 rc

Sorurct / 5sg f,vo gr

of

0-

It 1"" co'"roon lo61c g ( f,qa.ter

@ kon, G",|Norle{ Desrro a'ltt"o

.fi-t. t'gt"s alt fectla-ble i?i(s )and

Q ceL a4,yl'c"Ito*o cos t

-l.rke $,e Lli.'t gtilJrat<A hhrrcfesr dtfi' - LL- Ir*anryrt J.;**N-

y' .t4 A",a"lfu Y\"c^ms 4 g'* ualattx."tt'q (an t,^Ft:

Gl,.lt^'. yu"Li q,u^r cuo I rtp f'*To* ^J"'t 4#wilt't t@f all l*r!'*ynr V"'

J$: :,:T."n:, #::,'"["Hi^ v'cL'l^'\ a't-h^1

ryry O{djrn'1 iaira clar<es Ao* o" u'LV c'g oeL ttsa'"ce f"{""v

2afu,$ort ,nuJ U\ &*tr mo4^ u't-Yil-an'

&oow ,tt^tron1 - -T.rthf [w,]ey/""n')U*sr,llw"tl,ar,.

Tes+\rl7'do

wuIE:- ftw (-not i,- Enht a,nl Enir

" *-d"1 xJ r.rrc,'t< W( ar\

piv,.r t^ rL\ quest d^ot

Qo,Et g"1,ar' | :r, ,t "- ) *h"t *" a

$."r zr+'l-rrA - -.- ^ ,j"r.a;E;f

wY,oru"ctl )

' laoa JoueT (

bW,ll t"a'l^ur'-

ret&lrl t>'d'.

ojrL !;Lon FO OAeo q*.|*to*tr" 1',^ j.on^-r d-

Page 25: Design Patterns Complete Notes (Natraz)

fiLL olrt/lahaq ,luL ,,r" )^,sa cL,-xcs

Fn'"' rh g,o!t( I'K a$xca!'! on. A'u'S'*tu- )' J*'x co^'*^ (1<'r 9^'t t' J- 9n*w Atx'"Cb"o "

=;(c*^ri"n-). 3^8"\ wlnvc Drr*.uoGui.r i' &cxz'*'*ltu {'a (b^"*"JC*wn

eto*er (-.ro^ c-0*.-, )

Page 26: Design Patterns Complete Notes (Natraz)

i hie-b. Arn I .nrA.xm\ Pif"rSrv PrDiraro iD ael>'

Ci^H1ffi Fro"

IsE!- Ptonr Cdnmller setvlci lJsP PrD01^r4m ttust te

cdrh dirzo-org rrurcA url Porkr h or coltfr

tdeb ' xrfl I

4toeb - opp y

<*wkJ.>

{JervlCf -Dame > F alg.rvlef - 1pm€ }ls&v t& - cla!,g > Ecm rsrv z /Sc,rutcr _clac s 1

4suvlu >

/Scrv l(i_rrnpplnX 1

Lkxvlet - ncLrtr- > Y z/ Satvkr -narne >

/-url - Par*an > +'Jo Llul- patl<trn 2

Llwte* -Ym1,pinq y

4weh't+'t'>

I wanrgu " jov a

impott jotax, ScnvICt- "y.

co;tl, *'i0 oartaft* ' clo uY I

" fute el 'le'tOmergtH in ut-b'nmt

€,\ftn6ltm rnarti uvt Poffc'r 4

imta*-

lrnPn- io.+ )'Fl^Terv €xtc,ds )\7Qe''tle+

J,a+ (ilwe !*wfuq,exr''Y1,, l+4 !^"wP^r'"x'*)r1."

lua"as

?, --'n's' g*I)a* t>)

I +v, 1,,

s' spafu"rc"rfirt ("1r^"f t'r.,"t" ),'

flt vt4ae* lr affqofrNe lota dal4

yruHtc

jwax , K.ture+. htl7.+iJu.tu .

clu\

y*l;c V6ld

t

p;*N'''*

reoL/1e|l atnl W

lnt ,rt-tql I =- b ;

Jl6*o, x

if (V,. 6etQ'vWPa,O.wats ( lt,'n') )

Page 27: Design Patterns Complete Notes (Natraz)

i -Tesr7 t1 =- neta -l?st}| ) l

. .lr(r.{l I = tt - bmt (to,>o);

S lliv ,M t.etci''iP (1n ' nr:Q*wPoAL) ' e#ata ( /r''a" ) )

oa

Te*Z tz-' \\e!D 'Te:rZL);

:r,{tut+ = Y.' Lm-Llot'>o)l

1

llt,'t% +l'," nawtt

pr,o,ftir,rln ('2b", zL)1ht asutt is i " + rcsut) )

jlla"a"tq

Xr*,," uo,, )nNosr(WW'utL*r Wt +)+\C'"'te1-fup*tt *t )

dn6rt (*+l ,'rt') )

Dorc: r6foO 1"o.

L

t5

j

(E JntetcePhn3 t'fu:-

lrlrrce{rdn3 Ftrcl fbe gFgctc,t tDel Yes.crrce p'4}goot ol .,4af.{.-L'Or*6o, V

llar i9 C-t aaAz + f-{tPt5 rte rclucst { 'r.s1r,"1 fi 6ffis,r ,paf,1.esta1,uce L

:prab)ero:- keepinq rhe ccr",m.- ^^) ^ r^Lr,t r)rs-.nar r r,et- r>trcv+)n\lqlL alr'l Past Ttl/vnsc ffJrlethLt')----- ,.r .,- cooxr6.-, and 6lobr,l trs-rlAtjr p'pu",gn'tl7t c onl Past Ttr/'/r$c tr^-^LW" in n*\ ,r*n vt)crcsa.rce {r"Ato- 4 aboryaca*a Vitrc r!''e ^re-*aLl t } n 4 'l.e O,

:

de.y $rykne* rnntal,a,n $u.' Torl rurtu:1 'ak& i' '*&xb'*s*ulu

f;tr- :\J

m1cLfi, ,---t gnle+ 4,toyr-jro, exj, tt. Cunrron y-r,e-.rw*trp'nd^1 to|+c t1 ,-..v

*WV\ *y'ut .ginirral6 ,^e!ilr<. Carnynan yosrytrfnse V,oraaan t|tc \ W\ *;

YaWtL + 6Ste'r 6-L *X6,a-'tx- pr.f to^a . \-/

\-./

Page 28: Design Patterns Complete Notes (Natraz)

?stAnp (tr..8a/.ac o")

f?r) 'ef*s".rS pft.-"t q/LLes'r p'Dcr-t3iht

rod; c

( 'l :) q,re s."rS Pc(+'Fsrhse it;'r'-}}{{odrr.

(,lr) .rfrer6f' the rncnrt -r?"t'{t

procrs;"6 Inl c

!-,u.,rr,r lodo-rl

i€1Aa rl

e)l,np te3tsru e

O f'.'rl^n"ur'l-t",) l'tr r,

() -*|,"-.-sn [o6r.

O 1"66r"tr t7i"

a tx p1"." r4. jno*inn po"t -"tcsld1r e

y::t: Frc,rccorrz.,tte'r -Iiaps rfie ftellelt t6

&f.'ctprinJ Tjrrc< -lw.ps $e, ,ftefrrLt

52 cr"rl

to ord;na,1 jc"vo clc.,sses

$"ufet g,'06'c"ns., Gp r-gro-S ooj Jcl)o chr:q .

glbllc cl&s5

{

llgF,rtct irrrplernanl€ FllaY

inir (Fitaconfil f3 )

f/n;r,oti."n.n I7t'

P{"{blic Voi d

f

1

l>,aic

tf-)

&' JoF,,* (*r,,t");

\wtiL

t1-

l

v6ie ctcr Frvg L)

,,=\ slv-!

*.,,*",*ftuJ--- S.'m)

Svv r

-z g.tet Brrcr ;6 o6Ar, !u.t- implem<av;n6 inl€ycephhfi tr'

n 'o"n'"x-*rroc'tnX PtL.efs + lcf.i c in e*t+ptr.n p-7,^.

inlercephhfi Frr'v Deri6n p''t*n $'-""1J/6 '* plote r|''e

yz-ohn,U, * YY tv", *3Sl"J I-

O-r"^^%-,"11' 1"6i" o^A .nc-. - --lHs *rrn

0"'"f ro

&nnple -$*vlet TIte{ D4.Lptrnl- : -

flg F;r ie.r . j c.r a

Void doErx.* (9*r"t?"7,r^7 -g,]il+?.'t...-re'.*, p;taC\ain

f/ rn* -tc1,,^"st pnawn n 1"6+ '

- - ll p"s' wfonv Tt4raNc'^' Vgt c

luniruH^! z--g a.1 [o6l c

Page 29: Design Patterns Complete Notes (Natraz)

a-JD Shc.rs a'1 c^ppliLc\))am

Cr"rtptlet" . b4 i-nla'rr-r.$n1

Abet ar Conrmtttn :-

proLla'n : - arJ Co"d i"9d

Fz,ntC*.'ot r.r 's Ylit

SJ"n,n'.- Da,c,l,v *le[w

Ftrrc.D;"pt .[er is a ,',eJc |+re; 9" *trrrer

@

iorc" cct^ r;.,J I,rr_rD.tJ', 2tt..,PF{Ern oainX er '

.rai., lo6;.c

'errr.",'), I

l.d\d.+hd tn

yncr*s . lez

X+*c+r'6Drr" F,l'o-(9"rroF,* ) "

s hrrs de -?rr.leri7 4 nutr;(;""Jeo,t

i,*o dnxas J,, ;v,ktyh,,'d fr* p,X'^- f

+;*G,*;"Uc't ,-'1'^n

-G*An, (*l'r^l-$'")

ccaro.'i, ze rg'e l3"o "P +,.&.r conlrot lc^ p-f'"t- C"6)

e4 sJde "? fltte' f.w'f t''thL '

\'./

--t Abshoct &"trottel Chss i! *t .*fu '16

J",r-tar'.6Frt ' p,V.,o Ur,n

-z \n 5i,"*< r'r €wftinm<ttt Dq,nrP,n n^ clerl ;s A!r* G"''^ttt !- '("hs-?*t'Y ' 9,-lo,t4 tu, (r".t'Z'x e,,'t:irat^t^* }J*tftde ^"

,l'"

fitaDt'r-t.t-.

lron+ (or+bUer

all.e*t GrlnLF26v

4- t^*r.raV\'Lc,l Cwnttu & ,"u"a

)*'"d r'1o;^116r.1 6* rb $^ta;uV 4 m"&f,t.,!t-r. --yy,a -11.11,* cW ," ,dU,^6L,r

p$a"+ G,*'"llw '

Bltoft. trl^Johl

ry*ry

Page 30: Design Patterns Complete Notes (Natraz)

0

ll]) I"*ffor,"., la6a'-l D*;6n Pa** o *)

cttn* Arp

cl)qrBfd a

3 n€rqodP h.and.h,JoJ &rq Oel |r2lYe

o,n" IS JEE

g-:rr l-. ,

-Ar\; aHd'l td{?

_@

4 Ou mart .ro(lhd h,{ pr a.'P rrrl l<rr,

Woacio'"- 1f pztnote cticz.l diw{ -lot B nir& "rrr''tdplc

oho*rc & tr/.1 ''-""tdrlt 'oJ?^L >o,L,,A l'1?t Llu'

Ot[t. iluanu, bny<ne,*

4, ^.Lr) !e\!i.or}.,aa dc ,

Jd,r'., ,b* @ Jiograrn

Sla.Hoo i- 16'&<efun217o^L lounA ltips 4" oLo

oje on. d.,-t'1 tsa^* ?vfuat 9o*e."9td" *f, *o'^ yefr-tt &"- .UT W Canrav* l*'aoC", r,iA

9"cuAo +.,Ve

otrd "drol .lrrrr^

"rt*@, )e-te rle d1rn"rq !..el"'cu tc'"f'rrui:f is @tql

Lngln rs (onScx.t''t,3 flut it o

cl\t^f arJ @Eu-tlt^ct! Coryu^t* il

0

t

t-

$ypttur.an gq-.

("ui*t,oJ" d"e,','t- aor 61 ".,

Gt o ur [,u$ ,' trJ \oS".l"-f i*l".Le

Page 31: Design Patterns Complete Notes (Natraz)

i.ndftta4.. ri,rJnl fr ps 'tk 1 LU <^f Lratl'< k ;t-t<"-z'al''7 afrt'

cli.^t afrL'.a$"n lolH\

^etrJofu, ro].,n) I"io .

rn'"d+i p'lr- Rug ^r-rs Ct 'nrerrerut

roi.4 rnutnY'l- K-s'incta Az',qna'+I

-> -Tb Adeitt'+

arl"o, ttu

allusogehudu !

.-,/

.fl, Qn'u C;Je tcd"et"sY forla<'

Jcisl ui-tizig orth q c-"'U-- 1. dat'd ;nk ot eN4 cnl)u A" "nPfo luy" no's 2l ,.nA >)- '

fla-t

Sgnrhrrnor, s c3-rrun; ca'tl <r4 rll cr i"nJ- futlt"r{o-'

<e"v.o A PPeliet'J Al ?

r&1,lttr@

Wy'FXnch-ror,e (ornmun) tc,*|c:n tfta elic^r Av tt/.

a"d <<ntt-'t -A1p\;caJ4orl \ sr,utr filt coh'o"

udill Eitih

{ n.["o"t' t"

.----. J)\ C1)tit 'Sef d'{ (tnr7lt ct \cvt t il cticnr )s ln" ta 6ge"tt< naal NJPlelF ai+lottt G,attrtr

&"nv"u* ctll n 'E

XP ctlgnl- ls Llocve A ,n flaer u-z '11pn, taytt F

battc h eliL\1t Jr". gn* . +!^* lr is calneJ

-1., ff,w wy,^est reJ,i-4 *s1'ate ,fl'u if r( fuUed ls6'ilt"r'nns

*6rrtr.r"os &tnmawcartn tl"clit* erde kh^nl'V1 #fax 6{

L^rot* ntndara and r,.r/ sire urre

,rpat^e e I a)6,n) *tYcnrc &nu'I

&nv,Mtrrlaatl0"i.4ft,:'

crienr AfP

clrcnt&0

"LgAestO-ct-fiIl-44.YYQ

'(!f'c*

Yecsccqe suve,!

ffi otall spiy:,aV gmtL.t

$t -_' :.(l!\

f"e

r+llvle ss ar e sla}(,@

1t|)$ con? ,/@)

mrftv-1I tatS I

'l/

(t{eeto6ePoto..le \' J1-

t\!

lt0@)-ErBtoniilfrp

: ^:'l1

ms9

clieft side

Yol4oql

A^+,t -ti

,-'vnmw- cctH oq

P

(>(tb\\

4

c'r'03 ls[w

trrst ) I1

S€.rw,, (idC

U[r,. 6lterx fq,glicah t, an,l rar*lt,ple Kr,sl,rr

la*llonu^ts

A4*1.

Page 32: Design Patterns Complete Notes (Natraz)

i

9* -fie inplemunr) cn 4 grssa Fotc'de les:Xn 1o+k' n rdrt e net odL ^,s^d klps zh

clir,,+ anl kcinevs &m7ew-r'ts , k r l^o+ Camwni cc'J't tn i'< Sy"lur,"oc's Ca"p'uacolt on '

to, rb clun* ;, Lo, 6 ta;t h VnuraJ< nsrs r<1au t unkrt 'e 't(ulf lt rctd*J &"n

nrltiple bugntN &rFre^r<.

Solutt ooi- u,re JMs and l"i DB <,+f,ct tt maVe Ce^w,umca-11a7 Llp .liw,t a-vrJ Lttstlnt-v<

Cui,LftN'ft ,M Artn&n ^oul aA Sl*,an oLw lioVo,, 4A-@

94",'41\n1-

Lo&" +"-

Clc-t< Conlaln 9

L06,, n

Loft,,t lo

e(ia"tt?311

,Jease +1,.e

CDED

tanlarc

apuahont ^ We ar 9u f5rld<t Tetft\ttN4'l'

""irl^* ^" DAO clc'x tot) ""'atriple

Drto clatt<

NarEi'->

6o

NaTE:- -n dwbp 7c*isranct l16;'s

live fiac,L;k,n"t" \erc

A ,a^pl \,,|",-uu crn fles<"yFoule der;yVu|'t<'rn ,"refu ftzno i- 2'Lr>3

DAo : (t* 4*,, geee) i-ftat1em""- |'lix;r5 tr-t, prr<i<l.,nce )r:6i. coi* u'1n^ [o|ics

daLsnbt EL,e ftts;r;q oP ^d;{6:r^a- J-

6{ -/lTlicallen ('tt*\ a6"'lnLxi*ts b6i'"

Wlct<n& lofltL ,h* )oukt e c/a it

d^t d a irs Jnts on d*ryu"A

--fit.'roll^'

I^g\"-'a* D*O dut'6n pr#cnn ' it k a Jd'Da(:\u's flot ktatn"*l Pctt(i&ata

ortu l"6t.s Q Ae qttt"ttn d**V t*i

and pror.,;.{ce hu;nt tt'X rP

D'ro

c

rcfa'(vr 6 e Ao*",UUe e[," SleC h c D AO CIc,r OLtctf Lase-J

frrprleJ . *lldc i< ure4.,t rnLo-n p^jert 1rrot, rltrl nl;pleyuN"-t^X (ane pc.r9,*amce Olret:rFlens Cm ynrLtlnlE Jct ,Le,Se

Jr ir plrcnEisn o? DAo ,Farl,t"1 ) Wkrhr fiL;cl" ccolann!' +L" oL;t;ry 6 ft

u\2 a'n{ fo*lslznge WIrcU'y

u ,1"" *,to il^"t it

Aat-J"<e so(hto:rg

(okrlc.tq9 .

bT. k P'k'

J, cne- YJ& fe.

1" Ju'o"6lo6rcz '

4^" A:nvelt cn

Connctl4 on

in Dlro Ll^A Pe-ca4

Page 33: Design Patterns Complete Notes (Natraz)

(\.,btic ctass llgDAOPacrurg

fllr"nn nnerl,od

P.rDtc sl.*ic DAO ge*D/0 (Sitrng t'a-ee'"1

if (na-e ' e,1l,al s l'brc'cre " ))Kirrrn OT4ceDAb [);

else iP (rr.rne'coilrars ( frgSlr "))

. .rer.,'n XXfurDAo();el \e

?€j,(^rh n&t I ./

ct4i5 DA0

Ii

6b5hc.tlr

IPkbI{ C Abst{u!-t

ftrbllc ubst6l.;.t*

WIL 6bfia-t*

PUbl L obst{aiJ

5

//lno cton 4^ osue

cla'rS Orade D A0

{void

exrcnJg DAO

,aveCw"zutr"C )

/1to3t. to ertzr'b\ls lr Conrrpr'rrm t-oi rb

rrnPeCoinrrcr, crt' ( ) )

rgn*fotna*rc^t) ,

insetlnPo (-'-'-' -) i

upl"rc-I"F2 (-'-, - t -) )

Qrr.cle #rte

vold

vDl d

int

lr*

PUluc

f

3

frb\lct

3

\lo\ d

ovile dbsl'o

pubilc lrLt{_

.l

?uJjc fnt(rL

n.teose$"nn'ctrclnC )

|1 toXv to 'r1dteox Cgnnet$

on tpll. uo*' AL"lo-,

in::"tlPa l-, -' -'l

flr,6,. ra \nte* 'rt-tu'l rix]-o

ulh-r*fot-D (-,-, -' -)

11 = llt1l'''to qJale v'wX lvt $,2<,rc Faltt'

Page 34: Design Patterns Complete Notes (Natraz)

DAo cV-,ts 4a l1y5lt

ciars lltSqrDno exnnds DAo

s' purr, , vo i d mav e Gnrne dllnL )

t - - - lotri. ru €tta-blis I" Cav'esi c- r,'rr4 Ytfic?l db 6tiJ '

\

lutil. vo{ d rcLeueGnnet{onL )t-' - - - |oX'lc ko wlea1 e CLo''€ntt:.n,'' pith l{4s?l Jb e tLo

ItWlrc iot inq'rl',Po (-l -, -, -)

I----.- lo'd\c rd )nscn'1- fttud l^to l't{s?l db (tlx

tDt6ltc inr crpl.rcLFo t-, - , -,*)

{- -- - lal; c It upAa*< *to'< d i''' \1X61t dit e tto'

1

O{'B'r DAO c\oJl

DAo F€.ct-cttY ,' o &*1 nalsrnrnft cno dDAo F€.ctscrry i3 a -ru* " 1 - \,

>.,rr te usaj in OS-

dora isor is 9t1pl;ci . -tLis F 'rq ctort

: ^ ^ ..-a-,-dara +l,ar- is ttlprr.c .

n _na n ynk_.^ | ,icc DA-o ctr'x obic

Tnjarr h ser *l"et c't"c

6 41ert tc"scA tn rl'e

*cryrrtt-g oe &e

lutlsXt""U

qJ-r,i tode

det* t3

cltrgs +-, Clienr

A-pp licc.don. So ,

Appri6"6- ln rrin5 ire tdl *e L,srntss

in r\e d*r'\S ot

cl ppri crlr crn s calls bus;nat5 aa$0"!s ol

te dq;n 6'+ heltit;ttr o( no&E'<cuon'

ttl', l-" '-'-bdrners Ccm?ctnenK

rf brsnerl tt'erB"l

-.-_-_--:-'Problerni- Frrs ineSs Jh Cli€nt

in 9'rwr a{Pt:4hon di"ecriX

a€ clrar[ed in .{tr..1 .

oturLo:- D€velbced bc\oe.{ f oJi cs to

Or.e tltm

apu;u4c,.".^ t6 *-iY *l^or Drc clw otler+ '

f3*,n.,. Pell6ate "*

mor?ro dt 4 srtuttr AnX rnodi 6 ccH ..ns

Page 35: Design Patterns Complete Notes (Natraz)

B(sl ness merfiod can l,crPq.m rham B.-rslnevs Deie-6as d^ clc,x a" J *o* ;s no ,prsels -nq 4

Disturbi..l ctirnt +$pl;crrfi ons .

--,f,rr o,na an61e ii calte Sru.rs Actt<vrc\ a}{ a! 8a(rirz?s Dl r0"r< wlen ;ru l"ttT 1"5t. cdilta

d,e knn"* nul*,As 4 lldet Loacx lzTE avnTcnli*'ts t"r) 9y'^X c'$L c"'A$a '

€erv ice Loorrr j-

PrDbl€nr:- TO

AppliccrrlcrrvJ

rP E*"x

og,rnx

clienl amlicanor)

mctr{tha.t- iic.r"osc{ nQ,tLoofli mond

C&ll Ersr.,ecS metads o? fcrs-inat5 Gm fnFarrs

IndfetEsa

d^ir

|-ri Ps

fn$rol C );

Ynusl fla$e4

E sg,rers &,nror.cr,r 'ftk-ftl.L?s 4.,r'.r *tr.q.I,o trsl ^g JNDe GJe

ec4t"c.te\ e-t^ BusrinerJ .tf,.*,.c. &r-

Betr,"6t"g fo 9,rutx +le cbt*

Solultmi- De$eloP

oP *.,vt'r ond to keep thcr atae ln $!S- .

-[rls iel6,r clc!19 is &ued u S..r, i ce Lo ce]er ' ct&44 .

-j trc g.'rrr dtLl de,,t\o p ,6, ee vice l_oc..Kt clccy, ds SlrngfU-an

LrrP? ers b ftoi oy\s .

j..oa q* 1-u ot-ri d rnatlHp)e

H€lEr cto{s l.arin 3 logig t0 gdrl'e{ BuJiner5 Gff4'rrotr.r vgfurene d P** "t" h1

t4ore ddiueriyq \r cWryr"t A1plicafims"

Page 36: Design Patterns Complete Notes (Natraz)

Ne qanrratlq us€ dvJ Seivicebcale a lclsg tai rl Bksihers Dl;041€ rlals .alc.n 3

anA gi€ ldne(s o5!^t / or l"nett vefcence and

mut d,s *t *l *t E^r{es cfiizt] teP{'"^ce an d -

Jq rbe a|lolt diagrar"t

BL{661n1s5 o5je* rePewncr

h cofi &rsi ne4

alplicc,Hon,

Ar ro Aro io|i cttt-t-s Ctieni Applttation I

;s 6a+Il.) h." n1r"r7 anJ t*ni"te".J

eeoace b<arct [U- 6e+Hn?

u(e. q

B, l-o Bt in&catcs ctlcr.r ,41p l,'callcrn Z & Lrrre t Sot,, of e,\ecL,# o^n rol"-q* +[. &1s;ne-<

&nyent-,at re(*arc ;, qdlc^.e" -!,". grefr.,i L^l "rl"

Bctsstne* terlodf,'

Satvtc< Locnte'r tspsoslr"le h

6ad"er

kxdrress ltUtafe ycsg6rtslrrtE

to Pccrs tle .rertr\t6 to cllen+

EusitessDalilcltr.ntm't)l

;aoTl?ontni

b?'ltL')6---- (18'l

I (ts6 )t!-Dlor();

foro 4 erel..uor, !D k".e

in tk 'St,eF.' .tt-

ol S.a;te l*<rtta, Caft il'l

Page 37: Design Patterns Complete Notes (Natraz)

€truf 5, EJB c,o d JDBC technol o6,r, )ou'ng rhe i -plrrot'.'t."6,'.'lvlINI koietl- b9 ustng

rnLr\dple Des;6nPa$crng ;-

3

,. le

. ct,

..". €

5 r,6

E+

sc

qq

4

E

ICF:12€

.t

-a-e

_s

fts(5q5T2e-2

Page 38: Design Patterns Complete Notes (Natraz)

t slo l lrot >

0 Fixrn Paxe e&bm',r5 he *af asr bX teiectl n.X B",e ltem 4 sded bo^

@ As 6 c.",ilftlte'{ Aaicn *'tv tz+ +ft'P s and 'loYcc 1'la r1azs t

@ luton*nr ter t:su fhe e*ies ol Sflut| ' co"$ 6ut ono" ];rc d"';'le ]at han ao| Moncltt!''

h PmcesS rhe waTtesf '

@ Auic'nktvle'r nr; as txe h^lau to Fa'^Beot cl avs oqet '

&J 'r. lo rh€ dlagv am

..-, (O A* .,,.*,ulu- (rttts *e utu'1<L) oP Atsanctttl

l,3r;:,,,^tr:;':**:::.J^*"-i^'ouy:';::-'ratLiLr{'{ExBb*tv"^r

,r"fe'*nrc in B'l&'r U'l U*e a no,, i+airtbe 0*h"^

A-" J"

- tt gnre EJQ 6a7np6'^ea* 12Pe1z ntc is rur atw rasLe in Buf(u f ) &^lPe" 4

ryt<\ sl,') o? Avpl;to.t;crnsuw't anl o'rrse n;st<"J r'c;J- tle o't^" '- '

\, grvite Lxoi-<n -- +D Buv; vrevtDlu{ '}*

-' O Se,viteLoulat wssLs #e EIB c^r& zt'fu*ntc a /"t&*;'e< ^e'!'"J4

- O Ews',tssDel;pt<- cLd'ts Lx'r r{or EJR csr"ron** *Pa't'^Le *A d

t cta*' fi<en) oA ue

.- EJR Carn('u'L,'f '

g{,oqoq"(@ {1.i' Tu'1qiil('!4 -n},od ::'"' L}:':-- #:':;: Bu*:,,..xD&3,!

gaL #,!e.,r yn , Pom&u" 4',11't- a'l flul" t Nno't Li't

- (ts Bu:tintst *oLo) "? Elg u'^t4ett

'* 'u

Ut '{8utr u " ')

- @ &uo^^ ?a^6^r."Jr*- ^r*u +!",zrecuLr fo e)'eutco

, -.,h. *Le-t-qJ'-lt+o h-n^9*t''

_ ra pxpu&L) kr+ p^L .ras^tt in *11'tsr alhtu'rc a') *o^'"'0.,.

4* th -ruut{tu'Ie

v s'u'4- r us.l +{c nn1'';'t & kn-t-W'oh'-

h

' @q@ O*\un.

(dJ,or ta Resu*,isp ,,,^ taqtc onr wa.sl^'r'ru'^lt*) 7as

rxe '*

"

n' ,, br u,,y ynu,rdl.n lTtc a

' g Bu*tt'jsn S-6 il"tnuurrs \u

'e to fL k' " ; *'\aXe os lrnt- +'ble cott''*'

Page 39: Design Patterns Complete Notes (Natraz)

Erplicitll imelemerteA Dca;6n W+:.{ t1s oP ile alov{ lni ett : - "J

-kJ, i, *r|^* t* k:*ot --,Q F4(ord d.J.r )

O nvca 't1- dJb ca @?o^e^+ v-isP gvDgram I

@ o*o

(9 D'r'o classlv'o ct^-\^

(Q &'ssi"cwDu6't'

@ *""'Lo-t^(D S,"M- jaria cfa*!,w,*,r*l F$"itp1"--rrn1

@ ftu'a A'e )

c- Atr,r' QnIt

6 O^^*n*, tnt f-*'c'--> o{ &'y""*'vP*cw-

F* tt''" aLove r6.yn base f"l rn Pgjg! ll-tn fle imfenlta-/t "o oP )erlXoP"*t"' '

'.tP<rr +[. &1. -l,b.to* or1 IPl"n Zol>

\t

.o

n\

9* r r"loe't-- '

@ V,*, +1elru{ DaaT?aJ+r"n

'-*" tut.; F D';x"Poric'"""

4- t0'o oL"'.- P'qic$ "-

O ;;.'ffi;* '7n* n*-*o "ld,on

ctox tu httto'*".u\tr

O lt.o c*xf v,6 ctda L**"7^' ^ r^",*-,

Page 40: Design Patterns Complete Notes (Natraz)

\*' pro,"Oo* f0 cteploqee ord €xe(lde clesign praiect bc'se '1 m;n! Prqject Q banla't

ala.stS

* 'jartlr)

.:.,

-o

<.

!-ro

F\'C

F

iigd

i1 '

.Es{$r

tsccil?4:lcl\\lc

-I

sE.t€c,!lctr

cts-

ot,

o

vE!,t

e{v?oc^FcJgb!t&.Ectr

e31II

J.

d$.??K

!

.g_,

dF5

d

a;a-1

tv.J

€!_

I

.9

I!'5

-a

\x

IJJ

:^E

.c

Ef

i\.J

6-J

.?-c

It.J

c- .4 --)

'rdEsy

.4vs6

u-2

ct!l3

d3

3v.€3?g& 6t

(lf r.tj

-.-

s^tEe&9'art+!Yqeicl+5

-!s$.J o/

e- aJ

,:

(-')L4

3

(n

.J

9./

\o

!"fl.{r1

',. irr-

I2\r-{ 1

.Dliii3\

I.:lI

<ic

.q

d

.ilo:-P

\,J

I(o

3

vt

.?

i

€e_!

cc,

o-g.)

. ,tt!

6..!

! s-rFqS.Y -,o o

FE9

-'-e-

ttt\tl\lle-ll I

E\L'g

6

+

tJ-

\!l

c-

\\

\

-s\

I rE

qr :1

a-i

-Jttl

eldlol:-I

ci€

l-q

o-A

!l

Page 41: Design Patterns Complete Notes (Natraz)

h*Pr{/\ocarhP sT'' wwfr ery'*

fornbine \(av o.d J.." f, f. s Eav 9t te 'ond

€ar . Pi1n =B'e

6'rc

&qrtast UB L I'

OEn broose'r oin do@

F€fir€ Ja. 6'reS r.{teSc^f't$ EJB 6en06nerLt :-

E.,\ D ?prDi€l+ 14f\ co-pr> jar cP Copi'ja't

rtne.r6 ave L,,0 cDoJ s ro ' dePlqe e !

Afl,-alhJ',- , D4lo9te Wa' anl 'F' $rt' g+*d\ in 6l*'f"l' Q*sr

'\

,--1

Gr,".P*!' sttn"n '

--;, ,*oar'"" nna camP!"ia't 9'''s to

lcrlosrA't -lotz t\ 41"^,,'\ Jomot's\mgJa'"c"in! \@"trad+l'1a f"rau

dr"r

-t; - ec;o

jar ftre +jt^r Bta + - .

jarF;te+qtvSitc+ - - - ., o

a*rfue + w,t (;u+. . . - - "

FnT€st

51or6fr1P 'toarl

GinP..-'j4'1

dqtofetnS

wl

an'Lcth;rn -l-3 dn'ffiF\

60? ti 4"16n - X :^ \

-: t W*'

. *' " lrlitrr* (^ \tu'' br"viY'i:

ilvN

l31nu cad ar' >

/dispttJ'J - narc'zclercmpd a' u

Zmod"tE 7

> ee,Te:t ld-n2Srru,ts Ffl fFicu

/ ejb>

,, LlesrrdlAh.

, 14b> Corvrl!" i*r

4lrno0"Ie >

t*l*t ra*p\ica-rlc'rn'xrnl

prq.u'€-J eo, {te-!JDrp"o;.,t\E^rtsr) ja* cP Frer&oP'€a'{

Page 42: Design Patterns Complete Notes (Natraz)

1

_ -2

iq567a9

1011LZ13L415

&)afLor r 16o1*,.n"sl rzta<rt& / a86;6ple ) 19rrf.iE l20d' o Ffl( \-2 1

2223'2425.262728293031323334

, 3536

app2 hrip: /ilo<41 h0.sileh lsrux p+t---r Omain-jsp-------- -- Nel.ome f4e Cv )

-=* kl

<frameset r ow s=' t 3oo/o,7 Oo/ott ><frame name="f1" src= "Sea rch"jsp"><frame name= "f2"/ >

serach.jsp------ -------- Fc'.-Bc'str Lvit'p )<o/o@taqlib uri="htto://struts,ar,ache.orqltaqs-html,'prefix="html,,o/o><96-@!g-S!ib uri = "http: / /struts.aoache.oro /tads-bean" prefix=',bean" o/o><html:form action="F?IgIpe!I" target="f2.'> T>)rl [1!f a)

@ !.*-l{1 A(}ioa cla s 5"(-.,e6 [.r no:, sj)<bean: message ke-y="1py.161"r t_FteFer:ar<html;select property="job" multiple="yes">

<html;option value="CLERK">CLERKS<,/html:option><html:option va lue= "MANAGER"> MANAGERS< / htm l:optio n ><html;option value="ANALYST">ANALYSTS</html:option><htrnl;option value="SALESMAN">SALESMEN</html:option>

.J

</frameset>

</html:select>

<htrrd:submit><beanimessage

</html:submit>

</html:form>myfile,properti

# To change this template, choose Tools I Templates# and open the template in the editor.my.lbl=Select job(s)btn.cap=Search

xr) ro\t- h,:'liYT1i-*(rt

",^ l"a a'1+a G"^rnt4

l''"' r+e ,"lO .wr6&rc lht&h&" ** | t'tt\ Le e*b'Fljs fram e ,oh"r' h4rhd ls Bv'I

key= "btn.cap"/ >J6

39404L424344454647484950515253545556575859606162

<web-app version="2.5" xmlns= "htto I / /iava.sun,com /xml /ns/iavaee'.xmlns!xsi="http:/ /www.w3.orql2OO1 /XMLSchema-instance.'

xsi:schemaLocatio.t= @http://iava.sun.com./xml/nsliavaee/web-app 2 5.isd'.><serv Iet>

<servlet-name>action</servlet-name>< servlet-class> org.a pache.struts.action.Actionserviet</servlet-class><init-param>

< pa ra rn-name> config< / pa ra m-name>< pa ra m-value> / WEB-INF/struts-config.xml</ p.."rh-r,il r.> k

</init-pararh><load-on-startup>2</load-on-startup>

</servlet>

<servlet-mapping ><servlet-name>action</servlet-name>< url-pattern> *.do< / url-pattern >

< /servlet-mapping >

< we lcome-f ile-list><welcome-file>lq!I!EE</wetcome-fite> (Il

< /welco me-file-list> - /."

Ne.,_k'fos.dn?'tr.'''t 6 4

li.'tt 6 566676A69

<struts-config><form-beans>

<form-bean name= "sf "</form-bearis>

type= "Sea rchForm "/ >

<action-ma ppings><action na-e= "sf" path=" >

?& shurs A<*a, ctar^ cfo (J Pase 1 of " L"[D

36-5\ @

e**s (rznh1avttn krc Q"*,aw

"-/ / Apache Software Foundation/ i/ DTD Struts Configuration l.3/ /EN-"http: / / iaka rta.apache.oro /struts /dtds / struts-confia 1 3.dtd',>

</web-app>

<!DOCTYPE struts-config PUBLIC

6c io

L

Page 43: Design Patterns Complete Notes (Natraz)

@,"- 7t

72737475

<torward name =..success,. path =,,/ resu lt.islp,, /></action></action-mappings>

Co(Jvert'ade 6t;-tri:iii::::,:::::l =:"9.=rActionMappine

mappins,

< message-resources parameter=,.myfile.,/ > --, wr"rt$ R.te coo B 6,-.r..lic,r1

76 </struts-config>

il, 1;;;;;;;;;,;'";;;.;;.'",:il:H$T;,,?l'----------------------tu-u"',(-r"r<" r"vcr)79 irn port org.apache.struti."ction.action"lOO],{n,go import org,apache.struts.action-Actionr".-rij"".a182 public class SearchForm extends ActionForm {fi

private strins jobD; fJr

l,.r.r r,,r+rt"- vlr,..i' ."uLt {* 1;r, uo^

f# public void reset(ActionMappingmapping,HttpservletRequest req)

lii . i:3t"=Y.:1i,'3n"l1t;,"".Irl--ro6;. +ohonarehosser.rr€r srar.cf lisrtor J,;tnw"vta'4*e)9(} Scr(rm scqr.J T-rBr.;?1 pubric strins[] geLrob() { _r92 return jobi -- -

Ie3l'J'r94

A f-9s pubtic void seuob(String[] job) {( oJ I e6 this.job = job;- L_92 )

9aes )too ----------. ------sea rchAct;o.,:.iav-a------.--- ____________--&ln CWw ((c"*nt^fu'a)191 !-p".t j"va. utit.ArrayListi1O2 import javax.servlet.ittp. *;1O3 importorg.apache,struts.action.+;to41O5 public class SearchAction extends Action1()6 @overr.ide /,-:\Lo7 publicActionFo.ward exewte(ActionM€pping-mapping, ActionForm form,1oa HrtpservtetReq""=-. ."o".rll.,r1i,1o9 throws Exception { . rservletResponse response)

, 110 ,//read form djtalo$i.r. n%d e111 Sea rch Form_sf= (Search Form )for.ni -__J Tvfec,rsAyPJ^IfrvJ,!!? strinejobs[]=sdg";"b(;'"','"'",,i;r,u* ii'o 3liliil:lll|Iil:il[::il,:T:'.:1i,1;;:"];.,;.";:1o,".",, !115

116 ,/,/ call B.method- 117 R rr<iha-ch6r---.^ LrB usinessDelegate bd=new EM:j:!.]*::: ( );k rjff #d,-rft Hilffi'StDii #tr4":#H,*,ft?ffiffi;;;l2o !q'rrr'e r''meEnoo ');

a."apq lr're rn I tll t zoo )L2LL2Z / / send result to result page as req attribute

GX tll: req-uest.setAttri uute1,..e-sui1;,, j;-- -."\:yl l_: / trorwatd control to result paqey1: returnmapping.fi.ndForwardl,.iuccess,,).

L?6 Il / executel_,_,_,_1 -( -!!!ve' ,'127 > / / ctassL28

.r,..( i*^1,-,-F,r",'a q"*inlnon"Der)Vts?a+tn129 ___________

13O import java.util.*l --------servicelocator.java-------ll1t-t-:{t-1i-"?- I &,,nk"ol t, "4 o't

131 import javax.naming.*;L32

lii ?'o,,. "." u.*,..1".r.", ,l- 't't.on'T,t:, e or v,*orldrrt Er3 c"*M "*#4Y135 private Hashtable cache:->r"mdi$tar n l0'ar (*'

1,r rv.tEe l.laShtable Cachet,T)rom

i3, private rnitiatcontfi-ffi 6.N.,r+,j oro( y.+*nr {u,. . 'r

134 private static Servicelocator sl=nuJ1.. l4ua6rari- Stna te {rmu Page2 of 4

g,method");

Page 44: Design Patterns Complete Notes (Natraz)

CD

bn't telarotc,t Co.la'lssne

n r^L", tt*;o-*le" c^Le"

CaAt co.t u$ E,.epG/

139- 140- 141-L42143

'.44145- L46

private

try

servicelocator( I 1l rr"r"r. ccuch*l-trt ( a g-nt'r 9t9\ek")

- ^447lqr. r, \raee+'h"t ^.l Ms3ffri"il rso;J ..r l.{t'.-ls 1

".9p.ll'"13"xY' 1s4rbs1561571s8159

-160I re r,--r I rez( lo) / ros\J/ L64\ res

vtz:16a

PzrcsIL70lstlvzI L73I lt7411171

r:l I i rzo{lkllurz;\J I rze

I179I reoI rarI 182I rssI re+| 1ssi 1a6L:^az

1aa149190191L921931"94195L96197199199200

fit2o1\yL2o2

203204205

' 296zbz

Cache = new Hashtable( )i

,/,/ jndi propertiesHashtabte ht=new HashtableO;

ht. put( Context.rNITrAL_CONTEXT_FACTORy,"com.sun_enterprise.naming.SeriallnitContextFactory,.)i

ht. put(Context.pROVIDER_URL,,'iiopr / / tocalhojt:4a4[t,, );ic=new f nitialContext(ht);j/ ltrycatch(Exception e){

e.printStackTrace( );)

)//constructor

/ / Faetory rnethid having singleton logic ^ ,public st;tic servicelocJtor 6"ir-Li"i"iil n A*ta"t er.tha1- :

if(sl = = ng11;sl=new serviceLocatorO;

..!return sl;

),//getLocator( )

/ / tnethod having Servicelocator fmpl logicpublic Object getService(String jndiNamejthrows Exception{

System.out"println( " ServoceLocator:getservice(_)',)i

i",.,,--.ti:Y:* Y'l , . u" ..* u,,i&lac^rco"kif( lcaihe.conta insKey(jndiNime ) ) -----l ,ig fl|ryr Jrro+ nz,r,^c i< rtof al){di..Ae ut V

J ^ , ,t=_-_-_-*-

cache.Put( j nd iNa me, ic.lookup(jndiName) ); I *a pat ad^F !^t 'ek snt" *'' u #*t ,e', ,

, //rl',j -T gr*,o ti^""t*A:-j kt -.1 tc.x d o'r f,r:or "ray're arJ i+ €rr I s< ?

ble d rn

catchaException e) +ti $ilrt loQf {".1-. a\ n:r{ JND1 h^!\e,{ 'x'

e. printStackTrace ( )i> / / catch

// Return object from cachereturn Cache. get(jnd i N a me );

-----------E-&n "rr wt rr""c c

)i/,/ getservice( ) *t* tt

>/ lclass L-"-r;,*----------Bus i ness Del e gate.java---CLqJ5-''.!!e--------.,.import java. util. *;import com p. Myco m p Re m ote;

public class BusinessDelegatear\

(\,r )public A rray List s".n>-:"!j(9!!ngj"-q[f )throws Exceptiont_-

Q yin !bg!n3:,,c \tlt\ 5a'nl.,'ncJ 'nffi.

Pagie 3 of 4

Page 45: Design Patterns Complete Notes (Natraz)

,.4-\, -/^.a I

,b€ji(,-\t'Js\\:/2og - -------- -- -- - ---- -- - - - -- - - resurt.jsp----d4-q!t-Pt-.--------------2O9 <%lQEag€ import = "java-util. +,java.i'nath. *,p 1. EmpBea n " o/o >27-O27. L <o/o212 ArrayListal=(ArrayList)request,getAttribute("result");213 o/o>2i4 <center> . ,r2tS <table border width="1ooo/o" bgcolor= "#FFFFFF">2]-6 < tr>2t7 <th>EMPNO</th>21a <th>ENAME</th>2L9 <th>JOB< /th>22O <th>SAL</th>22L < /tr>222223 <o/o224 for(i nt i=O;i<al.sizeO;i++)22s {226 EmpBean eb= (EmpBean)at.9et(i);227 BigDecimal bd=new BigDecimal(eb.getsal( ) );228 o/o>229 <tr>23O <td > < b > < o/o =eb.getEmpnoo o/o></b></td>23I <td> < b > < o/o=eb.getEname( ) o/o></b></td>232 (td><b><o/o=eb.gelrobo.o/6></b><ftd>233 <td > <b> < o/o

= bd.setscale(2,BigDecimal.ROUND_HALF_Up )o/o > < /b></td>234 </t-r>235 <o/o236)..J237 o/o>238 </table>239 <./centei>24024L242 <o/o--<o/o@taolib uri= "htto: / / struts.aoache,oro / taqs-html,, prefix= "htmi'. o/o >243 <o/o@taolib u ri = " http: / / struts.apache,oro /taos-bean" prefix=',bean',o/o >244 <o/o@oaae import= "java. util, *,p 1. Empgean"o/o>245246 <o/o System.out. pri ntln( "In result;jsp,'); o/o >247248 <ta bl e border=1>249 <o/o25o Arraylist al = (ArrayList)request.getAttribute( "result" ); -l

rerJs fl.e refo.V al+ribtE- \loJtL251 o/o>

zt!3 . toni",.,otEmpty name="resqtt" scope=,,request,,> ---, cLcr1* o*p"^a*+o v d#L'.t< B -wh ;-254 <tr>255 <td>ENO</td>256 <td>ENAME</Id>257 <td>DESG</td25a <td>SALARY</Id>259 </tr>260

log; cr6 6e f 261 <logic:iterate id="id1" collection = "<o/d =alo/o>,, ) bti. Fc dr al_.rl tlr rtt^!8 af. . t 262ll.lDnlb rh< I ^--

262 <tr> I -

263 <td> <bean:write name=,,id1,,property=,,emp no', /></td> f arqd trlr a{ trrl ta'6(e c-tl€"l-

Aq&ilts 4 264 <td> <bean:write name="id1" property= "enam e" l></td>tu,'tti'r.)'l 19: <td> <bean:write name="id1" property="job" I > < / td>e",r"lr.,"s"f ]!! <td><bean:write name="id1" property="sal,, / > < / td>-:- ,|'267 </tr>if , ['o^rts tr\269 </loSic:iterate

6he €t{r.?flf dg 2 6 9

A {r.xL,,t 27 o-. -E-*&T.,f< / logic: notEmpty>

< /table> --olo >

Page 4 of 4

Page 46: Design Patterns Complete Notes (Natraz)

a--' (2)

2 ApPl

.4 ---------------------MyCompRemote--------------------------- &{sr;n<r4 l^rcht"'l E8;t'-1"'t t -5 package comp; "r (ftod.l la'<-;-6 import java-util.ArrayList;7 import javax -eib.Relnote;

3 "t=llno-'""".

*",,,.1;l;;'?I das PernorBr''ervrl t^tatrar"

10 public interface MycompRemote {11 public ArrayList search(String job[]);

^i3 i---:";;;";;-.-l-li#rs :1 ?tv*v).c^auu*\'14 package comp;15 importjava.util.ArrayList;16 importjavax.ejb.Stateless;17 import p l.ErnpBean;

. . r:liho.l3

"r,.r","" :"#J"*o:'t; ..r slsr(s,or'tcx srrst"' &a'n)

20 public class Mycollq.Bean implements MyCompRemote {2L /-lo=]-* s,rsi*" ^(h"d22 public Arraylistqtlgb (strinsl] jobs) {23 system.out.priEEn(;MycompBean:serach(-) method")i242s | / write b.losic tD Ptaore 6s.!lrro nv'hd +4 g|t Yn26 StringBuffer sb=new StringBuffero; -J27 sb.append("(")i. 3rttJ28 for( int i =oii<jobs.length;i+ + )29{30 if( i == jobs.length-1)31 sb.append( " "'+jobs [i] + ""'),32 else33 sb.a ppend( " "'+jobs[i] + "',");34)

373a / / use the persistance logic of DAO clas

35 sb-append(")") i - ,,.., . -,...t-) -t, +j' s,,t q/rana lt,,-e- t/ 'crfn *', ' f*urcnf f.' )35 sb-a ppend( " )" )i36 string cond=sb.tostri n9 ( ); r+ 3i"'s rdndlton Y."9a'-f,'{a &'+l T'4A {tre ('curr"' fJA tu)ER

t.r", ", "r'55 66;1 ruyoi<5 JJo=.t.w MyDAog; -- r"W llh. no's 5t hD q3

E*oq3 L4O\:?i Arrayl.ist a I = dao.findEmp !oyees( cond ); --.,--

*-\s6-AK-/

4l42434445464748495()51525354555657585960616263646566676a6s

return al:>rr'""*fq*> / / class yoao-.Jses----- Uildle4"l )

fi ndEm ployees(Stri n9 cond )i;|-A t*ir'1 Pc&lstanle- l..6; c

system.o ut. println( "find Employees(- );MyDAO" );

connection con= null;Statement st= null;Resultset rs= nulliArrayList al=new ArrayList( )i

trytclass.f orName( "oracle.jdbc.driver.oracleDriver")icon= DriverManager.getconnection( "id bc:oracle:thin: @localhost:1,521:satva'r,"scottrr,rrtist=con.createstatement( );rs=st,executeQuery("select empno,ename,iob,sal frqm ernp wherc job in "

sete!+ Paqe 1 of 2"n"', .'[fi?]rii'r1, p,o zyn, i"qe jos in (Lueev','rvwrooe') ana<" \

ns +a &'s;,1,aT>t;Pte cloxs '

--------------Mpackage comp;import java.sql.*;import java.util. *;import p'..EmpBean;

public class MYDAO {

p u blic ArrayList{

job

Page 47: Design Patterns Complete Notes (Natraz)

+ cond+" order b:. job");while( rs-next( ) )

{System,out.println("In while")tEmpBean eb=new EmpBean( );

eb.seaEmpno(rs.getlnt( 1));eb.setEname( rs.getstring(2) );eb.seudb(rs.9etstrin9(3));eb.setsal ( rs.getFloat(4) );

al.add(eb);> / / while

rs.close( );st.close( );

con.close( );>/ ltrvcatch(Exception ee){System,out.printl n(ee.tostring( ))i)return al: rt rtfs\ns

)77?l-"a-Effitoyees> / / class

fa the vr..cb rnolo d 4 frS Cor/'l'ctn"r fkt'n cla'u

package p1;import java.io. *;

public class EmpBean implements11L1111111111111111111111L1111

Serializable*-q"",l'd,J..^jprivateprivateprivateprivate

int empno;String enarneiStrinq job;float sal;

getEmpno( ) {empno;

public intretiJ rat

)public void setEmpno(int emp o) {

this.empno = empno;)public String getEname( ) t

return ename;)public void setEname(String ename) {

this.ename = ename;)public string getJob( ) {

return jobilpublic vaid

this.jobsetJob(string job) {

= job;)public float getsal( ) {

return sa li)public void setsal(float sal) {

this.sal = sal;

!./hrn N1 J.p ls1lg Ef,B a' t e-fffealn r i'r Crrlorsfi rl La/6 Ab *l,t Sunl,trw inxxkc ^umQ-bt' ftj bnyurL^a

Alranaht\ k@rnet -JNDI nqrnlPage 2 ot 2

L^r 8J7,1 c",i,Jl"i'ik*,, +ta+'1s pla"'l n.'(tn #X\n .

61(Arrajustfbj )

ID} TAli .LEPP

?", d.e o!r*" 6'\feuk CDr.p, MdCAr^pVn " t< O6 rt J\th ^ame,

Page 48: Design Patterns Complete Notes (Natraz)

I would try to update our site JavaEra.com everyday with various interesting

facts, scenarios and interview questions. Keep visiting regularly.....

Thanks and I wish all the readers all the best in the interviews.

www.JavaEra.com

A Perfect Place for All Java Resources