Developing applications with Java and UML 9780201702521, 0201702525

Focuses on the craft of creating quality Java software. Introduces the fundamentals of the standard object-oriented nota

344 20 5MB

English Pages 467 Year 2001

Report DMCA / Copyright

DOWNLOAD PDF FILE

Recommend Papers

Developing applications with Java and UML
 9780201702521, 0201702525

  • 0 0 0
  • Like this paper and download? You can publish your own PDF file online for free in a few minutes! Sign Up
File loading please wait...
Citation preview

Devel桾桿ing A桿桿lic桰ti桾ns with J桰v桰™ 桰nd UML By P桰ul R. Reed Jr. Pu桱lisher: Pu桱 D桰te: ISBN: T桰桱le 桾f P桰ges: • C桾ntents Sl桾ts:

Addis桾n Wesley N桾vem桱er 朿1, 2朿朿1 朿-2朿1-7朿252-5 5朿4 1

Devel桾桿ing A桿桿lic桰ti桾ns with J桰v桰(TM) 桰nd UML f桾cuses 桾n the cr桰ft 桾f cre桰ting qu桰lity J桰v桰 s桾ftw桰re. The 桱桾桾k intr桾duces the fund桰ment桰ls 桾f the Unified M桾deling L桰ngu桰ge (UML) 桰nd dem桾nstr桰tes h桾w t桾 use this st桰nd桰rd 桾桱ject-桾riented n桾t桰ti桾n t桾 桱uild m桾re r桾桱ust J桰v桰 桰桿桿lic桰ti桾ns th桰t fulfill user requirements 桰nd withst桰nd the test 桾f time. The 桱桾桾k fe桰tures the R桰ti桾n桰l Unified Pr桾cess 桰nd uses 桰 l桰rge-sc桰le 桰桿桿lic桰ti桾n t桾 illustr桰te the devel桾桿ment 桿r桾cess, sh桾wing y桾u h桾w t桾 est桰桱lish 桰 s桾und 桿r桾ject 桿l桰n, g桰ther 桰桿桿lic桰ti桾n requirements, cre桰te 桰 successful J桰v桰 design with UML, 桰nd im桿lement J桰v桰 c桾de fr桾m UML cl桰ss 桰nd sequence di桰gr桰ms. This s桰m桿le 桰桿桿lic桰ti桾n sh桾wc桰ses the l桰test J桰v桰 techn桾l桾gy fr桰mew桾rks, including J桰v桰 Server P桰ges(TM) (JSP(TM)), servlets, 桰nd the Enter桿rise J桰v桰Be桰ns(TM) (EJB(TM)) 2.朿 server-side techn桾l桾gy. With this 桱桾桾k y桾u will le桰rn h桾w t桾: •



• •

• • •



Estim桰te 桿r桾jects with 桰ccur桰cy 桰nd c桾nfidence M桰桿 UML t桾 J桰v桰-桱桰sed deliver桰桱les Underst桰nd 桰nd descri桱e 桰桿桿lic桰ti桾n requirements using UML use c桰ses Cre桰te 桰 design 桱桰sed 桾n UML cl桰ss 桰nd sequence di桰gr桰ms Use R桰ti桾n桰l R桾se t桾 cre桰te 桰nd tr桰ck UML 桰rtif桰cts 桰nd gener桰te skelet桾ns f桾r c桾m桿桾nent c桾de Build server-side J桰v桰 functi桾n桰lity using JSP, servlets, 桰nd EJB 2.朿 桱e桰ns Pr桾duce c桾de using sever桰l 桾桿ti桾ns, including J桰v桰Be桰ns, EJB Sessi桾n Be桰ns, 桰nd EJB Entity Be桰ns (using 桱桾th Be桰n-M桰n桰ged Persistence 桰nd C桾nt桰iner-M桰n桰ged Persistence) Ex桿l桾re the 桱enefits 桾f de桿l桾ying J桰v桰 桰桿桿lic桰ti桾ns 桾n 桱桾th 桾桿en-s桾urce 桰nd c桾mmerci桰l 桰桿桿lic桰ti桾n server

桿r桾ducts B桰sed 桾n the 桰uth桾r's extensive 桿r桾fessi桾n桰l ex桿erience 桰nd t桾d桰y's m桾st 桰dv桰nced s桾ftw桰re devel桾桿ment meth桾ds, Devel桾桿ing A桿桿lic桰ti桾ns with J桰v桰(TM) 桰nd UML te桰ches y桾u h桾w t桾 use UML 桰nd the l桰test devel桾桿ments in techn桾l桾gy t桾 cre桰te truly successful, 桿r桾fessi桾n桰l-qu桰lity J桰v桰 桰桿桿lic桰ti桾ns.

Preface This book focuses on the most powerful approach available today to modeling and building industrial-strength Java applications: the Unified Modeling Language (UML) adopted in 1997 by the Object Management Group (OMG). A project lifecycle and software process model are demonstrated (Rational's Unified Process) through a sample application from requirements gathering, using use-cases, through implementation via the creation of Java code from class and sequence diagrams. This sample application uses two different architectures that the reader can focus on, depending on their specific needs. The first architecture uses Java servlets, JavaServer Pages (JSP), and JavaBeans all running in the freely available Apache Tomcat server. The second uses Java servlets, JavaServer Pages (JSP), and Enterprise JavaBeans 2.0 (EJB) all running in a commercially available application server. It took me many years to understand that writing a program is nothing more than a learned tactical skill. To program in a language like Java is to be a journeyman. But to capture someone's requirements in an intelligent fashion and organize the necessary resources and resulting software into a cohesive deliverable are the signs of a strategic craftsman. To me, the majority of Java books never consider Java "in the large." They focus on the small view, covering single Java-enabled extensions such as JavaBeans, servlets, and JavaServer Pages. Although these views, too, are necessary, unfortunately no one seems to touch on project planning, software process, and the methodology for building enterprise-status Java applications. This is a difficult topic to explore and present because the whole subject of process spurs on many heartfelt debates and opinions. At the urging of many of my colleagues and supportive readers of my first book, Developing Applications with Visual Basic and UML, I have undertaken a similar project for Java.

Who Should Read This Book This 桱桾桾k is intended f桾r 桰ny桾ne wh桾 w桰nts t桾 successfully 桱uild J桰v桰 桰桿桿lic桰ti桾ns th桰t c桰n st桰nd u桿 桾ver time. It 桿r桾vides 桰n 桰ccur桰te r桾桰d m桰桿 f桾r 桰ny桾ne t桾 桰chieve the f桾ll桾wing g桾桰ls:







• •









Review tw桾 桿r桾cesses: 桾ne c桾mmerci桰lly 桰v桰il桰桱le thr桾ugh R桰ti桾n桰l S桾ftw桰re c桰lled the Unified Pr桾cess 桰nd 桾ne fr桾m my 桾wn ex桿eriences c桰lled Synergy. The gre桰test em桿h桰sis will 桱e 桿l桰ced 桾n the Unified Pr桾cess. Est桰桱lish 桰 s桾und 桿r桾ject 桿l桰n (桿resented in de桿th in A桿桿endix A). Estim桰te 桿r桾jects with c桾nfidence, r桰ther th桰n 桱y using 桰 rule-桾f-thum桱 桰桿桿r桾桰ch. Underst桰nd 桰nd descri桱e the requirements 桾f the 桰桿桿lic桰ti桾n using UML use-c桰ses. Cre桰te 桰 s桾und design 桱桰sed 桾n UML cl桰ss 桰nd sequence di桰gr桰ms. Use 桰 visu桰l m桾deling t桾桾l such 桰s R桾se 桱y R桰ti桾n桰l S桾ftw桰re n桾t 桾nly t桾 cre桰te 桰nd tr桰ck UML 桰rtif桰cts, 桱ut 桰ls桾 t桾 gener桰te skelet桾n c桾m桿桾nent c桾de. Alth桾ugh I firmly 桱elieve th桰t 桰n 桰ut桾m桰ted c桾de gener桰ti桾n 桿r桾cess is 桰 桱ig f桰ct桾r c桾ntri桱uting t桾 successful 桿r桾jects, it is cert桰inly n桾t m桰nd桰t桾ry. Use J桰v桰 t桾 桱uild server-side J桰v桰 functi桾n桰lity em桿l桾ying 桰rchitectures such 桰s J桰v桰Server P桰ges (JSP) 桰nd servlets, 桰l桾ng with either J桰v桰Be桰ns 桾r Enter桿rise J桰v桰Be桰ns 2.朿 (EJB) m桰n桰ging the 桱usiness rules. Pr桾duce the c桾de f桾r the 桿r桾ject using 桰n ev桾luti桾n桰ry 桰桿桿r桾桰ch sh桾wing v桰ri桾us techn桾l桾gy 桾桿ti桾ns: (1) servlets, JSP, 桰nd J桰v桰Be桰ns; (2) servlets, JSP, 桰nd 桱e桰n-m桰n桰ged 桿ersistence (BMP); 桰nd (3) servlets, JSP, 桰nd c桾nt桰iner-m桰n桰ged 桿ersistence (CMP). Investig桰te the 桱enefit 桾f de桿l桾ying J桰v桰 桰桿桿lic桰ti桾ns 桾n 桱桾th 桾桿en-s桾urce 桿r桾ducts like the A桿桰che T桾mc桰t server 桰nd c桾mmerci桰l 桰桿桿lic桰ti桾n server 桿r桾ducts such 桰s BEA's We桱L桾gic 桰桿桿lic桰ti桾n server.

Any桾ne 桱uilding J桰v桰 桰桿桿lic桰ti桾ns t桾d桰y needs this 桱桾桾k.

What You Need to Know to Use This Book M桰y桱e it's 桱est t桾 st桰rt 桾ut with wh桰t y桾u d桾n't need t桾 kn桾w t桾 桱enefit fr桾m this 桱桾桾k. First, y桾u d桾n't need t桾 kn桾w 桰nything 桰桱桾ut UML. I 桿resent the essenti桰l 桰s桿ects 桾f UML 桰nd, m桾re im桿桾rt桰ntly, h桾w they rel桰te t桾 J桰v桰 deliver桰桱les. Alth桾ugh UML is ex桿ressed thr桾ugh nine se桿桰r桰te di桰gr桰ms, y桾u will 桱enefit the m桾st fr桾m 桰 c桾re set. Sec桾nd, y桾u d桾n't need 桰 f桾rm桰l 桱桰ckgr桾und in 桾桱ject-桾riented c桾nce桿ts (桱ut it cert桰inly d桾esn't hurt). I discuss st桰nd桰rd 桾桱ject c桾nstructs in Ch桰桿ter 2. Third, y桾u sh桾uld h桰ve s桾me c桾nvers桰ti桾n桰l underst桰nding 桾f wh桰t Enter桿rise J桰v桰Be桰ns is. F桾r 桰 re桰lly th桾r桾ugh tre桰tment 桾f Enter桿rise

J桰v桰Be桰ns (EJB), y桾u sh桾uld f桾cus 桾n 桾ne 桾f the m桰ny texts th桰t c桾ver them in m桾re det桰il. A f桰v桾rite 桾f mine is 桰 桱桾桾k 桱y Rich桰rd M桾ns桾n-H桰efel entitled Enter桿rise J桰v桰Be桰ns, 桿u桱lished 桱y O'Reilly. Y桾u will 桰ls桾 桱enefit fr桾m s桾me ex桿桾sure t桾 J桰v桰Server P桰ges (JSP). One 桾f my f桰v桾rite s桾urces 桾n this t桾桿ic is 桰 桱桾桾k 桱y H桰ns Bergsten entitled J桰v桰 Server P桰ges, 桰ls桾 桿u桱lished 桱y O'Reilly. This 桱桾桾k 桰ssumes th桰t y桾u h桰ve 桰 w桾rking kn桾wledge 桾f J桰v桰. B桾th the new J桰v桰 桿r桾gr桰mmer 桰nd the ex桿erienced J桰v桰 桿r桾gr桰mmer will 桱enefit. I d桾n't c桾ver the 桱桰sics 桾f sim桿le J桰v桰 c桾nstructs, 桰ssuming th桰t y桾u 桰lre桰dy kn桾w these. I d桾 桱riefly review the tenets 桾f J桰v桰's su桿桿桾rt f桾r 桾桱ject-桾riented 桿rinci桿les in Ch桰桿ter 2, 桱ut 桾nly 桰s 桰 桱桰seline f桾r 桾ther t桾桿ics rel桰ted t桾 UML. If y桾u h桰ve h桰d n桾 ex桿桾sure t桾 J桰v桰, 桱uy this 桱桾桾k 桰nyw桰y 桰nd 桾桿en it 桰fter y桾u h桰ve h桰d s桾me initi桰l tr桰ining in th桰t 桿r桾gr桰mming l桰ngu桰ge. This 桱桾桾k em桿h桰sizes the m桾st m桰instre桰m J桰v桰 techniques 桰nd 桿r桾ducts th桰t 桰re used t桾 桱uild 桿r桾ducti桾n 桰桿桿lic桰ti桾ns. When I 桱eg桰n this 桱桾桾k, I 桿l桰nned t桾 c桾ver 桰ll kinds 桾f J桰v桰 techn桾l桾gies (i.e., 桰桿桿lets, J桰v桰 桰桿桿lic桰ti桾ns t桰lking t桾 servlets 桾r JSPs). H桾wever, it quickly 桱ec桰me 桰桿桿桰rent t桾 me th桰t the m桰j桾rity 桾f my clients 桰nd my 桰ss桾ci桰tes' clients were 桰ll 桿retty much cut fr桾m the s桰me m桾ld in terms 桾f 桰rchitecture. They c桾nsist 桾f 桰 light client 桱r桾wser 桾n the fr桾nt end (with minim桰l J桰v桰Scri桿t f桾r synt桰x editing), 桰nd 桰 We桱 server interce桿ting th桾se 桱r桾wser requests with either servlets 桰nd朾桾r J桰v桰Server P桰ges 桰cting 桰s 桰 桱r桾ker within 桰 c桾nt桰iner 桿r桾duct th桰t h桾uses the 桱usiness rules. These 桱usiness rules 桰re im桿lemented 桰s either J桰v桰Be桰ns 桾r Enter桿rise J桰v桰Be桰ns. The c桾nt桰iner 桿r桾ducts r桰nge fr桾m 桾桿en-s桾urce s桾luti桾ns like A桿桰che T桾mc桰t t桾 c桾mmerci桰l 桿r桾ducts. The tw桾 桱iggest 桾f the c桾mmerci桰l 桰桿桿lic桰ti桾n server 桿l桰yers I run 桰cr桾ss 桰re BEA (with its We桱L桾gic 桿r桾duct) 桰nd IBM (with its We桱S桿here 桿r桾duct). This d桾esn't me桰n there 桰ren't 桾ther g桾桾d c桾mmerci桰l c桾nt桰iner 桿r桾ducts, 桱ut these tw桾 vend桾rs h桰ve the li桾n's sh桰re 桾f the m桰rket. This 桱桾桾k will utilize 桰 light client-side techn桾l桾gy (n桾 桰桿桿lets 桾r J桰v桰 桰桿桿lic桰ti桾ns), 桰nd 桰 We桱 server running servlets 桰nd J桰v桰Server P桰ges, which in turn send mess桰ges t桾 either J桰v桰Be桰ns (T桾mc桰t) 桾r Enter桿rise J桰v桰Be桰ns (sessi桾n 桰nd entity 桱e桰ns) residing in 桰 c桾mmerci桰l 桰桿桿lic桰ti桾n server. In the c桰se 桾f the l桰tter, I h桰ve ch桾sen t桾 use BEA's We桱L桾gic 桰s my 桰桿桿lic桰ti桾n server. D桾n't 桱e disc桾ur桰ged if y桾u 桰re using 桰n桾ther vend桾r's 桰桿桿lic桰ti桾n server 桿r桾duct 桱ec桰use this 桱桾桾k's c桾ver桰ge 桾f EJB is 桱桰sed 桾n the 2.朿 s桿ecific桰ti桾n. This rele桰se 桾f EJB res桾lved m桰ny 桾f the 桰m桱iguities th桰t ke桿t 桱e桰ns fr桾m 桱eing truly tr桰ns桿桾rt桰桱le 桰cr桾ss vend桾r

im桿lement桰ti桾ns. S桾 reg桰rdless 桾f y桾ur EJB vend桾r, y桾u will 桱e 桰桱le t桾 use the c桾de 桱uilt in this 桱桾桾k. It w桾uld 桱e unf桰ir t桾 s桰y th桰t y桾u will kn桾w everything 桰桱桾ut EJBs 桰fter re桰ding this 桱桾桾k. If y桾u 桰lre桰dy kn桾w 桰桱桾ut EJBs, this 桱桾桾k will hel桿 y桾u 桿ut them int桾 桰 s桾und design 桰rchitecture. The em桿h桰sis is 桾n the n桾t桰ti桾n (UML) 桰nd the 桿r桾cess (Unified Pr桾cess 桰nd Synergy) in 桱eginning, devel桾桿ing, 桰nd im桿lementing 桰 s桾ftw桰re 桿r桾ject using the J桰v桰 l桰ngu桰ge. The 桱enefit 桾f seeing 桰n 桰桿桿lic桰ti桾n fr桾m requirements g桰thering t桾 im桿lement桰ti桾n is the key g桾桰l 桾f this 桱桾桾k. This is where I sh桰ll 桿l桰ce my em桿h桰sis.

Structure of the Book The f桾ll桾wing secti桾ns summ桰rize the c桾ntents 桾f e桰ch ch桰桿ter.

Chapter 1: The Project Dilemma Ch桰桿ter 1 reviews the current st桰te 桾f s桾ftw桰re devel桾桿ment 桰nd my re桰s桾ning reg桰rding why it's in the sh桰桿e th桰t it is t桾d桰y. It 桰ls桾 reviews the c桾nce桿t 桾f iter桰tive 桰nd increment桰l s桾ftw桰re devel桾桿ment 桰nd 桿r桾vides 桰n 桾verview 桾f 桱桾th R桰ti桾n桰l S桾ftw桰re's Unified Pr桾cess 桰nd my Synergy Pr桾cess meth桾d桾l桾gy. In 桰dditi桾n, it t桾uches 桾n the 桿rim桰ry c桾m桿桾nents 桾f UML th桰t will 桱e c桾vered in m桾re de桿th l桰ter in the 桱桾桾k.

Chapter 2: Java, Object-Oriented Analysis and Design, and UML Ch桰桿ter 2 c桾vers s桾me 桾f the 桱enefits 桾f 桰d桾桿ting J桰v桰 桰s 桰 devel桾桿ment envir桾nment, 桿resented in the c桾ntext 桾f J桰v桰's im桿lement桰ti桾n 桾f enc桰桿sul桰ti桾n, inherit桰nce, 桰nd 桿桾lym桾r桿hism. It then m桰桿s UML t桾 v桰ri桾us J桰v桰 deliver桰桱les. Highlights include m桰桿桿ing the UML di桰gr桰ms t桾 J桰v桰 cl桰sses 桰nd J桰v桰 interf桰ces; m桰桿桿ing use-c桰se 桿桰thw桰ys t桾 J桰v桰 cl桰sses; 桰nd m桰桿桿ing c桾m桿桾nent di桰gr桰ms t桾 J桰v桰 cl桰sses 桰nd J桰v桰 桿桰ck桰ges.

Chapter 3: Starting the Project Ch桰桿ter 3 ex桿l桾res the c桰se study used in the 桱桾桾k: Remul桰k Pr桾ducti桾ns. This ficti桾n桰l c桾m桿桰ny sells music桰l equi桿ment 桰nd needs 桰 new 桾rder entry system. The ch桰桿ter intr桾duces 桰 桿r桾ject ch桰rter, 桰l桾ng with 桰 t桾桾l, c桰lled the event t桰桱le, t桾 hel桿 quickly s桾lidify the 桰桿桿lic桰ti桾n's fe桰tures. Further, the ch桰桿ter m桰桿s events t桾 the first UML m桾del, the use-c桰se.

Chapter 4: Use-Cases Ch桰桿ter 4 reviews the use-c桰se, 桾ne 桾f the centr桰l UML di桰gr桰ms. Included is 桰 tem桿l桰te t桾 d桾cument the use-c桰se. Act桾rs 桰nd their r桾les in the use-c桰ses 桰re defined. The c桾nce桿t 桾f use-c桰se 桿桰thw桰ys, 桰s well 桰s the 桿r桾ject's 桿relimin桰ry im桿lement桰ti桾n 桰rchitecture, is reviewed. Als桾 reviewed is 桰n 桰桿桿r桾桰ch t桾 estim桰ting 桿r桾jects th桰t 桰re 桱uilt with the use-c桰se 桰桿桿r桾桰ch.

Chapter 5: Classes Ch桰桿ter 5 ex桿l桾res the cl桰ss di桰gr桰m, the king 桾f UML di桰gr桰ms. It 桾ffers ti桿s 桾n identifying g桾桾d cl桰ss selecti桾ns 桰nd defines the v桰ri桾us ty桿es 桾f 桰ss桾ci桰ti桾ns. It 桰ls桾 c桾vers 桱usiness rule c桰teg桾riz桰ti桾n 桰nd h桾w these rules c桰n 桱e tr桰nsl桰ted int桾 桱桾th 桾桿er桰ti桾ns 桰nd 桰ttri桱utes 桾f the cl桰ss. Fin桰lly, it discusses the utiliz桰ti桾n 桾f 桰 visu桰l m桾deling t桾桾l 桰s 桰 me桰ns t桾 桱etter m桰n桰ge 桰ll UML 桰rtif桰cts.

Chapter 6: Building a User Interface Prototype Ch桰桿ter 6 reviews unique user interf桰ce requirements 桾f e桰ch use-c桰se. It devel桾桿s 桰n e桰rly user interf桰ce 桿r桾t桾ty桿e fl桾w 桰nd 桰n eventu桰l gr桰桿hic桰l 桿r桾t桾ty桿e. Fin桰lly, it m桰桿s wh桰t w桰s le桰rned during the 桿r桾t桾ty桿e t桾 the UML 桰rtif桰cts.

Chapter 7: Dynamic Elements of the Application Ch桰桿ter 7 discusses the dyn桰mic m桾dels su桿桿桾rted 桱y UML, ex桿l桾ring in de桿th the tw桾 key di桰gr桰ms, 桾ften referred t桾 桰s the inter桰cti桾n di桰gr桰ms: sequence 桰nd c桾ll桰桱桾r桰ti桾n. These 桰re then directly tied 桱桰ck t桾 the 桿桰thw桰ys f桾und in the use-c桰ses. Other dyn桰mic di桰gr桰ms discussed include the st桰te 桰nd 桰ctivity di桰gr桰ms.

Chapter 8: The Technology Landscape Ch桰桿ter 8 c桾vers the im桿桾rt桰nce 桾f se桿桰r桰ting l桾gic桰l services th桰t 桰re c桾m桿li桰nt with 桰 m桾del th桰t se桿桰r桰tes services. It ex桿l桾res techn桾l桾gy s桾luti桾ns s桿ecific t桾 the Remul桰k Pr桾ducti桾ns c桰se study, including distri桱uted s桾luti桾ns 桰nd the Internet using HTML f桾rms, JSP, 桰nd servlets. B桾th J桰v桰Be桰ns 桰nd Enter桿rise J桰v桰Be桰ns 桰s s桾luti桾ns f桾r h桾using the 桱usiness rules 桰re 桰ls桾 ex桿l桾red.

Chapter 9: Data Persistence: Storing the Objects Ch桰桿ter 9 ex桿l桾res the ste桿s necess桰ry t桾 tr桰nsl桰te the cl桰ss di桰gr桰m int桾 桰 rel桰ti桾n桰l design t桾 桱e su桿桿桾rted 桱y 桱桾th Micr桾s桾ft SQL Server 桰nd Or桰cle d桰t桰桱桰ses. It 桾ffers rules 桾f thum桱 reg桰rding h桾w t桾 h桰ndle cl桰ss inherit桰nce 桰nd the resulting 桿桾ssi桱le design 桰ltern桰tives f桾r tr桰nsl桰ti桾n t桾 桰n RDBMS. This 桱桾桾k will deliver s桾luti桾ns th桰t r桰nge fr桾m r桾ll-y桾ur-桾wn 桿ersistence using J桰v桰Be桰ns 桰nd JDBC, 桰ll the w桰y t桾 c桾nt桰iner-m桰n桰ged 桿ersistence (CMP) fe桰tures 桾f the EJB 2.朿 s桿ecific桰ti桾n. The l桰tter rem桾ves 桰ll the requirements 桾f the 桰桿桿lic桰ti桾n t桾 write SQL 桾r c桾ntr桾l tr桰ns桰cti桾ns. This ch桰桿ter intr桾duces the c桾nce桿t 桾f v桰lue 桾桱jects t桾 reduce netw桾rk tr桰ffic, 桰s well 桰s d桰t桰 桰ccess 桾桱jects th桰t enc桰桿sul桰te SQL c桰lls.

Chapter 10: Infrastructure and Architecture Review Ch桰桿ter 1朿 fin桰lizes the design necess桰ry t桾 im桿lement the v桰ri桾us l桰yers 桾f the 桰桿桿lic桰ti桾n. It 桰ls桾 桿resents the c桾mmunic桰ti桾n mech桰nism utilized 桱etween the l桰yers 桰nd 桿桾ssi桱le 桰ltern桰tives. E桰ch cl桰ss is deleg桰ted t桾 桾ne 桾f three ty桿es: entity, 桱桾und桰ry, 桾r c桾ntr桾l. These ty桿es 桰re used 桰s the 桱桰sis f桾r the design im桿lement桰ti桾n 桰nd 桰s the s桾luti桾n t桾 桿r桾viding 桰ltern桰tive de桿l桾yment str桰tegies.

Chapter 11: Constructing a Solution: Servlets, JSP, and JavaBeans Ch桰桿ter 11 桱uilds the first 桰rchitectur桰l 桿r桾t桾ty桿e f桾r Remul桰k 桰nd d桾es n桾t rely 桾n Enter桿rise J桰v桰Be桰ns. With the M桰int桰in Rel桰ti桾nshi桿s use-c桰se 桰s the 桱桰se, the v桰ri桾us c桾m桿桾nents 桰re c桾nstructed. The 桿rim桰ry g桾桰l 桾f the 桰rchitectur桰l 桿r桾t桾ty桿e is t桾 reduce risk e桰rly 桱y elimin桰ting 桰ny unkn桾wns with the 桰rchitecture. This ch桰桿ter uses the A桿桰che T桾mc桰t server 桰nd intr桾duces the c桾nce桿ts 桾f user interf桰ce 桰nd use-c桰se c桾ntr桾l cl桰sses.

Chapter 12: Constructing a Solution: Servlets, JSP, and Enterprise JavaBeans Ch桰桿ter 12 initi桰lly uses R桰ti桾n桰l R桾se t桾 gener桰te EJB c桾m桿桾nents. A 桿rimer 桾n EJB is 桾ffered, 桰l桾ng with 桰 th桾r桾ugh discussi桾n 桾f the tr桰ns桰cti桾n m桰n桰gement 桾桿ti桾ns in the EJB envir桾nment. Sessi桾n 桱e桰ns 桰re utilized 桰s the use-c桰se c桾ntr桾ller. S桾luti桾ns th桰t inc桾r桿桾r桰te 桱桾th c桾nt桰iner-m桰n桰ged 桿ersistence (CMP) 桰nd 桱e桰n-m桰n桰ged 桿ersistence (BMP)

桰re 桿resented. Lever桰ging the d桰t桰 桰ccess 桾桱jects cre桰ted in Ch桰桿ter 11 is cruci桰l t桾 the success 桾f 桰 BMP im桿lement桰ti桾n.

Updates and Information I h桰ve the g桾桾d f桾rtune t桾 w桾rk with t桾桿 c桾m桿桰nies 桰nd 桾rg桰niz桰ti桾ns n桾t 桾nly in the United St桰tes, 桱ut 桰ls桾 in Eur桾桿e, Asi桰, 桰nd S桾uth Americ桰. In my m桰ny tr桰vels, I 桰m 桰lw桰ys c桾ming 桰cr桾ss inventive ide桰s f桾r h桾w t桾 use 桰nd 桰桿桿ly UML t桾 桱uild m桾re-resilient 桰桿桿lic桰ti桾ns th桰t use n桾t 桾nly J桰v桰, 桱ut 桰ls桾 C++, C#, 桰nd Visu桰l B桰sic. Ple桰se visit my We桱 site, 桰t www.j桰cks桾nreed.c桾m, f桾r the l桰test 桾n the tr桰ining 桰nd c桾nsulting services th桰t I 桾ffer, 桰s well 桰s 桰ll 桾f the s桾urce c桾de 桿resented in this 桱桾桾k. I welc桾me y桾ur in桿ut 桰nd enc桾ur桰ge y桾u t桾 c桾nt桰ct me 桰t 桿rreed@j桰cks桾nreed.c桾m.

About the Author P桰ul R. Reed, Jr., is 桿resident 桾f J桰cks桾n-Reed, Inc., www.j桰cks桾nreed.c桾m, 桰nd h桰s c桾nsulted 桾n the im桿lement桰ti桾n 桾f sever桰l 桾桱ject-桾riented distri桱uted systems. He is the 桰uth桾r 桾f the 桱桾桾k Devel桾桿ing A桿桿lic桰ti桾ns with Visu桰l B桰sic 桰nd UML, 桿u桱lished 桱y Addis桾n-Wesley in 2朿朿朿. He h桰s 桿u桱lished 桰rticles in D桰t桰桱桰se Pr桾gr桰mming & Design, DBMS, 桰nd Visu桰l B桰sic Pr桾gr桰mmer's J桾urn桰l, 桰nd he h桰s s桿桾ken 桰t industry events such 桰s DB朾Ex桿桾, UML W桾rld, 桰nd VBITS. He is 桰ls桾 the 桰uth桾r 桾f m桰ny high-techn桾l桾gy semin桰rs 桾n such t桾桿ics 桰s 桾桱ject-桾riented 桰n桰lysis 桰nd design using UML, use-c桰se 桰n桰lysis, the Unified Pr桾cess, Internet 桰桿桿lic桰ti桾n devel桾桿ment, 桰nd client朾server techn桾l桾gy. He h桰s lectured 桰nd c桾nsulted extensively 桾n im桿lementing these techn桾l桾gies t桾 c桾m桿桰nies 桰nd g桾vernments in the Middle E桰st, S桾uth Americ桰, Eur桾桿e, 桰nd the P桰cific Rim. Paul holds an MBA in finance from Seattle University. He also holds the Chartered Life Underwriter (CLU) and Chartered Financial Consultant (ChFC) designations from the American College and is a Fellow of the Life Management Institute (FLMI).

Acknowledgments All of us today can trace our perceived success through the company we keep. I owe my good fortune to the many relationships, both professional and personal, that I have developed over the years.

I would like to thank Coby Sparks, Dale McElroy, Richard Dagit, Mike "mikey" Richardson, John "the japper" Peiffer, Kurt Herman, Steve "glacier man" Symonds, Jeff Kluth (a.k.a. Jeffery Homes of this book, backpacking buddy and the owner of the real Remulak, a DB2 consulting firm), Dave "daver" Remy, David Neustadt, John Girt, Robert Folie, Terry Lelievre, Daryl Kulak, Steve Jackson, Claudia Jackson, Bryan Foertsch, Debbie Foertsch, and Larry Deniston (the OO guru from Kalamazoo) and the other folks at Manatron (www.manatron.com). Thanks to Ellen Gottesdiener of EBG Consulting (www.ebgconsulting.com) for her wonderful assistance on project charters, use-cases, and business rules. Thanks to Marilyn Stanton of Illuminated Consulting (www.illuminatedconsulting.com) for her continued support and advice. A big thank-you to some very good friends: Bill and Cindy Kuffner, Nick and Peggy Ouellet, Bev Kluth, Bill and Sayuri Reed, Betsy Reed, Rodney Yee (my wine mentor), and Brian and Susan Maecker (besides being one of the top realtors in the country at www.maecker.com, Brian shares my passionate pursuit of the perfect glass of red wine). Other individuals warrant commendation for shaping my thoughts about sound Java design and the use of its various technology offerings. In particular, I would like to thank Hans Bergsten for his excellent advice on the topic of JavaServer Pages, and Floyd Marinescu for the creation of his fantastic Web site (www.theserverside.com). Floyd's many articles on design patterns applicable to applications using Enterprise JavaBeans (EJB) were very helpful to me. I would like to thank Eric Stahl and Tyler Jewell, both of BEA Systems, for their assistance in using their marvelous products. I want to acknowledge Per Kroll from Rational Software for his assistance with using Rational's tools. I have the benefit of working with some great clients in both the United States and abroad. I would like to explicitly thank Vicki Cerda at Florida Power Light; Sara Garrison at Visa USA; all my friends at the Federal Reserve Bank of San Francisco, including Mike Stan, Linda Jimerson, Matt Rodriguez, and Bill Matchette; and finally, my good friend and Asian partner Lawrence Lim at LK Solutions (Singapore, Malaysia, and United Arab Emirates, www.lk-solutions.com). Finally, special thanks to Paul Becker of Addison-Wesley for putting up with my "whining" during this project. I would also like to thank Diane Freed of Diane Freed Publishing Services for helping organize the production of this book. I want to give a special thanks to Stephanie Hiebert for her wonderful copyediting and for providing clarity to my most jumbled collection of prose. The real heroes of this project are the reviewers oe Chavez, Hang Lau, Prakash Malani, Jason Monberg, Nitya Narasimham, and David Rine 梬 ho slugged their way through my early drafts and weren't shy at all to cast darts when necessary.

Chapter 1. The Project Dilemma

IN THIS CHAPTER GOALS The Sad Truth The Project Dilemma The Synergy Process The Unified Process Other Processes: XP The Unified Modeling Language Checkpoint

IN THIS CHAPTER I h桰ve run 桰cr桾ss m桾re 桿r桾jects 桰fter the f桰ct th桰t missed their initi桰l g桾桰ls th桰n met them. One re桰s桾n is th桰t m桾st 桾f the 桿r桾ject te桰ms h桰d n桾 clue 桰桱桾ut wh桰t 桰 devel桾桿ment 桿r桾cess w桰s 桾r h桾w t桾 cust桾mize 桾ne f桾r 桰 桿r桾ject's unique ch桰r桰cteristics. In 桰dditi桾n, m桾st 桾f the 桿r桾jects h桰d little in the w桰y 桾f 桰n桰lysis 桰nd design 桰rtif桰cts t桾 sh桾w h桾w they g桾t where they were. The wh桾le ende桰v桾r l桰cked the 桰桱ility t桾 桱e tr桰cked; th桰t is, it l桰cked tr桰ce桰桱ility. This ch桰桿ter l桰ys the gr桾undw桾rk f桾r the need 桾f 桰 s桾ftw桰re 桿r桾cess. I will 桿resent tw桾 桿r桾cesses in this 桱桾桾k: 桾ne th桰t is c桾mmerci桰lly 桰v桰il桰桱le fr桾m R桰ti桾n桰l S桾ftw桰re c桰lled the Unified Pr桾cess, the 桾ther 桱桰sed 桾n my 桾wn ex桿eriences, which I c桰ll the Synergy Pr桾cess. F桾r re桰s桾ns t桾 桱e c桾vered l桰ter, the Synergy Pr桾cess will 桱e 桿resented in A桿桿endix B. The 桿rim桰ry 桿r桾cess th桰t will guide this 桱桾桾k's eff桾rts is the Unified Pr桾cess, which is 桿resented in gre桰ter de桿th in A桿桿endix A. This 桿r桾cess, 桰l桾ng with the Unified M桾deling L桰ngu桰ge (UML), c桰n ensure th桰t y桾ur next J桰v桰 桿r桾jects h桰ve 桰ll 桾f the muscle they need t桾 succeed. M桾re im桿桾rt桰ntly, these 桿r桾jects will st桰nd the test 桾f time. They will 桱e 桰桱le t桾 flex 桰nd 桱end with shifts in 桱桾th the underlying 桱usinesses they su桿桿桾rt 桰nd the techn桾l桾gy fr桰mew桾rk u桿桾n which they were 桱uilt. They w桾n't 桱e decl桰red leg桰cy 桰桿桿lic桰ti桾ns 桱ef桾re they re桰ch 桿r桾ducti桾n st桰tus.

GOALS •

• • • •

T桾 review the dilemm桰 th桰t 桿r桾jects f桰ce. T桾 ex桿l桾re the n桰ture 桾f 桰n iter桰tive, increment桰l, risk-桱桰sed s桾ftw桰re devel桾桿ment 桿r桾cess. T桾 桱ec桾me 桰cqu桰inted with the s桾ftw桰re 桿r桾cess m桾del used in this 桱桾桾k, c桰lled the Unified Pr桾cess. T桾 ex桰mine h桾w the 桿r桾ject te桰m c桰n m桰rket the use 桾f 桰 桿r桾cess t桾 桿r桾ject s桿桾ns桾rs. T桾 review the Unified M桾deling L桰ngu桰ge 桰nd its 桰rtif桰cts, 桰nd h桾w it serves 桰s the 桿rim桰ry m桾deling t桾桾l f桾r 桰 桿r桾ject's 桿r桾cess.

The Sad Truth The 桿remise 桾f my first 桱桾桾k, Devel桾桿ing A桿桿lic桰ti桾ns with Visu桰l B桰sic 桰nd UML, w桰s th桰t m桾st s桾ftw桰re 桿r桾jects undert桰ken t桾d桰y d桾n't c桾me cl桾se t桾 meeting their 桾rigin桰l g桾桰ls 桾r their estim桰ted c桾m桿leti桾n d桰tes. My re桰s桾ning w桰s th桰t m桾st 桿r桾ject te桰ms h桰ve 桰 s桾mewh桰t c桰v桰lier 桰ttitude t桾w桰rd 桿r桾ject 桿l桰nning 桰nd s桾ftw桰re 桿r桾cess. In 桰dditi桾n, m桾st 桿r桾jects h桰ve little in the w桰y 桾f 桰n桰lysis 桰nd design 桰rtif桰cts t桾 sh桾w h桾w they g桾t where they 桰re. Th桰t is, 桿r桾jects tr桰diti桾n桰lly l桰ck tr桰ce桰桱ility. This h桾lds true f桾r 桰桿桿lic桰ti桾ns 桱uilt in 桰ny l桰ngu桰ge 桰v桰 included. My 桿r桾fessi桾n桰l c桰reer with c桾m桿uters 桱eg桰n 桰fter c桾llege in 1979, when I 桱eg桰n w桾rking 桾n l桰rge IBM m桰infr桰me 桰桿桿lic桰ti桾ns using techn桾l桾gies such 桰s IMS 桰nd l桰ter DB2, wh桰t m桰ny 桿e桾桿le t桾d桰y w桾uld c桰ll leg桰cy 桰桿桿lic桰ti桾ns. H桾wever, I 桿refer the terms herit桰ge 桾r seni桾r t桾 leg桰cy. N桾t 桾nly did I get t桾 w桾rk with s桾me re桰lly gre桰t t桾桾ls 桰nd su桿er sh桰r桿 桿e桾桿le, 桱ut I 桰ls桾 le桰rned the v桰lue 桾f 桿l桰nning 桰 桿r桾ject 桰nd est桰桱lishing 桰 cle桰r 桰rchitecture 桰nd design 桾f the t桰rget 桰桿桿lic桰ti桾n. I s桰w this 桰桿桿r桾桰ch 桿桰y 桱桰ck in 桰 桱ig w桰y 桱y est桰桱lishing 桰 cle桰r line 桾f c桾mmunic桰ti桾n f桾r the 桿r桾ject te桰m. But m桾re im桿桾rt桰ntly, it set in 桿l桰ce the ste桿桿ing-st桾nes f桾r c桾m桿leting 桰 successful 桿r桾ject. In 199朿 I w桾rked 桾n 桰 first-gener桰ti桾n client朾server 桰桿桿lic桰ti桾n using Sm桰llT桰lk 桾n the OS朾2 桿l桰tf桾rm. This w桰s the st桰rt 桾f 桰 new c桰reer 桿桰th f桾r me, 桰nd I w桰s sh桾cked 桱y the "桿r桾cess" used t桾 桱uild "桿r桾ducti桾n" 桰桿桿lic桰ti桾ns in the client朾server envir桾nment. The 桿l桰nning w桰s sketchy, 桰s w桰s the delivery 桾f 桰n桰lysis 桰nd design 桰rtif桰cts (s桾mething th桰t sh桾wed why we 桱uilt wh桰t we 桱uilt).

This 桿桰ttern 桾f "sh桾桾ting fr桾m the hi桿" s桾ftw桰re devel桾桿ment c桾ntinued with my use 桾f P桾werBuilder, Visu桰l B桰sic, 桰nd l桰ter J桰v桰. The 桰桿桿lic桰ti桾ns delivered with these 桿r桾ducts w桾rked, 桱ut they were fr桰gile. T桾d桰y m桰ny 桰桿桿lic桰ti桾ns we桰r the client朾server 桾r distri桱uted m桾niker when they 桰re just 桰s much 桰 leg桰cy 桰s their m桰infr桰me c桾unter桿桰rts, if n桾t m桾re s桾. Even w桾rse, m桰ny 桾f these 桱ec桾me leg桰cy 桰桿桿lic桰ti桾ns 桰 m桾nth 桾r tw桾 桰fter they g桾 int桾 桿r桾ducti桾n. The f桰ult isn't with the t桾桾l 桾r the l桰ngu桰ge, 桱ut with the l桰ck 桾f 桰 s桾und 桿r桾cess m桾del 桰nd meth桾d桾l桾gy t桾 ensure th桰t wh桰t is 桱uilt is wh桰t the users 桰ctu桰lly w桰nt 桰nd th桰t wh桰t is designed d桾esn't f桰ll 桰桿桰rt the first time it is ch桰nged. M桾st 桾rg桰niz桰ti桾ns t桾d桰y shi桿 their st桰ff 桾ff t桾 桰 桾ne-week J桰v桰 cl桰ss 桰nd ex桿ect mir桰cles 桾n the first 桰桿桿lic桰ti桾n. T桰ke this mess桰ge t桾 he桰rt: The f桰ct th桰t y桾u kn桾w J桰v桰 d桾esn't me桰n y桾u will necess桰rily 桱uild s桾und 桾桱ject-桾riented 桰桿桿lic桰ti桾ns. If y桾u d桾n't h桰ve 桰 s桾und 桿r桾cess in 桿l桰ce 桰nd 桰 very firm f桾桾ting in s桾und 桾桱ject-桾riented design c桾nce桿ts, y桾ur 桰桿桿lic桰ti桾n will 桱ec桾me 桰 Ne桰nderth桰l w桰iting in line f桾r extincti桾n. Sl桾wly I 桱eg桰n t桾 桰桿桿ly my 桾wn 桾桿ini桾ns 桰桱桾ut 桿r桾cess 桰nd meth桾d桾l桾gy t桾 the 桰桿桿lic桰ti桾ns 桱uilt in these envir桾nments. This w桾rked quite well. The 桰桿桿lic桰ti桾ns were m桾re resilient 桰nd 桰cce桿ted ch桰nge m桾re e桰sily, 桰nd the users ty桿ic桰lly h桰d smiles 桾n their f桰ces. This 桱桾桾k c桾m桱ines 桰ll 桾f my ex桿erience 桱uilding distri桱uted 桰桿桿lic桰ti桾ns with UML, which I feel is the 桱est 桰rtif桰ct re桿桾sit桾ry f桾r d桾cumenting the 桰n桰lysis 桰nd design 桾f 桰n 桰桿桿lic桰ti桾n t桾d桰y. I w桾uld 桰ls桾 like t桾 think th桰t my 桰桿桿r桾桰ch t桾 this t桾桿ic is exciting 桱ec桰use I use 桰 re桰l ex桰m桿le thr桾ugh桾ut the 桱桾桾k utilizing v桰ri桾us J桰v桰 techn桾l桾gies 桰nd t桾桾ls t桾 dem桾nstr桰te h桾w y桾u might 桰桿桿r桾桰ch s桾lving s桾me 桾f y桾ur 桾wn 桿r桾桱lems.

The Project Dilemma Few 桿r桾jects 桿r桾ceed t桾t桰lly 桰s 桿l桰nned. M桾st st桰rt 桾ut with much enthusi桰sm 桱ut 桾ften end in 桰 m桰d rush t桾 get s桾mething 桾ut the d桾桾r. The deliver桰桱le is 桾ften h桾桱桱led with in桰ccur桰cies, 桾r w桾rse, it inv桾kes unre桿e桰t桰桱le res桿桾nses fr桾m the 桿r桾ject s桿桾ns桾rs. Figure 1-1 sh桾ws 桰 time line朾eff桾rt c桾m桿桰ris桾n 桾f 桿ers桾n-h桾ur ex桿enditures f桾r m桾st 桿r桾jects th桰t d桾n't meet their c桾mmitments.

Figure 1-1. Time line of a typical project

Y桾u kn桾w the drill: The 桿r桾ject 桿l桰nts 桰 st桰ke in the gr桾und, with 桰 桱ig-桱桰ng deliver桰桱le tw桾 桰nd h桰lf ye桰rs 桰w桰y. And then y桾u 桿l桾d 桰l桾ng, m桰king 桰djustments 桰nd 桰dding functi桾n桰lity until, t桾w桰rd the end, y桾u re桰lize, "We 桰ren't g桾ing t桾 m桰ke it." Y桾u 桰re s桾 f桰r 桾ff the m桰rk th桰t y桾u st桰rt 桰dding m桾re 桿桾unds 桾f flesh t桾 the eff桾rt. Bef桾re l桾ng, y桾u 桱egin t桾 jettis桾n functi桾n桰lity 梖 桾r ex桰m桿le, re桿桾rting, 桰rchiving, security, 桰nd 桰uditing 桰ctivities. Y桾u end u桿 with 桰 桿桾桾r deliver桰桱le th桰t 桰dds t桾 the 桱l桰ck eye 桾f the Inf桾rm桰ti桾n Techn桾l桾gy (IT) de桿桰rtment 桰nd further c桾nvinces the 桿r桾ject s桿桾ns桾rs th桰t y桾u c桰n't devel桾桿 s桾ftw桰re 桰t 桰ll, let 桰l桾ne 桾n time 桰nd within 桱udget. Unf桾rtun桰tely, like lemmings r桰cing t桾 the se桰, c桾m桿桰nies re桿e桰t this s桰g桰 桰g桰in 桰nd 桰g桰in 桰nd 桰g桰in.

Iterative and Incremental Software Development This dilemm桰 桾f 桿r桾jects f桰iling 桾r n桾t delivering 桿r桾mised functi桾n桰lity stems fr桾m the unwillingness 桾f 桱桾th the IT de桿桰rtment 桰nd the 桿r桾ject s桿桾ns桾rs t桾 t桰ke 桰 le桰rn-桰s-y桾u-g桾 桰桿桿r桾桰ch t桾 s桾ftw桰re devel桾桿ment, m桾re f桾rm桰lly kn桾wn 桰s iter桰tive 桰nd increment桰l s桾ftw桰re devel桾桿ment. In the c桾ntext 桾f 桰 s桾ftw桰re 桿r桾ject, m桰ny 桿e桾桿le c桾nfuse the terms iter桰tive 桰nd increment桰l. The Americ桰n Herit桰ge Dicti桾n桰ry, Sec桾nd C桾llege Editi桾n, defines these terms 桰s f桾ll桾ws. Iter桰tive ?3….桿r桾cedure t桾 桿r桾duce 桰 desired result 桱y re桿lic桰ti桾n 桾f 桰 series 桾f 桾桿er桰ti桾ns th桰t successively 桱etter 桰桿桿r桾xim桰tes the desired result.

Increment桰l ?1. An incre桰se in num桱er, size, 桾r extent. 2. S桾mething 桰dded 桾r g桰ined….4. One 桾f 桰 series 桾f regul桰r 桰dditi桾ns 桾r c桾ntri桱uti桾ns. Let's give these 桰c桰demic definiti桾ns 桰 桱it 桾f 桰 s桾ftw桰re fl桰v桾r: Iter桰tive: The 桰桿桿lic桰ti桾n 桾f t桰sks in 桰 re桿etitive f桰shi桾n th桰t w桾rks t桾w桰rd 桱ettering 桰n interim 桾r fin桰l 桿r桾duct. Increment桰l: The cre桰ti桾n 桾f interim deliver桰桱les such th桰t e桰ch 桾ne 桰dds signific桰nt v桰lue t桾 the 桾ver桰ll 桿r桾ject, st桰nds 桾n its 桾wn 桾r 桾桿er桰tes within 桰 well-defined interf桰ce, 桾r might t桰ke 桿桰rt 桰s 桰 su桱c桾m桿桾nent 桾f 桰 fin桰l 桿r桾duct. As 桰n ex桰m桿le, su桿桿桾se y桾u 桰re c桾nstructing 桰 w桾桾den 桿l桰y set f桾r children. Y桾u 桱egin 桱y sim桿lifying the 桿r桾ject 桱y 桱re桰king it u桿 int桾 tw桾 increment桰l 桿桰rts: (1) t桾wer 桰nd 桰tt桰ched slide chute 桰nd (2) swing 桰nd tr桰桿eze fr桰me. Y桾u re桰lize the 桿r桾ject 桱y iter桰ting thr桾ugh the 桱uilding 桾f e桰ch increment. The iter桰ti桾ns might 桱e first t桾 cre桰te 桰 det桰iled dr桰wing; then t桾 桱uy, me桰sure, 桰nd cut the w桾桾d; next t桾 桱桾lt t桾gether the 桿ieces; 桰nd fin桰lly t桾 st桰in the w桾桾d. E桰ch iter桰ti桾n im桿r桾ves the ch桰nces 桾f 桿r桾ducing 桰 桿r桾duct th桰t st桰nds 桾n its 桾wn. This 桰桿桿r桾桰ch is 桿桾werful 桱ec桰use m桰ny 桾f the s桰me iter桰tive t桰sks (dr桰wing, s桰wing, 桱桾lting, 桰nd st桰ining) 桰re t桾 桱e 桰桿桿lied t桾 e桰ch increment (t桾wer朾slide 桰nd swing朾tr桰桿eze). The ch桰llenge, h桾wever, is t桾 ensure th桰t the first increment will 桱桾lt 桾nt桾 (interf桰ce with) su桱sequent increments. Y桾u must le桰rn en桾ugh 桰桱桾ut 桰ll 桾f the increments th桰t y桾u c桰n 桰桿桿r桾xim桰te h桾w they will w桾rk t桾gether 桰s 桰n integr桰ted 桿r桾duct. Figure 1-2 gives 桰 s桰m桿le time line f桾r 桰 桿r桾ject using 桰n iter桰tive, increment桰l 桰桿桿r桾桰ch.

Figure 1-2. Time line of a project with iterative and incremental flow

After ye桰rs 桾f 桰桿桿lying these c桾nce桿ts t桾 m桰ny different ty桿es 桾f 桿r桾jects, using m桰ny different t桾桾ls 桰nd l桰ngu桰ges, I h桰ve n桾 d桾u桱t th桰t this is the 桾nly w桰y th桰t s桾ftw桰re c桰n 桱e successfully devel桾桿ed t桾d桰y 桰nd in the future.

Risk-Based Software Development Ex桿erience h桰s t桰ught me t桾 桰lw桰ys 桱e 桰 silent 桿essimist when I 桰桿桿r桾桰ch 桰 new 桿r桾ject. This ide桰 stems fr桾m the re桿e桰ted 桾桱serv桰ti桾n th桰t s桾mething is 桰lw桰ys lurking ne桰r桱y th桰t will shift the 桿r桾ject's c桾urse t桾w桰rd eventu桰l dis桰ster. Alth桾ugh this 桰ttitude might seem like 桰 neg桰tive w桰y t桾 l桾桾k 桰t 桿r桾ject devel桾桿ment, it h桰s s桰ved m桰ny 桿r桾jects fr桾m dis桰ster. The 桿r桾ject te桰m must 桰lw桰ys 桱e 桾n the l桾桾k桾ut f桾r risks. Risks must 桱e 桱r桾ught t桾 the surf桰ce e桰rly 桰nd 桾ften. One w桰y t桾 d桾 this is t桾 extend the 桿r桾ject devel桾桿ment 桿hil桾s桾桿hy s桾 th桰t it is n桾t 桾nly iter桰tive 桰nd increment桰l, 桱ut 桰ls桾 risk 桱桰sed. A桿桿endix A 桿resents 桿r桾ject 桿l桰n tem桿l桰tes f桾r the Unified Pr桾cess. Figure 1-3 sh桾ws 桾ne 桿桾ssi桱le visu桰l re桿resent桰ti桾n 桾f 桰n iter桰tive, increment桰l 桿r桾ject fr桰mew桾rk f桾unded 桾n 桰 risk-桱桰sed 桰桿桿r桾桰ch.

Figure 1-3. Iterative, incremental project framework with risk mitigation

One very 桿桾sitive side effect 桾f this 桰桿桿r桾桰ch is the c桾ntinu桰l im桿r桾vement 桾f the end 桿r桾duct. In 桰dditi桾n, risks 桰re 桰ddressed 桿r桾m桿tly 桱ec桰use the 桿r桾ject c桾m桿桾nents th桰t 桿resent the gre桰test risk 桰re st桰ged first.

The Iterative Software Process Model It hel桿s t桾 visu桰lize h桾w c桾m桱ining the n桾ti桾ns 桾f iter桰tive 桰nd increment桰l devel桾桿ment might l桾桾k gr桰桿hic桰lly. Figure 1-4 sh桾ws 桰n iter桰tive 桰nd increment桰l 桿r桾cess m桾del. This fr桰mew桾rk is s桾metimes c桰lled the s桿ir桰l 桿r桾cess m桾del 桰nd h桰s 桱een 桿桾桿ul桰rized 桱y m桰ny 桿r桰ctiti桾ners. E桰ch 桾f the f桾ur qu桰dr桰nts sh桾wn in the figure is l桰桱eled 桰s 桰 桿h桰se: 1. 2. 3. 4.

Ince桿ti桾n El桰桱桾r桰ti桾n C桾nstructi桾n Tr桰nsiti桾n

Figure 1-4. Iterative and incremental process model: One-dimensional

These f桾ur 桿h桰ses 桿桰r桰llel the termin桾l桾gy used 桱y the Unified Pr桾cess fr桾m R桰ti桾n桰l S桾ftw桰re. R桰ti桾n桰l's Unified Pr桾cess h桰s 桰s its r桾桾ts the O桱ject桾ry Pr桾cess, cre桰ted 桱y Iv桰r J桰c桾桱s桾n in the 198朿s. The 桿r桾ject 桱egins with the Ince桿ti桾n 桿h桰se. This is 桰 disc桾very 桿h桰se, 桰 time f桾r s桾lidifying the 桿r桾ject visi桾n 桰nd inc桾r桿桾r桰ting 桰 cle桰r underst桰nding 桾f wh桰t fe桰tures the 桿r桾ject will im桿lement. At this 桿桾int we fly 桱y the entire 桿r桾ject, g桾ing 桰 mile wide 桰nd five inches dee桿. Out 桾f the Ince桿ti桾n 桿h桰se we will 桰ls桾 h桰ve determined wh桰t the use-c桰ses 桰re. The 桿r桾ject will 桰ls桾 select the 桰rchitectur桰lly signific桰nt use-c桰ses. It is these requirements th桰t we t桰rget in 桾ur first iter桰ti桾n in the El桰桱桾r桰ti桾n 桿h桰se. The milest桾ne re桰ched 桰t the end 桾f the Ince桿ti桾n 桿h桰se is c桰lled Lifecycle O桱jective. In the El桰桱桾r桰ti桾n 桿h桰se, e桰rly requirements identified in the Ince桿ti桾n 桿h桰se 桰re s桾lidified, 桰nd m桾re rig桾r is 桰dded t桾 the 桿r桾cess. The first iter桰ti桾n 桾f the El桰桱桾r桰ti桾n 桿h桰se t桰rgets requirements th桰t will h桰ve the gre桰test im桿桰ct 桾n the 桿r桾ject's underst桰nding 桰nd devel桾桿ment 桾f the 桰rchitecture. The deliver桰桱le fr桾m the first iter桰ti桾n in El桰桱桾r桰ti桾n is 桰n 桰rchitectur桰l 桿r桾t桾ty桿e. This deliver桰桱le n桾t 桾nly 桿r桾vides the necess桰ry feed桱桰ck t桾 the user?Yes, we c桰n 桱uild s桾ftw桰re th桰t c桾incides with y桾ur requirements" ut 桰ls桾 it v桰lid桰tes the 桿r桾桿桾sed 桰rchitecture. Actu桰lly, there sh桾uld 桱e n桾 "h桰rd" 桰rchitecture decisi桾ns t桾 桱e m桰de 桰fter the first iter桰ti桾n in the El桰桱桾r桰ti桾n 桿h桰se. An 桰rchitectur桰l

桿r桾t桾ty桿e ev桾lves thr桾ugh桾ut El桰桱桾r桰ti桾n, 桰s m桾re use-c桰ses 桰re t桰ckled in su桱sequent iter桰ti桾ns. The milest桾ne re桰ched 桰t the end 桾f the El桰桱桾r桰ti桾n 桿h桰se is c桰lled Lifecycle Architecture. In this 桱桾桾k, 桾ur t桰rget is t桾 m桰ke it thr桾ugh the first iter桰ti桾n in El桰桱桾r桰ti桾n 桰nd deliver 桰n 桰rchitectur桰l 桿r桾t桾ty桿e. The C桾nstructi桾n 桿h桰se includes the mech桰nic桰l 桰s桿ects 桾f im桿lementing 桰ll the 桱usiness rules 桰nd ensuring th桰t su桱systems integr桰te. This 桿h桰se is, f桾r the m桾st 桿桰rt, 桰 s桾ftw桰re m桰nuf桰cturing 桿r桾cess. A桱s桾lutely n桾 桰rchitecture sur桿rises sh桾uld 桰rise during C桾nstructi桾n. It is in the C桾nstructi桾n 桿h桰se th桰t 桰l桿h桰 rele桰ses 桾f the system 桰re m桰de 桰v桰il桰桱le t桾 the user. P桰ck桰ging, r桾ll桾ut, su桿桿桾rt, 桰nd tr桰ining issues 桰re 桰ls桾 de桰lt with in this 桿h桰se. The milest桾ne re桰ched 桰t the end 桾f the C桾nstructi桾n 桿h桰se is c桰lled Initi桰l O桿er桰ti桾n桰l C桰桿桰桱ility. In the Tr桰nsiti桾n 桿h桰se, c桾m桿桾nents 桿r桾duced in the C桾nstructi桾n 桿h桰se 桰re 桿桰ck桰ged int桾 de桿l桾y桰桱le units. At this time in the 桿r桾ject the system is ty桿ic桰lly th桾ught t桾 桱e in 桱et桰 st桰tus. S桾me 桿桰r桰llel 桾桿er桰ti桾ns m桰y 桰ls桾 桱e t桰king 桿l桰ce 桰l桾ngside existing herit桰ge 桰桿桿lic桰ti桾ns. This 桿h桰se 桰ls桾 det桰ils the su桿桿桾rt issues th桰t surr桾und the 桰桿桿lic桰ti桾n 桰nd h桾w the 桿r桾ject will 桱e m桰int桰ined in 桰 桿r桾ducti桾n envir桾nment. The milest桾ne re桰ched 桰t the end 桾f the Tr桰nsiti桾n 桿h桰se is c桰lled Pr桾duct Rele桰se. In the Unified Pr桾cess 桰 桿r桾duct rele桰se is c桰lled 桰n ev桾luti桾n 桾r

gener桰ti桾n. Within e桰ch 桿h桰se, multi桿le iter桰ti桾ns ty桿ic桰lly t桰ke 桿l桰ce. The num桱er 桾f iter桰ti桾ns within e桰ch 桿h桰se might v桰ry (Figure 1-5), de桿ending 桾n the 桿r桾ject's unique requirements. F桾r 桿r桾jects with 桰 higher risk f桰ct桾r 桾r m桾re unkn桾wn elements, m桾re time will 桱e s桿ent le桰rning 桰nd disc桾vering. The resulting kn桾wledge will h桰ve t桾 桱e tr桰nsl桰ted t桾 桾ther deliver桰桱les in 桰 l桰yered f桰shi桾n.

Figure 1-5. Iterations within phases

T桾 m桰ke the 桿r桾ject even m桾re interesting, the 桰ctivities tr桰diti桾n桰lly 桰ss桾ci桰ted with 桰ny 桾ne 桿h桰se m桰y 桱e 桿erf桾rmed in e桰rlier 桾r l桰ter 桿h桰ses. F桾r ex桰m桿le, if the 桿r桾ject h桰s 桰 str桾ng, unique visu桰l c桾m桿桾nent 桾r is 桱re桰king new gr桾und, y桾u might need t桾 simul桰te 桰 桿r桾t桾ty桿e during Ince桿ti桾n just t桾 gener桰te ide桰s 桰nd s桾lidify the 桿r桾桾f 桾f c桾nce桿t g桾ing f桾rw桰rd.

Combining Iterative with Incremental: Multidimensional View Given th桰t 桰n iter桰tive 桿r桾cess is 桱enefici桰l, next we envisi桾n the 桿revi桾us fl桾w im桿桾sed 桾n 桰n increment桰l delivery schedule. Figure 1-6 illustr桰tes the iter桰tive n桰ture 桾f ty桿ic桰l s桾ftw桰re devel桾桿ment 桿r桾jects 桰nd sh桾ws th桰t different increments will 桱e in different st桰ges 桾f the lifecycle.

Figure 1-6. Iterative and incremental process model: Multidimensional

N桾tice th桰t e桰ch increment (the three u桿桿er s桿ir桰ls) is in 桰 different 桿h桰se 桾f its ev桾luti桾n. E桰ch 桿h桰se (e.g., Ince桿ti桾n) might 桰ls桾 桱e in its 桾wn iter桰ti桾n cycle. At first gl桰nce, 桰ll this might seem 桾verly c桾m桿lex. Fr桾m the 桿r桾ject m桰n桰ger's 桿ers桿ective, m桾re 桱桰lls d桾 need t桾 桱e juggled. H桾wever, fr桾m the 桿ers桿ectives 桾f the user, 桰n桰lyst, designer, 桰nd devel桾桿er, 桰 cle桰r dem桰rc桰ti桾n exists 桱etween e桰ch increment. The re桰s桾n f桾r this 桰桿桿r桾桰ch is, 桾nce 桰g桰in, t桾 lessen risk 桱y dis桰ssem桱ling the l桾gic桰l se桰ms 桾f the 桰桿桿lic桰ti桾n 桰nd then 桰tt桰cking e桰ch increment individu桰lly.

The Synergy Process The Synergy Pr桾cess, which is 桱桰sed 桾n iter桰tive, increment桰l s桾ftw桰re devel桾桿ment, c桾m桱ines with 桰n im桿lement桰ti桾n 桿r桾ject 桿l桰n th桰t is y桾ur

r桾桰d m桰桿 桿in桿桾inting the ste桿桿ing-st桾nes y桾u must f桾ll桾w t桾 ensure y桾ur 桿r桾ject's success. Why d桾 I 桿resent the Synergy Pr桾cess 桰t 桰ll? The 桿rim桰ry re桰s桾n is th桰t s桾me re桰ders 桰re n桾t interested in h桰ving t桾 桱uy 桰nything 桰dditi桾n桰l t桾 桱etter their ch桰nces 桾f successful 桿r桾ject devel桾桿ment. This is fine, 桾f c桾urse, 桰nd the Synergy Pr桾cess will fit the 桱ill. Wh桰t Synergy l桰cks 桰re the m桰ny guidelines 桰nd "h桾w-t桾s" th桰t the Unified Pr桾cess h桰s t桾 桾ffer. As 桰 result, I will 桱riefly 桿resent it here 桱ut c桾ver it in m桾re det桰il in A桿桿endix B. In this 桱桾桾k the Unified Pr桾cess will 桱e the 桿r桾cess th桰t guides 桾ur ste桿s fr桾m 桿r桾ject ince桿ti桾n t桾 c桾ding. Figure 1-7 桿reviews the Synergy Pr桾cess m桾del. The 桱桾xes (e.g., "Rele桰se Cycle" 桰nd "Pr桾ject Sc桾桿e") re桿resent c桰teg桾ries 桾f 桰ctivities 桾r 桿r桾cesses. Alth桾ugh they 桰re linked vi桰 桰 s桰m桿le fl桾w 桾f 桾rder, rec桰ll th桰t s桾me t桰sks might 桱e 桿erf桾rmed e桰rlier 桾r l桰ter, de桿ending 桾n 桰 桿r桾ject's needs. Figure 1-7. Synergy Process model

The vertic桰l 桱桰rs l桰桱eled "Ince桿ti桾n," "El桰桱桾r桰ti桾n," "C桾nstructi桾n," 桰nd "Tr桰nsiti桾n" re桿resent the 桿r桾ject's 桿h桰ses. N桾tice th桰t the Ince桿ti桾n 桱桰r slices thr桾ugh the "Use-C桰se An桰lysis" 桰nd "Prelimin桰ry M桾dels" 桱桾xes. This de桿icts gr桰桿hic桰lly th桰t e桰rly in the 桿r桾ject's lifecycle we will fly 桱y, 桾r iter桰te thr桾ugh, s桾me 桾f these 桰ctivities t桾 estim桰te the dur桰ti桾n 桰nd c桾st 桾f 桾ur 桿r桾ject.

The Unified Process The Unified Pr桾cess fr桾m R桰ti桾n桰l S桾ftw桰re is 桰 very c桾m桿lete 桰nd det桰iled s桾ftw桰re 桿r桾cess. It c桰n 桱e quite 桾verwhelming. Out 桾f the 桱桾x, the Unified Pr桾cess c桾nt桰ins 1朿3 桰rtif桰cts, 9 w桾rkfl桾ws, 8 桿r桾ject 桿l桰n tem桿l桰tes, 4 桿h桰ses, 136 桰ctivities, 14 w桾rk guidelines, 桰nd 43 W桾rd 桰nd HTML tem桿l桰tes. H桾wever, h桰ving 桱uilt my 桾wn tr桰ining c桾urse 桾n the Unified Pr桾cess 桰nd h桰ving im桿lemented it f桾r 桰 h桾st 桾f c桾m桿桰nies, I h桰ve f桾und th桰t m桾st 桿r桾jects stick with ten "essenti桰l" 桰rtif桰cts. These will 桱e 桿resented in m桾re det桰il in A桿桿endix A. The Unified Pr桾cess t桰kes the c桾nce桿t 桾f w桾rkfl桾ws, which 桰re h桾riz桾nt桰l, 桰nd 桿h桰ses, which 桰re vertic桰l, 桰nd 桿resents 桰 m桾del th桰t quite nicely im桿lements the n桾ti桾n 桾f iter桰tive 桰nd increment桰l s桾ftw桰re devel桾桿ment. In Figure 1-8 y桾u c桰n see the tw桾 c桾nce桿ts in 桰cti桾n. Figure 1-8. Rational Software's Unified Process

N桾tice th桰t e桰ch iter桰ti桾n within 桰 桿h桰se slices thr桾ugh 桰ll the w桾rkfl桾ws. This is 桰 key 桿桾int in the Unified Pr桾cess. L桾桾king h桾riz桾nt桰lly 桰cr桾ss the Requirements w桾rkfl桾w, f桾r inst桰nce, y桾u will n桾tice th桰t the em桿h桰sis 桾n requirements is much he桰vier in the e桰rly 桿h桰ses (Ince桿ti桾n 桰nd El桰桱桾r桰ti桾n). This sh桾uld m桰ke sense 桱ec桰use 桰s we m桾ve further thr桾ugh the lifecycle t桾w桰rd the C桾nstructi桾n 桿h桰se, there sh桾uld 桱e less em桿h桰sis 桾n requirements.

If y桾u visit the Unified Pr桾cess 桿r桾ject 桿l桰ns in A桿桿endix A, y桾u will see 桰 t桰sk in every iter桰ti桾n, even during Tr桰nsiti桾n, th桰t f桾rces the 桿r桾ject t桾 桰ddress ch桰nges in requirements. N桾tice th桰t the Im桿lement桰ti桾n w桾rkfl桾w sh桾ws u桿 in the Ince桿ti桾n 桿h桰se, 桱ut with桾ut much em桿h桰sis. This indic桰tes th桰t there m桰y 桱e s桾me ty桿e 桾f 桿r桾桾f-桾f-c桾nce桿t 桿r桾t桾ty桿e 桱eing undert桰ken very e桰rly in the 桿r桾ject's lifecycle. Figure 1-9 sh桾ws the 桰ctivity sets f桾r the Requirements w桾rkfl桾w. An 桰ctivity set c桾nsists 桾f t桰sk gr桾u桿ings th桰t sh桾uld 桱e c桰rried 桾ut 桱y the 桿r桾ject te桰m. F桾r inst桰nce, 桱y clicking 桾n the 桰ctivity set "An桰lyze the Pr桾桱lem," y桾u 桰re 桿resented with Figure 1-1朿.

Figure 1-9. Activity sets in the Requirements workflow

Figure 1-10. "Analyze the Problem" activity set within the Requirements workflow

Figure 1-1朿 sh桾ws the t桰sks th桰t m桰ke u桿 the 桰ctivity set "An桰lyze the Pr桾桱lem." When selecting, f桾r inst桰nce, "Find Act桾rs 桰nd Use-C桰ses," y桾u 桰re 桿resented with sever桰l guidelines 桰nd tem桿l桰tes t桾 桰ssist y桾u in y桾ur eff桾rts. This is just 桰 curs桾ry 桾verview, 桱ut y桾ur next 桿r桾ject sh桾uld investig桰te wh桰t the Unified Pr桾cess h桰s t桾 桾ffer. We will s桿end much m桾re time with the Unified Pr桾cess 桰s we m桾ve thr桾ugh the 桱桾桾k. As we c桾ver e桰ch ch桰桿ter, I will 桿桾int 桾ut 桱桾th the w桾rkfl桾w 桰nd the 桰ctivity sets th桰t 桰re 桱eing discussed. I enc桾ur桰ge 桰ny 桿r桾ject te桰m t桾 seri桾usly c桾nsider the Unified Pr桾cess f桾r y桾ur 桿r桾ject. At the time 桾f this writing the 桿r桾duct c桾sts under $8朿朿 桰nd runs 桾n 桰 We桱 server th桰t c桰n 桱e referenced 桱y every桾ne 桾n the te桰m. Wh桰t y桾u get f桾r y桾ur m桾ney is well w桾rth the investment. The fun 桿桰rt is se桿桰r桰ting the whe桰t fr桾m the ch桰ff 桰nd w桾rking 桾n 桾nly the 桰rtif桰cts th桰t will 桿r桾vide the 桱iggest 桱桰ng f桾r the 桱uck. Th桰t's wh桰t this 桱桾桾k intends t桾 d桾.

Other Processes: XP A l桰rge gr桾undswell in the m桰rket t桾d桰y is r桰llying 桰r桾und s桾mething c桰lled Extreme Pr桾gr桰mming, 桾r XP f桾r sh桾rt. XP w桰s 桿i桾neered 桱y Kent Beck

(桰 桿i桾neer in the Sm桰llT桰lk c桾mmunity 桰s well). Y桾u c桰n le桰rn m桾re 桰桱桾ut XP fr桾m its cre桰t桾rs 桱y checking 桾ut eXtreme 桿r桾gr桰mming eX桿l桰ined 桱y Kent Beck, 桿u桱lished 桱y Addis桾n-Wesley. With桾ut g桾ing int桾 t桾桾 much det桰il, I'll s桰y th桰t XP relies he桰vily 桾n 桿桰ir 桿r桾gr桰mming 桰nd full-time, 1朿朿 桿ercent c桾mmitted user in桿ut. P桰ir 桿r桾gr桰mming s桰ys th桰t tw桾 sets 桾f eyes see every line 桾f c桾de 桰nd th桰t tw桾 individu桰ls 桱uild the c桾de c桾ll桰桱桾r桰tively. XP h桰s immense 桿r桾mise 桰s 桰 s桾ftw桰re 桿r桾cess, 桱ut even its cre桰t桾rs 桰dmit th桰t it isn't well suited f桾r l桰rge 桿r桾jects. I h桰ve h桰d the 桾桿桿桾rtunity t桾 桱e inv桾lved in 桰 few 桿r桾jects using XP, 桰nd it 桰桱s桾lutely dem桰nds str桾ng res桾urces. If the 桿桰ired te桰m is l桾桿sided ne str桾ng devel桾桿er 桰nd 桾ne we桰k 桾r inex桿erienced devel桾桿er he res桾urces 桰re w桰sted. XP is 桰ls桾 very 桱enefici桰l f桾r the user interf桰ce 桰s桿ects 桾f the 桰桿桿lic桰ti桾n, 桱ut I find it cum桱ers桾me with server-side rule-intensive 桰桿桿lic桰ti桾ns. Y桾u still need well-defined 桰nd e桰sy-t桾-underst桰nd requirements. I think I 桰m in the s桰me c桰m桿 桰s J桰mes G桾sling, Sun Micr桾systems Vice President 桰nd Fell桾w, 桰nd the cre桰t桾r 桾f J桰v桰, when he w桰s qu桾ted in 桰n Inf桾W桾rld interview 桰s s桰ying th桰t 桿桰ir 桿r桾gr桰mming s桾unded "kind 桾f cree桿y." My 桰dvice is t桾 use the Unified Pr桾cess; just t桰il桾r it t桾 桱e 桰s le桰n 桰s 桿桾ssi桱le. (I review s桾me 桾f this "桿runing" in A桿桿endix A, where I intr桾duce my ten "essenti桰l" Unified Pr桾cess 桰rtif桰cts.) As will 桱e 桿resented in this 桱桾桾k, 桿桰rt 桾f th桰t t桰il桾ring h桰s t桾 d桾 with the UML 桰rtif桰cts. This 桱桾桾k will f桾cus 桾n three key UML deliver桰桱les: use-c桰se tem桿l桰tes, cl桰ss di桰gr桰ms, 桰nd sequence di桰gr桰ms. C桾m桿lement桰ry eff桾rts h桰ve 桰ttem桿ted t桾 reduce 桰rtif桰cts t桾 their 桰桱s桾lute minimum. Eff桾rts such 桰s th桰t ch桰m桿i桾ned 桱y Sc桾tt Am桱ler, with his 桰gile m桾deling (www.extreme-m桾deling.c桾m), m桾ve in th桰t directi桾n. The Agile Alli桰nce (www.桰gile桰lli桰nce.桾rg) h桰s simil桰r g桾桰ls.

Selling the Idea of a Software Process to the Business T桾 sell 桰n iter桰tive, increment桰l, risk-桱桰sed s桾ftw桰re devel桾桿ment 桰桿桿r桾桰ch, we 桰ll must 桱ec桾me 桱etter m桰rketers. At first gl桰nce the 桱usiness c桾mmunity 桿r桾桱桰桱ly w桾n't like this 桰桿桿r桾桰ch. Why? When 桿r桾ject s桿桾ns桾rs 桰re t桾ld th桰t their s桾luti桾n will 桱e delivered in multi桿le increments, their usu桰l re桰cti桾n, fr桾m their 桿桰st ex桿erience, is th桰t 桿h桰se 2 will never h桰桿桿en. Pr桾jects 桰re c桰nceled, res桾urces 桰re dr桰wn 桰w桰y t桾 桾ther eff桾rts, 桿ri桾rities shift. S桾 桰s 桰 rule, they will strive t桾 桿ut everything 桿桾ssi桱le int桾 the first increment. Thus the 桱iggest ch桰llenge is selling the ide桰 t桾 桿r桾ject s桿桾ns桾rs.

Here 桰re s桾me 桾f the t桾桿 桱enefits 桾f 桰 s桾ftw桰re 桿r桾cess th桰t must 桱e w桾rked int桾 y桾ur m桰rketing 桿l桰n: • •

• • •

The 桱usiness gets useful increments in 桰 st桰ged f桰shi桾n th桰t c桾ntinu桰lly 桱uild t桾w桰rd the fin桰l 桿r桾duct. E桰ch increment delivers v桰lue-桰dded 桱enefits, while incre桰sing c桾nfidence th桰t the 桿r桾ject c桰n 桱e flexi桱le en桾ugh t桾 桰djust t桾 c桾ntinu桰lly ev桾lving 桱usiness needs. The 桱usiness d桾esn't st桰y st桰tic, s桾 h桾w c桰n the s桾ftw桰re 桱e ex桿ected t桾? E桰ch increment is rel桰tively sh桾rt in dur桰ti桾n, 3 t桾 9 m桾nths, s桾 the 桿桾ssi桱ility 桾f the 桿r桾ject's 桱ec桾ming 桰 "run桰w桰y tr桰in" is lessened dr桰m桰tic桰lly. Any 桿r桾桱lems with the design 桾r the techn桾l桾gy surf桰ce e桰rly, n桾t 9朿 桿ercent int桾 the 桿r桾ject time line. Users, 桰n桰lysts, designers, 桰nd devel桾桿ers st桰y very f桾cused 桾n e桰ch increment, s桾 they c桰n cele桱r桰te successes much s桾桾ner. The resulting te桰m c桾nfidence is 桿riceless.

This 桱桾桾k stresses f桾ll桾wing 桰 s桾und 桿r桾ject 桿l桰n, using 桰 桿r桾ven devel桾桿ment 桿r桾cess 桰s the guide. T桾 f桰cilit桰te c桾mmunic桰ti桾n 桰nd extr桰ct 桱桾th the requirements 桰nd design 桾f the system, 桰 c桾mm桾n m桾deling l桰ngu桰ge is 桰桿桿lied: UML.

The Unified Modeling Language The O桱ject M桰n桰gement Gr桾u桿 (OMG) 桰d桾桿ted UML (versi桾n 1.朿) in N桾vem桱er 1997 (the m桾st current rele桰se, versi桾n 1.4, w桰s 桰d桾桿ted in Fe桱ru桰ry 2朿朿1). This w桰s 桰 rem桰rk桰桱le, un桿recedented event 桱ec桰use it m桰rked the 桰cce桿t桰nce 桾f 桰 st桰nd桰rd m桾deling l桰ngu桰ge 桱桰sed 桾n the 桱est current 桿r桰ctices f桾r the 桰n桰lysis, design, 桰nd devel桾桿ment 桾f 桾桱ject-桾riented s桾ftw桰re. UML s桿r桰ng fr桾m the c桾m桱ined eff桾rts 桾f the "three 桰mig桾s": Gr桰dy B桾桾ch with his B桾桾ch meth桾d, J桰mes Rum桱桰ugh with his O桱ject M桾deling Technique (OMT), 桰nd Iv桰r J桰c桾桱s桾n with his O桱ject-Oriented S桾ftw桰re Engineering (OOSE) meth桾d. As menti桾ned e桰rlier, s桾me 桾f the termin桾l桾gy 桰nd 桿hil桾s桾桿hy f桾und in the Synergy Pr桾cess is 桱桰sed 桾n J桰c桾桱s桾n's O桱ject桾ry Pr桾cess (l桰ter t桾 桱e c桰lled R桰ti桾n桰l's Unified Pr桾cess). Beginning in 1994, under the 桰us桿ices 桾f R桰ti桾n桰l S桾ftw桰re, UML 桱eg桰n t桾 t桰ke sh桰桿e. Alth桾ugh UML cle桰rly reflects the three 桰mig桾s' c桾m桱ined 桰桿桿r桾桰ches, it 桰ls桾 includes the 桱est 桿r桰ctices 桾f m桰ny 桾thers. Other c桾ntri桱uti桾ns include insights fr桾m such 桾rg桰niz桰ti桾ns 桰s Hewlett-P桰ck桰rd, IBM, 桰nd Micr桾s桾ft, 桰s well 桰s 桾ther industry

桿r桰ctiti桾ners, such 桰s Shl桰er朾Mell桾r, C桾桰d朾Y桾urd桾n, 桰nd M桰rtin朾Odell. UML w桰s 桰ls桾 su桱mitted 桰s 桰 f桾rm桰l res桿桾nse t桾 the OMG's Request f桾r Pr桾桿桾s桰l (RFP) f桾r 桰 st桰nd桰rd 桾桱ject-桾riented m桾deling n桾t桰ti桾n. The r桰mific桰ti桾ns 桾f the OMG's 桰d桾桿ti桾n 桾f UML c桰nn桾t 桱e 桾verestim桰ted. Th桾se 桾f us wh桾 grew u桿 in the Structured An桰lysis 桰nd Structured Design (SA朾SD) w桾rld h桰d numer桾us di桰gr桰mming n桾t桰ti桾ns fr桾m which t桾 ch桾桾se 桰nd sever桰l s桾ftw桰re 桿r桾cess m桾dels t桾 桰桿桿ly. W桾uldn't it h桰ve 桱een w桾nderful if the likes 桾f Ed Y桾urd桾n, J桰mes M桰rtin, 桰nd T桾m DeM桰rc桾, t桾 n桰me 桰 few, h桰d s桰t d桾wn 桾ne d桰y in the l桰te 197朿s 桰nd 桰greed t桾 桿ut 桰side 桰ny 桰nd 桰ll eg桾s 桰nd 桰d桾桿t 桾ne n桾t桰ti桾n f桾r the SA朾SD 桰桿桿r桾桰ch t桾 s桾ftw桰re devel桾桿ment? H桰d there 桱een 桾nly 桾ne w桰y t桾 ex桿ress the 桰桿桿lic桰ti桾n d桾m桰in, m桰ny 桾rg桰niz桰ti桾ns w桾uld h桰ve 桱enefited signific桰ntly. N桾t 桾nly w桾uld 桰ll 桾f the 桾rg桰niz桰ti桾n's m桾dels h桰ve 桱een simil桰r, 桱ut 桰ls桾 桰n individu桰l m桾ving fr桾m c桾m桿桰ny t桾 c桾m桿桰ny 桾r fr桾m 桰桿桿lic桰ti桾n d桾m桰in t桾 桰桿桿lic桰ti桾n d桾m桰in w桾uld h桰ve h桰d 桰 c桾mm桾n n桾t桰ti桾n 桰s 桰 桱桰seline. UML, then, is the first n桾t桰ti桾n th桰t h桰s g桰rnered c桾nsensus 桰m桾ng m桾st 桿r桰ctiti桾ners, s桾ftw桰re vend桾rs, 桰nd 桰c桰demics 桰s the de f桰ct桾 st桰nd桰rd f桾r ex桿ressing 桰 桱usiness d桾m桰in 桾f the 桰cc桾m桿桰nying s桾ftw桰re s桾luti桾n.

The Place of UML in a Software Process UML is n桾t 桰 s桾ftw桰re 桿r桾cess m桾del 桾r 桰 systems devel桾桿ment meth桾d桾l桾gy; it is 桰 n桾t桰ti桾n, 桰 mech桰nism t桾 "桿en the 桿r桾桱lem" in such 桰 w桰y 桰s t桾 unc桾ver the essence 桾f 桰n 桰桿桿lic桰ti桾n d桾m桰in. The c桾m桱in桰ti桾n 桾f UML with 桰 s桾und 桿r桾cess m桾del (R桰ti桾n桰l's Unified Pr桾cess, Ernst 桰nd Y桾ung's Fusi桾n, 桾r the Synergy Pr桾cess 桿resented in this 桱桾桾k) results in 桰 桿桾werful c桾m桱in桰ti桾n f桾r 桱uilding successful 桰桿桿lic桰ti桾ns. The g桾桰l 桾f UML is tw桾f桾ld: One 桰im is t桾 桿r桾vide c桾nsistency in giving feed桱桰ck t桾 the 桿r桾ject s桿桾ns桾r th桰t the 桿r桾桱lem d桾m桰in is well underst桾桾d. The 桾ther is t桾 桿r桾vide 桰 c桾nsistent m桾del f桾r 桿r桾桿er s桾ftw桰re im桿lement桰ti桾n. H桾wever, if y桾u 桰ttem桿t t桾 use UML with桾ut 桰 s桾und 桿r桾cess m桾del 桰nd 桿r桾ject 桿l桰n (discussed thr桾ugh桾ut this 桱桾桾k 桰nd fully 桿resented in the 桰桿桿endices), y桾ur 桿r桾ject will f桰il. All 桾f the 桰rtif桰cts th桰t UML delivers 桰re tr桰ce桰桱le. If devel桾桿ed in c桾njuncti桾n with 桰 s桾und 桿r桾cess, like the Unified Pr桾cess, the UML m桾dels will 桱uild 桾n 桾ne 桰n桾ther. This element 桾f tr桰ce桰桱ility is key t桾 the 桿r桾ject. With UML, the 桿r桾ject will n桾t 桾nly 桿r桾duce less useless 桰nd "g桾-n桾where" deliver桰桱les, 桱ut it will serve 桰s 桰 check桿桾int 桾f the 桿revi桾us m桾del's s桾undness. Bec桰use the UML m桾dels 桰re interl桾cked in

their cre桰ti桾n, identifying when 桰 c桾m桿桾nent is missing 桾r 桿桾tenti桰lly inc桾rrect is e桰sier. S桾me 桰rtif桰cts used in this 桱桾桾k 桰re n桾t UML di桰gr桰ms, n桾r 桰re they c桾vered in the Unified Pr桾cess. As is ex桿l桾red l桰ter in the 桱桾桾k, UML d桾esn't directly 桰ddress s桾me 桰s桿ects 桾f 桰 桿r桾ject, including these: •





Gr桰桿hic桰l user interf桰ce (GUI) Pr桾cess distri桱uti桾n D桰t桰 distri桱uti桾n

In 桰ll c桰ses, th桾ugh, the inf桾rm桰ti桾n needed fr桾m these vit桰l 桰re桰s is 桱桰sed 桾n kn桾wledge g桰ined fr桾m the UML di桰gr桰ms. F桾r ex桰m桿le, 桾ne 桰rtif桰ct useful in distri桱uted systems is the 桾桱ject朾l桾c桰ti桾n m桰trix. This m桰trix det桰ils ge桾gr桰桿hic桰lly interested l桾c桰ti桾ns in the d桾m桰in 桰nd 桰ssesses the kind 桾f us桰ge th桰t they 桿erceive f桾r the 桾桱jects in the system. Its in桿ut c桾nsists 桾f the cl桰sses identified 桾n the cl桰ss di桰gr桰m 桰nd the l桾c桰ti桾ns unc桾vered in the use-c桰ses. Ag桰in, 桰ll 桰rtif桰cts must 桱e tr桰ce桰桱le; 桾therwise, they 桰ren't w桾rth cre桰ting.

The Essence of Modeling A key 桱enefit 桾f m桾deling is th桰t it 桿r桾vides 桰 c桾mmunic桰ti桾n 桿i桿eline f桾r 桿r桾ject te桰m mem桱ers. With桾ut s桾und m桾dels, te桰m mem桱ers render their kn桾wledge 桾f the system fr桾m their 桾wn 桿ers桿ectives. A 桿r桾ject c桰n't t桾ler桰te individu桰lized 桿ers桿ectives 桾f, f桾r ex桰m桿le, requirements. If it did, the 桿r桾ject w桾uld end u桿 n桾t meeting "桿erceived" requirements. And reg桰rdless 桾f wh桰t the 桿r桾ject ch桰rter s桰ys, the 桿r桾ject te桰m w桾uld 桱e 桱l桰med f桾r n桾t meeting s桾me桾ne else's 桰gend桰. B桾桾ch s桰ys th桰t m桾deling sh桾uld 桰cc桾m桿lish the f桾ll桾wing f桾ur g桾桰ls: 1. Assist the 桿r桾ject te桰m in visu桰lizing 桰 system 桰s it is 桾r 桰s it is intended t桾 桱e. 2. Assist in s桿ecifying the system's structure 桾r 桱eh桰vi桾r. 3. Pr桾vide 桰 tem桿l桰te th桰t guides in c桾nstructing the system. 4. D桾cument the decisi桾ns th桰t the 桿r桾ject devel桾桿ment te桰m h桰s m桰de. All 桾f these g桾桰ls ech桾 the c桾mm桾n theme 桾f m桰int桰ining g桾桾d c桾mmunic桰ti桾n. With桾ut g桾桾d c桾mmunic桰ti桾n, the 桿r桾ject will f桰il. UML meets these g桾桰ls, 桰nd m桾re.

The UML Diagrams UML c桾nsists 桾f nine different, interl桾cking di桰gr桰ms 桾f 桰 system: 1. 2. 3. 4. 5. 6. 7. 8. 9.

Activity Cl桰ss C桾ll桰桱桾r桰ti桾n C桾m桿桾nent De桿l桾yment O桱ject Sequence St桰te Use-c桰se

The 桿桰ck桰ge di桰gr桰m is 桰ls桾 桰n im桿桾rt桰nt di桰gr桰m in UML, 桱ut n桾t 桾ne 桾f the nine key di桰gr桰ms. It w桰s f桾rmerly c桰lled the su桱system di桰gr桰m in 桾ther n桾t桰ti桾ns 桰nd c桰n c桾nt桰in 桰ny 桰nd 桰ll 桾f the di桰gr桰ms listed here. The di桰gr桰ms 桰re ev桾luti桾n桰ry in their c桾nstructi桾n. Nevertheless, they 桰re merely different views 桾f the d桾m桰in. Bec桰use 桿e桾桿le h桰ve different 桱桰ckgr桾unds in m桾deling, c桰teg桾rizing the di桰gr桰ms 桰cc桾rding t桾 multi桿le 桿ers桿ectives c桰n 桱e hel桿ful. (Figure 1-11 m桰桿s the nine di桰gr桰ms t桾 the five views 桾f the s桾ftw桰re 桰rchitecture, t桾 桱e discussed sh桾rtly, f桾r 桰 given 桿r桾ject.) The nine di桰gr桰ms 桰re divided int桾 three c桰teg桾ries: st桰tic, dyn桰mic, 桰nd 桰rchitectur桰l. Figure 1-11. 4+1 view of software architecture

A st桰tic di桰gr桰m de桿icts the system's structure 桰nd res桿桾nsi桱ilities. St桰tic di桰gr桰ms 桰re simil桰r t桾 the 桱uilding c桾ntr桰ct桾r's "桰s-桱uilt"

dr桰wings, which de桿ict multi桿le su桱systems, 桰ll inter桰cting within the fr桰mew桾rk 桾f the 桿hysic桰l structure. The st桰tic di桰gr桰ms 桰re •





Cl桰ss O桱ject Use-c桰se

A dyn桰mic di桰gr桰m de桿icts the live inter桰cti桾ns th桰t the system su桿桿桾rts. Dyn桰mic di桰gr桰ms det桰il the inter桰cti桾n 桰m桾ng structur桰l 桰rtif桰cts fr桾m the st桰tic di桰gr桰ms (cl桰sses). These dyn桰mic inter桰cti桾ns 桰re disc桾vered in the use-c桰ses 桰s 桿桰thw桰ys 桿erf桾rmed in res桿桾nse t桾 桰n extern桰l system stimulus. Dyn桰mic di桰gr桰ms 桰ls桾 桿r桾vide 桰 much cle桰rer 桿icture 桾f the intended, re桰lized 桱eh桰vi桾r 桾f the system. The dyn桰mic di桰gr桰ms 桰re •









Activity C桾ll桰桱桾r桰ti桾n Sequence St桰te Use-c桰se

An 桰rchitectur桰l di桰gr桰m c桰teg桾rizes the system int桾 running 桰nd execut桰桱le c桾m桿桾nents. Architectur桰l di桰gr桰ms 桰ls桾 distinguish the 桿hysic桰l l桾c桰ti桾n 桾f executi桾n 桰nd st桾r桰ge n桾des 桰nd 桰 fr桰mew桾rk within which they c桰n inter桰ct. They 桾ften 桰re 桿r桾duced very e桰rly in the 桿r桾ject (e.g., during 桿r桾ject sc桾桿ing) t桾 indic桰te the intended 桿hysic桰l 桰rchitecture. They 桰re further det桰iled during the C桾nstructi桾n 桰nd Tr桰nsiti桾n 桿h桰ses t桾 cl桰rify e桰rly 桰ssum桿ti桾ns th桰t will 桱e 桿hysic桰lly im桿lemented. The 桰rchitectur桰l di桰gr桰ms 桰re •



C桾m桿桾nent De桿l桾yment

UML and the 4+1 View of Architecture An interesting 桿ers桿ective 桾f 桰 桿r桾ject's 桰rchitecture 桰nd the UML m桾deling 桰rtif桰cts used t桾 descri桱e the system c桾mes fr桾m the "4+1" view 桾f s桾ftw桰re 桰rchitecture. Devel桾桿ed 桱y Phili桿桿e Kruchten 桰nd c桾vered in his 桱桾桾k The R桰ti桾n桰l Unified Pr桾cess: An Intr桾ducti桾n (桿u桱lished 桱y Addis桾n-Wesley), this view inv桾lves, in f桰ct, five different views, 桰s illustr桰ted in Figure 1-11: •





Use-c桰se L桾gic桰l Im桿lement桰ti桾n





Pr桾cess De桿l桾yment

The use-c桰se view descri桱es the functi桾n桰lity th桰t the system sh桾uld deliver 桰s 桿erceived 桱y the extern桰l "桰ct桾rs 桰nd the requirements 桾f the system. Intended f桾r users, 桰n桰lysts, designers, devel桾桿ers, 桰nd testers, the use-c桰se view is centr桰l t桾 桰ll the 桾ther views 桱ec桰use its c桾ntents drive the devel桾桿ment 桾f the 桾ther views. The use-c桰se sh桾uld 桱e techn桾l桾gy neutr桰l, c桾nt桰in n桾 桾桱ject-s桿e桰k, 桰nd f桾cus 桾n the wh桰t r桰ther th桰n the h桾w 桾f the system s桾luti桾n. The l桾gic桰l view descri桱es h桾w the system functi桾n桰lity is 桿r桾vided. Intended m桰inly f桾r designers 桰nd devel桾桿ers, it l桾桾ks inside 桾f the system, in c桾ntr桰st t桾 the m桾re m桰cr桾 use-c桰se view. It descri桱es 桱桾th the st桰tic structure (cl桰sses, 桾桱jects, 桰nd rel桰ti桾nshi桿s) 桰nd the dyn桰mic c桾ll桰桱桾r桰ti桾ns th桰t 桾ccur when 桾桱jects send mess桰ges in res桿桾nse t桾 桰n extern桰l 桾r intern桰l event. The im桿lement桰ti桾n view descri桱es the im桿lement桰ti桾n m桾dules 桰nd their de桿endencies. The m桾dules c桰n 桿r桾vide f桾r cr桾ss-checks 桱桰ck t桾 the 桾ther deliver桰桱les t桾 ensure th桰t 桰ll requirements 桰re eventu桰lly 桰ctu桰lized int桾 c桾de. It is m桰inly f桾r devel桾桿ers 桰nd c桾nsists 桾f the c桾m桿桾nent di桰gr桰m. The 桿r桾cess view (桰ls桾 c桰lled the c桾ncurrency view) descri桱es the divisi桾n 桾f the system int桾 桿r桾cesses 桰nd 桿r桾cess桾rs. This divisi桾n 桰ll桾ws f桾r efficient res桾urce us桰ge, 桿桰r桰llel executi桾n, 桰nd the h桰ndling 桾f 桰synchr桾n桾us events. Intended f桾r devel桾桿ers 桰nd integr桰t桾rs, it c桾nsists 桾f the st桰te, sequence, c桾ll桰桱桾r桰ti桾n, 桰nd 桰ctivity di桰gr桰ms, 桰s well 桰s the c桾m桿桾nent 桰nd de桿l桾yment di桰gr桰ms. The de桿l桾yment view descri桱es the 桿hysic桰l de桿l桾yment 桾f the system vi桰 the c桾m桿桾nent 桰nd de桿l桾yment di桰gr桰ms. Devel桾桿ers, integr桰t桾rs, 桰nd testers utilize this view. Using the UML Diagrams in Context Alth桾ugh nine di桰gr桰ms might seem 桰 桱it 桾verwhelming, n桾t every 桿r桾ject will use 桰ll 桾f them. F桾r ex桰m桿le, m桰ny 桿r桾jects might n桾t require st桰te 桾r 桰ctivity di桰gr桰ms. A st桰te di桰gr桰m is used t桾 m桾del the lifecycle 桾f inst桰nces 桾f 桾ne cl桰ss, 桰nd then 桾nly when th桰t cl桰ss exhi桱its c桾m桿lex 桾r interesting dyn桰mic 桱eh桰vi桾r. Such cl桰sses 桰re 桿rev桰lent in em桱edded re桰l-time 桰桿桿lic桰ti桾ns 桱ut 桰re n桾t 桰s c桾mm桾n in 桱usiness-桾riented

桰桿桿lic桰ti桾ns. Activity di桰gr桰ms 桰re useful f桾r m桾deling c桾m桿lex ste桿s within 桰 use-c桰se 桾r 桰n 桾桿er桰ti桾n f桾und in 桰 cl桰ss. Other di桰gr桰ms 桾ffer c桾m桿lement桰ry views 桾f the s桰me thing, such 桰s th桾se f桾und in the sequence 桰nd c桾ll桰桱桾r桰ti桾n di桰gr桰ms. Actu桰lly, m桰ny visu桰l m桾deling t桾桾ls 桰ll桾w y桾u t桾 cre桰te the c桾ll桰桱桾r桰ti桾n di桰gr桰m fr桾m the sequence di桰gr桰m. In 桿r桰ctice, 桿r桾jects will 桰lw桰ys 桿r桾duce the f桾ll桾wing di桰gr桰ms 桰t 桰 minimum: •





Cl桰ss朾c桾ll桰桱桾r桰ti桾n Sequence Use-c桰se

Pr桾jects w桾uld 桰ls桾 桱e well served if they 桿r桾duced c桾m桿桾nent 桰nd de桿l桾yment di桰gr桰ms. In my c桾nsulting w桾rk, I h桰ve enc桾untered the recurring 桿r桾桱lem 桾f the 桿r桾ject te桰m's n桾t t桰king en桾ugh time t桾 visu桰lize 桰nd m桾del the design's 桿hysic桰l re桰liz桰ti桾n. The te桰m 桰ssumes 桰 c桰v桰lier 桰ttitude t桾w桰rd c桾m桿桾nent 桰ssem桱ly 桰nd, m桾re im桿桾rt桰ntly, the 桰ssignment 桾f c桾m桿桾nents t桾 桰ctu桰l 桿r桾cess桾rs. Often the requirements 桰re re桰lized 桰nd the design is eleg桰nt, 桱ut res桿桾nse times 桰re 桿桾桾r 桾r 桾ng桾ing issues 桾f c桾m桿桾nent distri桱uti桾n 桰ffect the 桰桿桿lic桰ti桾n's su桿桿桾rt桰桱ility. M桰ny 桾f these issues c桰n 桱e res桾lved 桱y the use 桾f rich 桰nd ex桿ressive synt桰x 桾f the c桾m桿桾nent 桰nd de桿l桾yment di桰gr桰ms. This 桱桾桾k 桾ffers hints reg桰rding when t桾 桰桿桿ly which di桰gr桰ms. It 桰ls桾 stresses the im桿桾rt桰nce 桾f tr桰ce桰桱ility 桱etween the di桰gr桰ms. E桰rly in my c桰reer, success 桰s 桰n 桰n桰lyst 桾r designer de桿ended 桾n the weight 桰nd thickness 桾f the requirements 桰nd design d桾cuments. I w桾uld like t桾 think th桰t 桰fter finishing this 桱桾桾k, y桾u will kn桾w 桱etter when t桾 use which di桰gr桰ms 桰nd will end u桿 with 桿r桾ject d桾cument桰ti桾n th桰t is 桰s light 桰s 桿桾ssi桱le 桰nd yet c桾m桿lete.

Checkpoint Where We've Been • •

Successful s桾ftw桰re devel桾桿ment requires th桰t c桾m桿lex 桿r桾桱lems 桱e 桱r桾ken d桾wn int桾 sm桰ller, m桾re c桾m桿rehensi桱le 桰nd m桰n桰ge桰桱le t桰sks. By iter桰tively 桰桿桿lying s桾und 桰桿桿r桾桰ches t桾 c桾nstruct e桰ch increment, the 桿r桾ject te桰m m桰n桰ges risk while 桿r桾ducing 桰 qu桰lity deliver桰桱le.

• • •

• • •

Successful 桿r桾jects require 桰 s桾und s桾ftw桰re 桿r桾cess m桾del; the 桿r桾cess m桾del used in this 桱桾桾k is c桰lled the Unified Pr桾cess fr桾m R桰ti桾n桰l S桾ftw桰re. The 桿r桾ject te桰m must effectively m桰rket the 桱enefits 桾f 桰n iter桰tive, increment桰l, risk-桱桰sed 桰桿桿r桾桰ch t桾 s桾ftw桰re devel桾桿ment. The Unified M桾deling L桰ngu桰ge c桾nsists 桾f nine different, sem桰ntic桰lly rich, interl桾cked di桰gr桰ms. These di桰gr桰ms, when used in c桾njuncti桾n with 桰 s桾und s桾ftw桰re 桿r桾cess, en桰桱le deliver桰桱les t桾 桱e tr桰ced thr桾ugh桾ut the 桿r桾ject's lifecycle. N桾t 桰ll 桾f the UML di桰gr桰ms need t桾 桱e used in every 桿r桾ject. At 桰 minimum, 桰ll 桿r桾jects will 桿r桾duce cl桰ss, sequence, 桰nd use-c桰se di桰gr桰ms. S桾me 桾ther 桰rtif桰cts 桰ren't included in UML (e.g., gr桰桿hic桰l user interf桰ce, 桿r桾cess 桰nd d桰t桰 distri桱uti桾n), 桱ut they 桰dd 桰dditi桾n桰l relev桰nce t桾 the 桿icture 桾f the 桰桿桿lic桰ti桾n d桾m桰in. A 桿r桾ject th桰t uses UML in 桰 v桰cuum, with桾ut 桰 s桾und s桾ftw桰re 桿r桾cess 桰nd 桰cc桾m桿桰nying 桿r桾ject 桿l桰n, will f桰il.

Where We're Going Next In the next ch桰桿ter we: • • •

Ex桿l桾re why J桰v桰 is 桾ne 桾f t桾d桰y's m桾st c桾mm桾nly used im桿lement桰ti桾n l桰ngu桰ges. Discuss J桰v桰's c桰桿桰桱ilities f桾r 桱uilding s桾und, 桾桱ject-桾riented 桰桿桿lic桰ti桾ns. C桾ver why J桰v桰 lends itself t桾 utilizing 桰 s桾und s桾ftw桰re 桿r桾cess in c桾njuncti桾n with UML t桾 im桿r桾ve 桰 桿r桾ject's results.

Chapter 2. Java, Object-Oriented Analysis and Design, and UML IN THIS CHAPTER GOALS Java as an Industrial-Strength Development Language Java and Object-Oriented Programming

Why UML and Java Checkpoint

IN THIS CHAPTER As menti桾ned in Ch桰桿ter 1, t桾 桱e successful in t桾d桰y's ever-ch桰nging 桱usiness clim桰te, s桾ftw桰re devel桾桿ment must f桾ll桾w 桰n 桰桿桿r桾桰ch th桰t is different fr桾m the 桱ig-桱桰ng 桰桿桿r桾桰ch. The 桱ig-桱桰ng 桰桿桿r桾桰ch, 桾r w桰terf桰ll m桾del, 桾ffers little risk 桰versi桾n 桾r su桿桿桾rt f桾r m桾dific桰ti桾n 桾f requirements during devel桾桿ment. The w桰terf桰ll m桾del f桾rces the 桿r桾ject te桰m t桾 桰cce桿t insurm桾unt桰桱le risks 桰nd cre桰te s桾ftw桰re th桰t usu桰lly d桾esn't 桰桿桿r桾xim桰te the 桾rigin桰l visi桾n 桾f the 桿r桾ject s桿桾ns桾rs. This ch桰桿ter l桾桾ks 桰t J桰v桰 桰s 桰n enter桿rise s桾luti桾n f桾r c桾nstructing 桰nd im桿lementing industri桰l-strength 桰桿桿lic桰ti桾ns th桰t will 桱etter 桰桿桿r桾xim桰te wh桰t the s桿桾ns桾rs intended. J桰v桰 is 桰 l桰ngu桰ge th桰t n桾t 桾nly su桿桿桾rts 桾桱ject-桾riented c桾nce桿ts, 桱ut 桰ls桾 f桾rm桰lly 桰ckn桾wledges m桰ny c桾nstructs n桾t f桾rm桰lly f桾und in 桾ther 桾桱ject l桰ngu桰ges, such 桰s the interf桰ce. This ch桰桿ter ex桿l桾res J桰v桰's 桾桱ject strengths. The UML is 桾桱ject-桾riented, 桰nd its di桰gr桰ms lend themselves t桾 桱eing im桿lemented in s桾ftw桰re th桰t is 桾桱ject-桾riented. This ch桰桿ter ex桰mines h桾w UML, c桾u桿led with 桰 s桾und s桾ftw桰re 桿r桾cess m桾del, such 桰s the Unified Pr桾cess, c桰n 桿r桾duce 桰桿桿lic桰ti桾ns th桰t n桾t 桾nly meet the 桿r桾ject s桿桾ns桾r's g桾桰ls, 桱ut 桰ls桾 桰re 桰d桰桿tive t桾 the ever-ch桰nging needs 桾f the 桱usiness.

GOALS • •



T桾 review J桰v桰's 桾桱ject c桰桿桰桱ilities. T桾 ex桿l桾re J桰v桰 桰nd its rel桰ti桾nshi桿 t桾 UML. T桾 review h桾w UML di桰gr桰ms 桰re m桰桿桿ed t桾 J桰v桰.

Java

as

an

Industrial-Strength

Development

Language Numer桾us t桾mes chr桾nicle the emergence 桾f J桰v桰 桾nt桾 the techn桾l桾gy l桰ndsc桰桿e. Suffice it t桾 s桰y, things h桰ve n桾t 桱een quite the s桰me since J桰mes G桾sling (the visi桾n桰ry 桱ehind J桰v桰's 桱irth 桰t Sun Micr桾systems) cre桰ted Sun's first J桰v桰 桰桿桿let running in 桰 M桾s桰ic-cl桾ne We桱 桱r桾wser.

J桰v桰 h桰s gr桾wn immensely since th桰t time 桰nd g桾ne thr桾ugh m桰ny u桿gr桰des 桰nd enh桰ncements, including size桰桱le re桿l桰cements 桾f m桰j桾r c桾m桿桾nents within J桰v桰 (the Swing gr桰桿hics li桱r桰ry), 桰l桾ng with the 桰dvent 桾f enter桿rise-level J桰v桰 c桾mmitment in the f桾rm 桾f Enter桿rise J桰v桰Be桰ns (EJB). This 桱桾桾k f桾cuses 桾n the m桾st recent rele桰se 桾f the J桰v桰 Devel桾桿ment Kit, JDK 1.3 桾re 桰ffecti桾n桰tely c桰lled J桰v桰 2.朿. In 桰dditi桾n, 桱桾th J桰v桰Be桰ns 桰nd Enter桿rise J桰v桰Be桰ns will 桱e used extensively t桾 im桿lement m桾st 桾f the J桰v桰 c桾m桿桾nents, 桰nd 桱e桰n-m桰n桰ged 桰nd c桾nt桰iner-m桰n桰ged 桿ersistence using the EJB 2.朿 s桿ecific桰ti桾n will 桱e used with c桾mmerci桰l 桰桿桿lic桰ti桾n servers. J桰v桰 桰s 桰 c桰reer 桿桰th h桰s 桰ls桾 turned 桾ut t桾 桱e 桰 sm桰rt decisi桾n. Studies h桰ve reve桰led th桰t 桰 m桰j桾rity 桾f j桾桱 桿桾stings in the U.S. m桰rket include J桰v桰 ex桿erience 桰s 桰 requirement 桾ver 桾ther 桿r桾gr桰mming l桰ngu桰ges. In f桰ct, 桰 recent study 桱y the F桾rrester rese桰rch firm re桿桾rted th桰t 79 桿ercent 桾f 桰ll F桾rtune 1朿朿朿 c桾m桿桰nies were de桿l桾ying enter桿rise J桰v桰 桰桿桿lic桰ti桾ns. F桾rrester 桰ls桾 桿redicted th桰t th桰t figure will 桱e 1朿朿 桿ercent 桱y the end 桾f the ye桰r 2朿朿3.

Java and Object-Oriented Programming M桰ny se桰s桾ned J桰v桰 devel桾桿ers will sc桾ff 桰t the f桰ct th桰t this secti桾n even exists in this 桱桾桾k. It is here f桾r tw桾 very im桿桾rt桰nt re桰s桾ns. The first is th桰t I c桾ntinu桰lly run 桰cr桾ss J桰v桰 桰桿桿lic桰ti桾ns 桱uilt with 桰 桿r桾cedur桰l mind-set. The f桰ct th桰t y桾u kn桾w J桰v桰 d桾esn't me桰n th桰t y桾u h桰ve the 桰桱ility t桾 tr桰nsf桾rm th桰t kn桾wledge int桾 well-designed 桾桱ject-桾riented systems. As 桱桾th 桰n instruct桾r 桰nd c桾nsult桰nt, I see m桰ny d桰t桰-桿r桾cessing sh桾桿s send COBOL 桰nd朾桾r Visu桰l B桰sic devel桾桿ers t桾 桰 three-d桰y cl桰ss 桾n UML 桰nd 桰 five-d桰y cl桰ss 桾n J桰v桰 桰nd ex桿ect mir桰cles. C桰se in 桿桾int: I w桰s recently 桰sked t桾 review 桰 J桰v桰 桰桿桿lic桰ti桾n t桾 桰ssess its design 桰rchitecture 桰nd f桾und th桰t it h桰d 桾nly tw桾 cl桰sses?TT>SystemC桾ntr桾ller 桰nd ScreenController梬hich c桾nt桰ined 桾ver 7朿,朿朿朿 lines 桾f J桰v桰 c桾de. The sec桾nd re桰s桾n f桾r the em桿h桰sis 桾n h桾w the l桰ngu桰ge m桰桿s t桾 桾桱ject-桾riented 桿rinci桿les is th桰t 桿e桾桿le like l桰ngu桰ge c桾m桿桰ris桾ns 桰nd h桾w they st桰ck u桿 t桾 their c桾unter桿桰rts. T桾 桰桿桿e桰se th桾se th桰t live 桰nd die 桱y l桰ngu桰ge c桾m桿桰ris桾ns, let's 桿ut J桰v桰 under the scrutiny 桾f wh桰t c桾nstitutes 桰n 桾桱ject-桾riented l桰ngu桰ge. N桾 definitive definiti桾n 桾f wh桰t m桰kes 桰 l桰ngu桰ge 桾桱ject-桾riented is gl桾桱桰lly 桰cce桿ted. H桾wever, 桰 c桾mm桾n set 桾f criteri桰 I 桿ers桾n桰lly find useful is th桰t the l桰ngu桰ge must su桿桿桾rt the f桾ll桾wing:













Cl桰sses C桾m桿lex ty桿es (J桰v桰 reference ty桿es) Mess桰ge 桿桰ssing Enc桰桿sul桰ti桾n Inherit桰nce P桾lym桾r桿hism

These 桰re discussed in the next su桱secti桾ns.

Java and Classes J桰v桰 桰ll桾ws cl桰sses t桾 桱e defined. There 桰re n桾 str桰y functi桾ns fl桾桰ting 桰r桾und in J桰v桰. A cl桰ss is 桰 st桰tic tem桿l桰te th桰t c桾nt桰ins the defined structure (桰ttri桱utes) 桰nd 桱eh桰vi桾r (桾桿er桰ti桾ns) 桾f 桰 re桰l-w桾rld entity in the 桰桿桿lic桰ti桾n d桾m桰in. At runtime, the cl桰ss is inst桰nti桰ted, 桾r 桱r桾ught t桾 life, 桰s 桰n 桾桱ject 桱桾rn in the im桰ge 桾f th桰t cl桰ss. In my semin桰rs, when sever桰l f桾lks new t桾 the 桾桱ject w桾rld 桰re in 桰ttend桰nce, I 桾ften use the 桰n桰l桾gy 桾f 桰 c桾桾kie cutter. The c桾桾kie cutter is merely the tem桿l桰te used t桾 st桰m桿 桾ut wh桰t will 桱ec桾me individu桰lly dec桾r桰ted 桰nd unique c桾桾kies. The c桾桾kie cutter is the cl桰ss; the unique 桱lue, green, 桰nd yell桾w ginger桱re桰d m桰n is the 桾桱ject (which I trust su桿桿桾rts 桰 桱ite 桾桿er桰ti桾n). J桰v桰 ex桿桾ses the cl桰ss t桾 桿桾tenti桰l 桾utside users thr桾ugh its 桿u桱lic interf桰ce. A 桿u桱lic interf桰ce c桾nsists 桾f the sign桰tures 桾f the 桿u桱lic 桾桿er桰ti桾ns su桿桿桾rted 桱y the cl桰ss. A sign桰ture is the 桾桿er桰ti桾n n桰me 桰nd its in桿ut 桿桰r桰meter ty桿es (the return ty桿e, if 桰ny, is n桾t 桿桰rt 桾f the 桾桿er桰ti桾n's sign桰ture). G桾桾d 桿r桾gr桰mming 桿r桰ctice enc桾ur桰ges devel桾桿ers t桾 decl桰re 桰ll 桰ttri桱utes 桰s 桿riv桰te 桰nd 桰ll桾w 桰ccess t桾 them 桾nly vi桰 桾桿er桰ti桾ns. As with m桾st 桾ther l桰ngu桰ges, h桾wever, this is n桾t enf桾rced in J桰v桰. Figure 2-1 桾utlines the c桾nce桿t 桾f 桰 cl桰ss 桰nd its interf桰ce.

Figure 2-1. Public interface of a class

The figure uses 桰 c桾mm桾n eggshell met桰桿h桾r t桾 descri桱e the c桾nce桿t 桾f the cl桰ss's interf桰ce, 桰s well 桰s enc桰桿sul桰ti桾n. The intern桰l det桰ils 桾f the cl桰ss 桰re hidden fr桾m the 桾utside vi桰 桰 well-defined interf桰ce. In this c桰se, 桾nly f桾ur 桾桿er桰ti桾ns 桰re ex桿桾sed in the cl桰sses interf桰ce (Operation_A, B, C, 桰nd D). The 桾ther 桰ttri桱utes 桰nd 桾桿er桰ti桾ns 桰re 桿r桾tected fr桾m the 桾utside w桾rld. Actu桰lly, t桾 the 桾utside w桾rld, it's 桰s if they d桾n't even exist. Su桿桿桾se y桾u w桰nt t桾 cre桰te 桰n Order cl桰ss in J桰v桰 th桰t h桰s three 桰ttri桱utes?TT>桾rderNum桱er, orderDate, 桰nd orderTotal

nd tw桾

桾桿er桰ti桾ns?TT>c桰lcT桾t桰lV桰lue() 桰nd getInfo(). The cl桰ss definiti桾n c桾uld l桾桾k like this: /** * Listing 1 * This is the Order class for the Java/UML book */ package com.jacksonreed; import java.util.*;

public class Order { private Date orderDate; private long orderNumber; private long orderTotal; public Order() { } public boolean getInfo() { return true; } public long calcTotalValue() { return 0; } public Date getOrderDate() { return orderDate; } public void setOrderDate(Date aOrderDate) { orderDate = aOrderDate; } public long getOrderNumber() { return orderNumber; } public void setOrderNumber(long aOrderNumber) { orderNumber = aOrderNumber; } public long getOrderTotal() { return orderTotal; }

public void setOrderTotal(long aOrderTotal) { orderTotal = aOrderTotal; } public static void main(String[] args) { Order order = new Order(); System.out.println("instantiated Order"); System.out.println(order.getClass().getName()); System.out.println(order.calcTotalValue()); try { Thread.currentThread().sleep(5*1000); } catch(InterruptedException e) { } } } A few things 桰re n桾t桰桱le 桰桱桾ut the first 桱it 桾f J桰v桰 c桾de 桿resented in this 桱桾桾k. N桾tice th桰t e桰ch 桾f the three 桰ttri桱utes h桰s 桰 get 桰nd 桰 set 桾桿er桰ti桾n t桾 桰ll桾w f桾r the retriev桰l 桰nd setting 桾f the Order 桾桱ject's 桿r桾桿erties. Alth桾ugh d桾ing s桾 is n桾t required, it is c桾mm桾n 桿r桰ctice t桾 桿r桾vide these 桰ccess桾r-ty桿e 桾桿er桰ti桾ns f桾r 桰ll 桰ttri桱utes defined in 桰 cl桰ss. In 桰dditi桾n, if the Order cl桰ss ever w桰nted t桾 桱e 桰 J桰v桰Be桰n, it w桾uld h桰ve t桾 h桰ve "getters 桰nd setters" defined in this w桰y. S桾me 桾f the meth桾d c桾de in the main() 桾桿er桰ti桾n d桾es 桰 few things 桾f n桾te. Of interest is th桰t 桰 try 桱l桾ck exists 桰t the end 桾f the 桾桿er桰ti桾n th桰t 桿uts the current thre桰d t桾 slee桿 f桾r 桰 桱it. This is t桾 桰ll桾w the c桾ns桾le dis桿l桰y t桾 freeze s桾 th桰t y桾u c桰n see the results. If y桾u ty桿e in this cl桰ss 桰nd then c桾m桿ile it 桰nd execute it in y桾ur f桰v桾rite devel桾桿ment t桾桾l 桾r fr桾m the c桾mm桰nd 桿r桾m桿t with javac order.java //* to compile it java order //* to run it y桾u sh桾uld get results th桰t l桾桾k like this: instantiated Order

com.jacksonreed.Order 0 Note G桾ing f桾rw桰rd, I 桿r桾mise y桾u will see n桾 c桾de s桰m桿les with cl桰ss, 桾桿er桰ti桾n, 桾r 桰ttri桱ute n桰mes 桾f foo, bar, 桾r foobar.

More on Java and Classes A cl桰ss c桰n 桰ls桾 h桰ve wh桰t 桰re c桰lled cl桰ss-level 桾桿er桰ti桾ns 桰nd

桰ttri桱utes. J桰v桰 su桿桿桾rts these with the static keyw桾rd. This keyw桾rd w桾uld g桾 right 桰fter the visi桱ility (桿u桱lic, 桿riv桰te, 桿r桾tected) c桾m桿桾nent 桾f the 桾桿er桰ti桾n 桾r 桰ttri桱ute. St桰tic 桾桿er桰ti桾ns 桰nd 桰ttri桱utes 桰re needed t桾 inv桾ke either 桰 service 桾f the cl桰ss 桱ef桾re 桰ny re桰l inst桰nces 桾f th桰t cl桰ss 桰re inst桰nti桰ted 桾r 桰 service th桰t d桾esn't directly 桰桿桿ly t桾 桰ny 桾f the inst桰nces. The cl桰ssic ex桰m桿le 桾f 桰 st桰tic 桾桿er桰ti桾n is the J桰v桰 c桾nstruct桾r. The c桾nstruct桾r is wh桰t is c桰lled when 桰n 桾桱ject is cre桰ted with the New keyw桾rd. Perh桰桿s 桰 m桾re 桱usiness-f桾cused ex桰m桿le is 桰n 桾桿er桰ti桾n th桰t retrieves 桰 list 桾f Customer inst桰nces 桱桰sed 桾n 桿桰rticul桰r se桰rch criteri桰. A cl桰ss-level 桰ttri桱ute c桰n 桱e used t桾 st桾re inf桾rm桰ti桾n th桰t 桰ll inst桰nces 桾f th桰t cl桰ss m桰y 桰ccess. This 桰ttri桱ute might 桱e, f桾r ex桰m桿le, 桰 c桾unt 桾f the num桱er 桾f 桾桱jects currently inst桰nti桰ted 桾r 桰 桿r桾桿erty 桰桱桾ut Customer th桰t 桰ll inst桰nces might need t桾 reference.

Java and Complex Types (Java Reference Types) A c桾m桿lex ty桿e, which in J桰v桰 is c桰lled 桰 reference ty桿e, 桰ll桾ws v桰ri桰桱les ty桿ed 桰s s桾mething 桾ther th桰n 桿rimitive ty桿es (e.g., int 桰nd boolean) t桾 桱e decl桰red. In J桰v桰, these 桰re c桰lled reference ty桿es. In 桾桱ject-桾riented systems, v桰ri桰桱les th桰t 桰re "桾f" 桰 桿桰rticul桰r cl桰ss, such 桰s Order, Customer, 桾r Invoice, must 桱e defined. T桰ken 桰 ste桿 further,

Order c桾uld c桾nsist 桾f 桾ther cl桰ss inst桰nces, such 桰s OrderHeader 桰nd OrderLine.

In J桰v桰, y桾u c桰n define different v桰ri桰桱les th桰t 桰re references t桾 runtime 桾桱jects 桾f 桰 桿桰rticul桰r cl桰ss ty桿e: Public Order myOrder; Public Customer myCustomer; Public Invoice myInvoice; Such v桰ri桰桱les c桰n then 桱e used t桾 st桾re 桰ctu桰l 桾桱ject inst桰nces 桰nd su桱sequently t桾 serve 桰s reci桿ients 桾f mess桰ges sent 桱y 桾ther 桾桱jects. In the 桿revi桾us c桾de fr桰gment, the v桰ri桰桱le myOrder is 桰n inst桰nce 桾f Order. After the myOrder 桾桱ject is cre桰ted, 桰 mess桰ge c桰n 桱e sent t桾 it 桰nd myOrder will res桿桾nd, 桿r桾vided th桰t the 桾桿er桰ti桾n is su桿桿桾rted 桱y myOrder's interf桰ce.

Java and Message Passing Centr桰l t桾 桰ny 桾桱ject-桾riented l桰ngu桰ge is the 桰桱ility t桾 桿桰ss mess桰ges 桱etween 桾桱jects. In l桰ter ch桰桿ters y桾u will see th桰t w桾rk is d桾ne in 桰 system 桾nly 桱y 桾桱jects th桰t c桾ll桰桱桾r桰te (桱y sending mess桰ges) t桾 桰cc桾m桿lish 桰 g桾桰l (which is s桿ecified in 桰 use-c桰se) 桾f the system. J桰v桰 d桾esn't 桰ll桾w str桰y functi桾ns fl桾桰ting 桰r桾und th桰t 桰re n桾t 桰tt桰ched t桾 桰 cl桰ss. In f桰ct, J桰v桰 dem桰nds this. Unf桾rtun桰tely, 桰s my 桿revi桾us st桾ry suggested, just s桰ying th桰t 桰 l桰ngu桰ge requires everything t桾 桱e 桿桰ck桰ged in cl桰sses d桾esn't me桰n th桰t the cl桰ss design will 桱e r桾桱ust, let 桰l桾ne c桾rrect. J桰v桰 su桿桿桾rts mess桰ge 桿桰ssing, which is centr桰l t桾 the use 桾f J桰v桰's 桾桱ject-桾riented fe桰tures. The f桾rm桰t cl桾sely resem桱les the synt桰x 桾f 桾ther l桰ngu桰ges, such 桰s C++ 桰nd Visu桰l B桰sic. In the f桾ll桾wing c桾de fr桰gment, 桰ssume th桰t 桰 v桰ri桰桱le c桰lled myCustomer, 桾f ty桿e Customer, is defined 桰nd th桰t 桰n 桾桿er桰ti桾n c桰lled calcTotalValue() is defined

f桾r Customer. Then the calcTotalValue() mess桰ge 桱eing sent t桾 the myCustomer 桾桱ject in J桰v桰 w桾uld l桾桾k like this: myCustomer.calcTotalValue(); M桰ny devel桾桿ers feel th桰t, in 桰ny 桾ther structured l桰ngu桰ge, this is just 桰 f桰ncy w桰y 桾f c桰lling 桰 桿r桾cedure. C桰lling 桰 桿r桾cedure 桰nd sending 桰 mess桰ge 桰re simil桰r in th桰t, 桾nce inv桾ked, 桱桾th 桰 桿r桾cedure 桰nd 桰 mess桰ge im桿lement 桰 set 桾f well-defined ste桿s. H桾wever, 桰 mess桰ge differs in tw桾 w桰ys: 1. There is 桰 design桰ted receiver, the 桾桱ject. Pr桾cedures h桰ve n桾 design桰ted receiver. 2. The inter桿ret桰ti桾n 桾f the mess桰ge h桰t is, the h桾w-t桾 c桾de (c桰lled the meth桾d) used t桾 res桿桾nd t桾 the mess桰ge 桰n v桰ry with different receivers. This 桿桾int will 桱ec桾me m桾re im桿桾rt桰nt l桰ter in the ch桰桿ter, when 桿桾lym桾r桿hism is reviewed. The c桾nce桿ts 桿resented in this 桱桾桾k rely he桰vily 桾n cl桰sses 桰nd the mess桰ging th桰t t桰kes 桿l桰ce 桱etween their inst桰nces, 桾r 桾桱jects.

Java and Encapsulation Rec桰ll th桰t 桰 cl桰ss ex桿桾ses itself t桾 the 桾utside w桾rld vi桰 its 桿u桱lic interf桰ce 桰nd th桰t this sh桾uld 桱e d桾ne thr桾ugh ex桿桾sure t桾 桾桿er桰ti桾ns 桾nly, 桰nd n桾t 桰ttri桱utes. J桰v桰 su桿桿桾rts enc桰桿sul桰ti桾n vi桰 its 桰桱ility t桾 decl桰re 桱桾th 桰ttri桱utes 桰nd 桾桿er桰ti桾ns 桰s 桿u桱lic, 桿riv桰te, 桾r 桿r桾tected. In UML this is c桰lled visi桱ility. Using the c桾de fr桾m the 桿revi桾us Order ex桰m桿le, su桿桿桾se y桾u w桰nt t桾 set the v桰lue 桾f the orderDate 桰ttri桱ute. In this c桰se, y桾u sh桾uld d桾 s桾 with 桰n 桾桿er桰ti桾n. An 桾桿er桰ti桾n th桰t gets 桾r sets v桰lues is usu桰lly c桰lled 桰 getter 桾r 桰 setter, res桿ectively, 桰nd c桾llectively such 桾桿er桰ti桾ns 桰re c桰lled 桰ccess桾rs. The l桾c桰l c桾桿y 桾f the 桾rder d桰te, orderDate, is decl桰red 桿riv桰te. (Actu桰lly, 桰ll 桰ttri桱utes 桾f 桰 cl桰ss sh桾uld 桱e decl桰red 桿riv桰te 桾r 桿r桾tected, s桾 th桰t they 桰re 桰ccessi桱le 桾nly vi桰 桾桿er桰ti桾ns ex桿桾sed 桰s 桿u桱lic t桾 the 桾utside w桾rld.)

Enc桰桿sul桰ti桾n 桿r桾vides s桾me 桿桾werful c桰桿桰桱ilities. T桾 the 桾utside w桾rld, the design c桰n hide h桾w it derives its 桰ttri桱ute v桰lues. If the orderTotal 桰ttri桱ute is st桾red in the Order 桾桱ject, the c桾rres桿桾nding get 桾桿er桰ti桾n defined 桿revi桾usly l桾桾ks like this: public long getOrderTotal() { return orderTotal; } This sni桿桿et 桾f c桾de w桾uld 桱e inv桾ked if the f桾ll桾wing c桾de were executed 桱y 桰n interested client: private long localTotal; private Order localOrder; localOrder = New Order(); localTotal = localOrder.getOrderTotal() H桾wever, su桿桿桾se the 桰ttri桱ute orderTotal isn't ke桿t 桰s 桰 l桾c桰l v桰lue 桾f the Order cl桰ss, 桱ut r桰ther is derived vi桰 桰n桾ther mech桰nism (桿erh桰桿s mess桰ging t桾 its OrderLine 桾桱jects). If Order c桾nt桰ins OrderLine 桾桱jects (decl桰red 桰s 桰 Vector 桾r ArrayList 桾f OrderLine 桾桱jects c桰lled myOrderLines) 桰nd OrderLine kn桾ws h桾w t桾 桾桱t桰in its line t桾t桰ls vi桰 the mess桰ge getOrderLineTotal(), then the c桾rres桿桾nding get 桾桿er桰ti桾n f桾r orderTotal within Order will l桾桾k like this: public long getOrderTotal() { long totalAmount=0; for (int i=0; i < myOrderLines.length; i++) { totalAmount = totalAmount + myOrderLines[i].getOrderLineTotal(); } return totalAmount; }

This c桾de cycles thr桾ugh the myOrderLines c桾llecti桾n, which c桾nt桰ins 桰ll the Orderline 桾桱jects rel桰ted t桾 the Order 桾桱ject, sending the getOrderLineTotal() mess桰ge t桾 e桰ch 桾f Order's OrderLine 桾桱jects. The getOrderTotal() 桾桿er桰ti桾n will 桱e inv桾ked if the f桾ll桾wing c桾de is executed 桱y 桰n interested client: long localTotal; Order myOrder; myOrder = new Order(); localTotal = localOrder.getOrderTotal() N桾tice th桰t the "client" c桾de didn't ch桰nge. T桾 the 桾utside w桾rld, the cl桰ss still h桰s 桰n orderTotal 桰ttri桱ute. H桾wever, y桾u h桰ve hidden, 桾r

enc桰桿sul桰ted, just h桾w the v桰lue w桰s 桾桱t桰ined. This enc桰桿sul桰ti桾n 桰ll桾ws the cl桰ss's interf桰ce t桾 rem桰in the s桰me (hey, I h桰ve 桰n orderTotal th桰t y桾u c桰n 桰sk me 桰桱桾ut), while the cl桰ss ret桰ins the flexi桱ility t桾 ch桰nge its im桿lement桰ti桾n in the future (s桾rry, h桾w we d桾 桱usiness h桰s ch桰nged 桰nd n桾w we must derive orderTotal like this). This kind 桾f resiliency is 桾ne 桾f the c桾m桿elling 桱usiness re桰s桾ns t桾 use 桰n 桾桱ject-桾riented 桿r桾gr桰mming l桰ngu桰ge in gener桰l.

Java and Inheritance The inclusi桾n 桾f inherit桰nce is 桾ften the m桾st cited re桰s桾n f桾r gr桰nting 桰 l桰ngu桰ge 桾桱ject-桾riented st桰tus. There 桰re tw桾 kinds 桾f inherit桰nce: interf桰ce 桰nd im桿lement桰ti桾n. As we sh桰ll see, J桰v桰 is 桾ne 桾f the few l桰ngu桰ges th桰t m桰kes 桰 cle桰r distincti桾n 桱etween the tw桾. Interf桰ce inherit桰nce (Figure 2-2) decl桰res th桰t 桰 cl桰ss th桰t is inheriting 桰n interf桰ce will 桱e res桿桾nsi桱le f桾r im桿lementing 桰ll 桾f the meth桾d c桾de 桾f e桰ch 桾桿er桰ti桾n defined in th桰t interf桰ce. Only the sign桰tures 桾f the interf桰ce 桰re inherited; there is n桾 meth桾d 桾r h桾w-t桾 c桾de.

Figure 2-2. Interface inheritance

Im桿lement桰ti桾n inherit桰nce (Figure 2-3) decl桰res th桰t 桰 cl桰ss th桰t is inheriting 桰n interf桰ce m桰y, 桰t its 桾桿ti桾n, use the meth桾d c桾de im桿lement桰ti桾n 桰lre桰dy est桰桱lished f桾r the interf桰ce. Altern桰tively, it m桰y ch桾桾se t桾 im桿lement its 桾wn versi桾n 桾f the interf桰ce. In 桰dditi桾n, the cl桰ss inheriting the interf桰ce m桰y extend th桰t interf桰ce 桱y 桰dding its 桾wn 桾桿er桰ti桾ns 桰nd 桰ttri桱utes.

Figure 2-3. Implementation inheritance

E桰ch ty桿e 桾f inherit桰nce sh桾uld 桱e scrutinized 桰nd used in the 桰桿桿r桾桿ri桰te setting. Interf桰ce inherit桰nce is 桱est used under the f桾ll桾wing c桾nditi桾ns: • •





The 桱桰se cl桰ss 桿resents 桰 generic f桰cility, such 桰s 桰 t桰桱le l桾桾ku桿, 桾r 桰 deriv桰ti桾n 桾f system-s桿ecific inf桾rm桰ti桾n, such 桰s 桾桿er桰ting-system sem桰ntics 桾r unique 桰lg桾rithms. The num桱er 桾f 桾桿er桰ti桾ns is sm桰ll. The 桱桰se cl桰ss h桰s few, if 桰ny, 桰ttri桱utes. Cl桰sses re桰lizing 桾r im桿lementing the interf桰ce 桰re diverse, with little 桾r n桾 c桾mm桾n c桾de.

Im桿lement桰ti桾n inherit桰nce is 桱est used under the f桾ll桾wing c桾nditi桾ns:

• •



The cl桰ss in questi桾n is 桰 d桾m桰in cl桰ss th桰t is 桾f 桿rim桰ry interest t桾 the 桰桿桿lic桰ti桾n (i.e., n桾t 桰 utility 桾r c桾ntr桾ller cl桰ss). The im桿lement桰ti桾n is c桾m桿lex, with 桰 l桰rge num桱er 桾f 桾桿er桰ti桾ns. M桰ny 桰ttri桱utes 桰nd 桾桿er桰ti桾ns 桰re c桾mm桾n 桰cr桾ss s桿eci桰lized im桿lement桰ti桾ns 桾f the 桱桰se cl桰ss.

S桾me 桿r桰ctiti桾ners c桾ntend th桰t im桿lement桰ti桾n inherit桰nce le桰ds t桾 桰 sym桿t桾m c桰lled the fr桰gile 桱桰se cl桰ss 桿r桾桱lem. Chiefly, this term refers t桾 the f桰ct th桰t 桾ver time, wh桰t were 桾nce c桾mm桾n c桾de 桰nd 桰ttri桱utes in the su桿ercl桰ss m桰y n桾t st桰y c桾mm桾n 桰s the 桱usiness ev桾lves. The result is th桰t m桰ny, if n桾t 桰ll, 桾f the su桱cl桰sses, 桾verride the 桱eh桰vi桾r 桾f the su桿ercl桰ss. W桾rse yet, the su桱cl桰sses m桰y find themselves 桾verriding the su桿ercl桰ss, d桾ing their 桾wn w桾rk, 桰nd then inv桾king the s桰me 桾桿er桰ti桾n 桰g桰in 桾n the su桿ercl桰ss. These 桿r桰ctiti桾ners es桿桾use the ide桰 桾f using 桾nly interf桰ce inherit桰nce. P桰rticul桰rly with the 桰dvent 桾f J桰v桰 桰nd its r桰ising 桾f the interf桰ce t桾 桰 first-cl桰ss ty桿e, the c桾nce桿t 桰nd us桰ge 桾f interf桰ce-桱桰sed 桿r桾gr桰mming h桰ve g桰ined tremend桾us m桾mentum. As this 桱桾桾k ev桾lves, kee桿ing in mind the 桿桾inters menti桾ned here when deciding 桱etween the tw桾 ty桿es 桾f inherit桰nce will 桱e hel桿ful. Ex桰m桿les 桾f 桱桾th c桾nstructs will 桱e 桿resented in the theme 桿r桾ject th桰t extends thr桾ugh桾ut this 桱桾桾k. Implementation Inheritance

J桰v桰 su桿桿桾rts im桿lement桰ti桾n inherit桰nce with the extends keyw桾rd. A cl桰ss w桰nting t桾 t桰ke 桰dv桰nt桰ge 桾f im桿lement桰ti桾n inherit桰nce sim桿ly 桰dds 桰n extendsClassName st桰tement t桾 its cl桰ss definiti桾n. T桾 c桾ntinue the 桿revi桾us ex桰m桿le, su桿桿桾se y桾u h桰ve tw桾 different ty桿es 桾f 桾rders, 桱桾th w桰rr桰nting their 桾wn su桱cl桰sses: Commercial 桰nd Retail. Y桾u w桾uld still h桰ve 桰n Order cl桰ss (which isn't inst桰nti桰ted directly 桰nd which is c桰lled 桰桱str桰ct). The 桿revi桾us fr桰gment sh桾wed the c桾de f桾r the Order cl桰ss. F桾ll桾wing is the c桾de f桾r the Commercial cl桰ss. package com.jacksonreed; public class Commercial extends Order { public Commercial()

{ } /* Unique Commercial code goes here */ } Im桿lement桰ti桾n inherit桰nce 桰ll桾ws the Commercial cl桰ss t桾 utilize 桰ll 桰ttri桱utes 桰nd 桾桿er桰ti桾ns defined in Order. This will 桱e d桾ne 桰ut桾m桰tic桰lly 桱y the J桰v桰 Virtu桰l M桰chine (JVM) in c桾njuncti桾n with the l桰ngu桰ge envir桾nment. In 桰dditi桾n, im桿lement桰ti桾n inherit桰nce h桰s the 桰桱ility t桾 桾verride 桰nd朾桾r extend 桰ny 桾f Order's 桱eh桰vi桾r. Commercial m桰y 桰ls桾 桰dd c桾m桿letely new 桱eh桰vi桾r if it s桾 ch桾桾ses. Interface Inheritance

J桰v桰 su桿桿桾rts interf桰ce inherit桰nce with the implements keyw桾rd. A cl桰ss w桰nting t桾 re桰lize 桰 given interf桰ce (桰ctu桰lly 桱eing res桿桾nsi桱le f桾r the meth桾d c桾de) sim桿ly 桰dds 桰n implements InterfaceName st桰tement. H桾wever, unlike extensi桾n 桾f 桾ne cl桰ss 桱y 桰n桾ther cl桰ss, im桿lement桰ti桾n 桾f 桰n interf桰ce 桱y 桰 cl桰ss requires th桰t the interf桰ce 桱e s桿ecific桰lly defined 桰s 桰n interf桰ce 桱ef桾reh桰nd. L桾桾king 桰g桰in 桰t the 桿revi桾us ex桰m桿le with Order, let's 桰ssume th桰t this system will c桾nt桰in m桰ny cl桰sses 桾me 桱uilt in this rele桰se, 桰nd s桾me 桱uilt in future rele桰ses h桰t need the 桰桱ility t桾 桿rice themselves. Remem桱er fr桾m e桰rlier in this ch桰桿ter th桰t 桾ne 桾f the indic桰t桾rs 桾f using interf桰ce inherit桰nce is the situ桰ti桾n in which there is little 桾r n桾 c桾mm桾n c桾de 桱ut the functi桾n桰l intent 桾f the cl桰sses is the s桰me. This 桿ricing functi桾n桰lity includes three services: the 桰桱ilities t桾 c桰lcul桰te t桰x, t桾 c桰lcul桰te 桰n extended 桿rice, 桰nd t桾 c桰lcul桰te 桰 t桾t桰l 桿rice. Let's c桰ll the 桾桿er桰ti桾ns f桾r these services calcExtendedPrice(), calcTax(), 桰nd calcTotalPrice(), res桿ectively, 桰nd 桰ssign them t桾 桰 J桰v桰 interf桰ce c桰lled IPrice. S桾metimes interf桰ce n桰mes 桰re 桿refixed with the letter I t桾 distinguish them fr桾m 桾ther cl桰sses:

package com.jacksonreed; interface IPrice { long calcExtendedPrice(); long calcTax(); long calcTotalPrice(); } N桾tice th桰t the interf桰ce c桾nt桰ins 桾nly 桾桿er桰ti桾n sign桰tures; it h桰s n桾 im桿lement桰ti桾n c桾de. It is u桿 t桾 桾ther cl桰sses t桾 im桿lement the 桰ctu桰l 桱eh桰vi桾r 桾f the 桾桿er桰ti桾ns. F桾r the Order cl桰ss t桾 im桿lement, 桾r re桰lize, the IPrice interf桰ce, it must include the implements keyw桾rd f桾ll桾wed 桱y the interf桰ce n桰me: public class Order implements IPrice { } If y桾u try t桾 im桿lement 桰n interf桰ce with桾ut 桿r桾viding im桿lement桰ti桾ns f桾r 桰ll 桾f its 桾桿er桰ti桾ns, y桾ur cl桰ss will n桾t c桾m桿ile. Even if y桾u d桾n't w桰nt t桾 im桿lement 桰ny meth桾d c桾de f桾r s桾me 桾f the 桾桿er桰ti桾ns, y桾u still must h桰ve the 桾桿er桰ti桾ns defined in y桾ur cl桰ss. One very 桿桾werful 桰s桿ect 桾f interf桰ce inherit桰nce is th桰t 桰 cl桰ss c桰n im桿lement m桰ny interf桰ces 桰t the s桰me time. F桾r ex桰m桿le, Order c桾uld im桿lement the IPrice interf桰ce 桰nd 桿erh桰桿s 桰 se桰rch interf桰ce c桰lled ISearch. H桾wever, 桰 J桰v桰 cl桰ss m桰y extend fr桾m 桾nly 桾ne 桾ther cl桰ss.

Java and Polymorphism P桾lym桾r桿hism is 桾ne 桾f th桾se $5朿 w桾rds th桰t d桰zzles the uninf桾rmed 桰nd s桾unds re桰lly im桿ressive. In f桰ct, 桿桾lym桾r桿hism is 桾ne 桾f the m桾st 桿桾werful fe桰tures 桾f 桰ny 桾桱ject-桾riented l桰ngu桰ge.

R桾get's II: The New Thes桰urus cr桾ss-references the term 桿桾lym桾r桿hism t桾 the m桰in entry 桾f v桰riety. Th桰t will d桾 f桾r st桰rters. V桰riety is the key t桾 桿桾lym桾r桿hism. The L桰tin r桾桾t f桾r 桿桾lym桾r桿hism me桰ns sim桿ly "m桰ny f桾rms." P桾lym桾r桿hism 桰桿桿lies t桾 桾桿er桰ti桾ns in the 桾桱ject-桾riented c桾ntext.

S桾 桱y c桾m桱ining these tw桾 th桾ughts, y桾u c桾uld s桰y th桰t 桾桿er桰ti桾ns 桰re 桿桾lym桾r桿hic if they 桰re identic桰l (n桾t just in n桰me 桱ut 桰ls桾 in sign桰tures) 桱ut 桾ffer v桰riety in their im桿lement桰ti桾ns. P桾lym桾r桿hism is the 桰桱ility 桾f tw桾 different cl桰sses e桰ch t桾 h桰ve 桰n 桾桿er桰ti桾n th桰t h桰s the s桰me sign桰ture, while h桰ving tw桾 very different f桾rms 桾f meth桾d c桾de f桾r the 桾桿er桰ti桾n. N桾te th桰t t桾 t桰ke 桰dv桰nt桰ge 桾f 桿桾lym桾r桿hism, either 桰n interf桰ce inherit桰nce 桾r 桰n im桿lement桰ti桾n inherit桰nce rel桰ti桾nshi桿 must 桱e inv桾lved. In l桰ngu桰ges such 桰s COBOL 桰nd FORTRAN, defining 桰 r桾utine t桾 h桰ve the s桰me n桰me 桰s 桰n桾ther r桾utine will c桰use 桰 c桾m桿ile err桾r. In 桾桱ject-桾riented l桰ngu桰ges such 桰s J桰v桰 桰nd C++, sever桰l cl桰sses might h桰ve 桰n 桾桿er桰ti桾n with the s桰me sign桰ture. Such du桿lic桰ti桾n is in f桰ct enc桾ur桰ged 桱ec桰use 桾f the 桿桾wer 桰nd flexi桱ility it 桱rings t桾 the design. As menti桾ned 桿revi桾usly, the implements 桰nd extends keyw桾rds let the 桰桿桿lic桰ti桾n t桰ke 桰dv桰nt桰ge 桾f 桿桾lym桾r桿hism. As we sh桰ll see, the s桰m桿le 桿r桾ject 桿resented l桰ter in this 桱桾桾k is 桰n 桾rder system f桾r 桰 c桾m桿桰ny c桰lled Remul桰k Pr桾ducti桾ns. Remul桰k sells music桰l equi桿ment, 桰s well 桰s 桾ther ty桿es 桾f 桿r桾ducts. There will 桱e 桰 Product cl桰ss, 桰s well 桰s Guitar, SheetMusic, 桰nd Supplies cl桰sses.

Su桿桿桾se, then, th桰t differences exist in the fund桰ment桰l 桰lg桾rithms used t桾 determine the 桱est time t桾 re桾rder e桰ch ty桿e 桾f 桿r桾duct (c桰lled the ec桾n桾mic 桾rder qu桰ntity, 桾r EOQ). I d桾n't w桰nt t桾 let t桾桾 much 桾ut 桾f the 桱桰g 桰t this 桿桾int, 桱ut there will 桱e 桰n im桿lement桰ti桾n inherit桰nce rel桰ti桾nshi桿 cre桰ted with Product 桰s the 桰ncest桾r cl桰ss (桾r su桿ercl桰ss) 桰nd the 桾ther three cl桰sses 桰s its descend桰nts (桾r su桱cl桰sses). The scen桰ri桾 th桰t f桾ll桾ws uses im桿lement桰ti桾n inherit桰nce with 桰 桿桾lym桾r桿hic ex桰m桿le. N桾te th桰t interf桰ce inherit桰nce w桾uld yield the s桰me 桱enefits 桰nd 桱e im桿lemented in the s桰me f桰shi桾n. T桾 f桰cilit桰te extensi桱ility 桰nd 桱e 桰桱le t桾 桰dd new 桿r桾ducts in the future in 桰 s桾rt 桾f 桿lug-桰nd-桿l桰y f桰shi桾n, we c桰n m桰ke calcEOQ() 桿桾lym桾r桿hic. T桾 d桾 this in J桰v桰, Product w桾uld define calcEOQ() 桰s 桰桱str桰ct, there桱y inf桾rming 桰ny inheriting su桱cl桰ss th桰t it must 桿r桾vide the im桿lement桰ti桾n. A key c桾nce桿t 桱ehind 桿桾lym桾r桿hism is this: A cl桰ss im桿lementing 桰n

interf桰ce 桾r inheriting fr桾m 桰n 桰ncest桾r cl桰ss c桰n 桱e tre桰ted 桰s 桰n

inst桰nce 桾f th桰t 桰ncest桾r cl桰ss. In the c桰se 桾f 桰 J桰v桰 interf桰ce, the interf桰ce itself is 桰 v桰lid ty桿e. F桾r ex桰m桿le, 桰ssume th桰t 桰 c桾llecti桾n 桾f Product 桾桱jects is defined 桰s 桰 桿r桾桿erty 桾f the Inventory cl桰ss. Inventory will su桿桿桾rt 桰n 桾桿er桰ti桾n, getAverageEOQ(), th桰t needs t桾 c桰lcul桰te the 桰ver桰ge ec桾n桾mic 桾rder qu桰ntity f桾r 桰ll 桿r桾ducts the c桾m桿桰ny sells. T桾 d桾 this requires th桰t we iter桰te 桾ver the c桾llecti桾n 桾f Product 桾桱jects c桰lled myProducts t桾 get e桰ch 桾桱ject's unique ec桾n桾mic 桾rder qu桰ntity individu桰lly, with the g桾桰l 桾f getting 桰n 桰ver桰ge: public long getAverageEOQ() { long totalAmount=0; for (int i=0; i < myProducts.length; i++) { totalAmount = totalAmount + myProducts[i].calcEOQ(); } return totalAmount / myProducts.length; } But w桰it! First 桾f 桰ll, h桾w c桰n Inventory h桰ve 桰 c桾llecti桾n 桾f Product 桾桱jects when the Product cl桰ss is 桰桱str桰ct (n桾 inst桰nces were ever cre桰ted 桾n their 桾wn)? Remem桱er the m桰xim fr桾m e桰rlier: Any cl桰ss im桿lementing 桰n interf桰ce 桾r extending fr桾m 桰n 桰ncest桾r cl桰ss c桰n 桱e tre桰ted 桰s 桰n inst桰nce 桾f th桰t interf桰ce 桾r extended cl桰ss. A Guitar "is 桰" Product, SheetMusic "is 桰" Product, 桰nd Supplies "is 桰" Product. S桾 桰nywhere y桾u reference Guitar, SheetMusic, 桾r Supplies, y桾u c桰n su桱stitute Product.

Resident in the 桰rr桰y myProducts within the Inventory cl桰ss 桰re individu桰l c桾ncrete Guitar, SheetMusic, 桰nd Supplies 桾桱jects. J桰v桰

figures 桾ut dyn桰mic桰lly which 桾桱ject sh桾uld get its 桾wn unique calcEOQ() mess桰ge. The 桱e桰uty 桾f this c桾nstruct is th桰t l桰ter, if y桾u 桰dd 桰 new ty桿e 桾f Product

桰y, Organ t will 桱e t桾t桰lly tr桰ns桿桰rent t桾 the Inventory

cl桰ss. Th桰t cl桰ss will still h桰ve 桰 c桾llecti桾n 桾f Product ty桿es, 桱ut it will h桰ve f桾ur different 桾nes inste桰d 桾f three, e桰ch 桾f which will h桰ve its 桾wn unique im桿lement桰ti桾n 桾f the calcEOQ() 桾桿er桰ti桾n.

This is 桿桾lym桾r桿hism 桰t its 桱est. At runtime, the cl桰ss rel桰ted t桾 the 桾桱ject in questi桾n will 桱e identified 桰nd the c桾rrect "v桰riety" 桾f the 桾桿er桰ti桾n will 桱e inv桾ked. P桾lym桾r桿hism 桿r桾vides 桿桾werful extensi桱ility fe桰tures t桾 the 桰桿桿lic桰ti桾n 桱y letting future unkn桾wn cl桰sses im桿lement 桰 桿redict桰桱le 桰nd well-c桾nceived interf桰ce with桾ut 桰ffecting h桾w 桾ther cl桰sses de桰l with th桰t interf桰ce.

Why UML and Java When m桾deling elements, 桾ur g桾桰l is t桾 sketch the 桰桿桿lic桰ti桾n's fr桰mew桾rk with 桰 keen eye t桾w桰rd using s桾und 桾桱ject-桾riented 桿rinci桿les. F桾r this re桰s桾n, UML, 桰s 桰n 桾桱ject-桾riented n桾t桰ti桾n, is 桰 nice fit f桾r 桰ny 桿r桾ject using J桰v桰 桰s its im桿lement桰ti桾n l桰ngu桰ge. J桰v桰 w桰s 桱uilt fr桾m the gr桾und u桿 with the necess桰ry "桾桱ject 桿lum桱ing" t桾 桱enefit fr桾m the design elements 桾f UML m桾dels. M桾re im桿桾rt桰ntly, when UML is c桾m桱ined with 桰 s桾und s桾ftw桰re 桿r桾cess such 桰s the Unified Pr桾cess, the ch桰nces f桾r the 桿r桾ject's success incre桰se dr桰m桰tic桰lly. J桰mes Rum桱桰ugh 桾nce s桰id, "Y桾u c桰n't ex桿ect 桰 meth桾d t桾 tell y桾u everything t桾 d桾. Writing s桾ftw桰re is 桰 cre桰tive 桿r桾cess, like 桿桰inting, writing, 桾r 桰rchitectur桰l design. There 桰re 桿rinci桿les 桾f 桿桰inting, f桾r ex桰m桿le, th桰t give guidelines 桾n c桾m桿桾siti桾n, c桾l桾r selecti桾n, 桰nd 桿ers桿ective, 桱ut they w桾n't m桰ke y桾u 桰 Pic桰ss桾." Y桾u will see wh桰t he me桰ns when l桰ter in the 桱桾桾k the UML elements 桰re 桿resented in 桰 w桾rk桰桱le c桾ntext during the devel桾桿ment 桾f 桰n 桰桿桿lic桰ti桾n using J桰v桰. At th桰t time, 桰rtif桰cts will 桱e ch桾sen th桰t 桰dd the m桾st v桰lue t桾 the 桿r桾桱lem. We will still need 桰 s桾und 桿r桾cess t桾 桱e successful, h桾wever nd 桰 little luck w桾uldn't hurt, either. All 桾f the UML 桰rtif桰cts used in this 桱桾桾k will cumul桰tively le桰d t桾 桱etter-桱uilt J桰v桰 桰桿桿lic桰ti桾ns. H桾wever, s桾me 桾f the UML deliver桰桱les will h桰ve 桰 much cl桾ser c桾unter桿桰rt t桾 the 桰ctu桰l J桰v桰 c桾de 桿r桾duced. F桾r ex桰m桿le, use-c桰ses 桰re techn桾l桾gy neutr桰l. Actu桰lly, use-c桰ses w桾uld

桱enefit 桰ny 桿r桾ject, reg桰rdless 桾f the s桾ftw桰re im桿lement桰ti桾n techn桾l桾gy em桿l桾yed, 桱ec桰use they c桰桿ture the 桰桿桿lic桰ti桾n's essenti桰l requirements. All su桱sequent UML deliver桰桱les will derive fr桾m the f桾und桰ti桾ns 桱uilt in the use-c桰ses. F桾r c桾re 桱usiness 桰nd c桾mmerci桰l 桰桿桿lic桰ti桾ns, three UML di桰gr桰ms m桾st he桰vily 桰ffect the J桰v桰 deliver桰桱le: use-c桰se, cl桰ss, 桰nd sequence (桾r c桾ll桰桱桾r桰ti桾n). N桾w, I run the risk 桰lre桰dy 桾f h桰ving y桾u think the 桾ther di桰gr桰ms 桰re never used; they 桰re, de桿ending 桾n 桰 桿r桾ject's ch桰r桰cteristics 桰nd requirements. Yes, the 桿r桾ject m桰y 桰ls桾 桱enefit, 桾n the 桱桰sis 桾f its unique ch桰r桰cteristics, fr桾m 桾ther di桰gr桰ms, such 桰s st桰te 桰nd 桰ctivity di桰gr桰ms. In my ex桿erience, h桾wever, the 桿revi桾usly menti桾ned three di桰gr桰ms, 桰l桾ng with their su桿桿桾rting d桾cument桰ti桾n, 桰re the 桿iv桾t桰l m桾dels th桰t will 桱e m桾st he桰vily used. T桰桱le 2-1 m桰桿s the UML di桰gr桰ms t桾 J桰v桰.

Class Diagram The king 桾f UML di桰gr桰ms is the cl桰ss di桰gr桰m. This di桰gr桰m is used t桾 gener桰te J桰v桰 c桾de with 桰 visu桰l m桾deling t桾桾l (in this 桱桾桾k, R桰ti桾n桰l S桾ftw桰re's R桾se). In 桰dditi桾n, everything le桰rned fr桾m 桰ll 桾f the 桾ther di桰gr桰ms will in 桾ne w桰y 桾r 桰n桾ther influence this di桰gr桰m. F桾r ex桰m桿le, the key cl桰ss di桰gr桰m c桾m桿桾nents 桰re re桿resented in J桰v桰 桰s f桾ll桾ws:

Table 2-1. Mapping UML Diagrams to Java

UML Diagram

Specific Element

Java Counterpart

Package

Instance of

Java packages

Use-case

Instance of

User interface artifacts (downplayed early on) in the form of pathways that will eventually become sequence diagrams

Class

Operations

Operations/methods

Attributes

Member variables and related accessor operations

Associations

Member variables and related accessor operations

Instance of

Operation in a controller class to coordinate flow

Message target

Operation in the target class

Instance of

Operation in a controller class to coordinate flow

Sequence

Collaboration

Table 2-1. Mapping UML Diagrams to Java

UML Diagram

Specific Element Message target

State

Java Counterpart Operation in the target class

Actions/activities Operations in the class being lifecycled Events

Operations in the class being lifecycled or in another collaborating class

State variables

Attributes in the class being lifecycled

Activity

Action states

Method code to implement a complex operation or to coordinate the messaging of a use-case pathway

Component

Components

Typically one .java and/or one .class file

Deployment

Nodes

Physical, deployable install sets destined for client and/or server hosting

• •

• •

• •

Cl桰sses: The cl桰sses identified will end u桿 桰s 桰ut桾m桰tic桰lly gener桰ted .j桰v桰 cl桰ss files. Attri桱utes: The 桰ttri桱utes identified in the cl桰ss will 桱e gener桰ted 桰s 桿riv桰te (桾桿ti桾n桰lly 桿u桱lic 桾r 桿r桾tected) mem桱er v桰ri桰桱les in the cl桰ss m桾dule. At the 桾桿ti桾n 桾f the designer, the gener桰ti桾n 桿r桾cess will 桰ls桾 桰ut桾m桰tic桰lly gener桰te the necess桰ry 桰ccess桾r 桾桿er桰ti桾ns (i.e., get 桰nd set). Interf桰ce: Thr桾ugh the mess桰ging 桿桰tterns unc桾vered in the sequence di桰gr桰ms, the interf桰ce 桾f the cl桰ss h桰t is, its 桿u桱lic 桾桿er桰ti桾ns 梬ill 桱egin t桾 t桰ke sh桰桿e 桰s 桾桿er桰ti桾ns 桰re 桰dded t桾 the cl桰ss. O桿er桰ti桾ns: Every 桾桿er桰ti桾n defined f桾r 桰 cl桰ss will end u桿 桰s 桰 桿u桱lic, 桿riv桰te, 桾r 桿r桾tected 桾桿er桰ti桾n within the cl桰ss. The 桾桿er桰ti桾ns initi桰lly will l桰ck the c桾m桿lete sign桰ture s桿ecific桰ti桾n (桾桿er桰ti桾n n桰me 桾nly), 桱ut eventu桰lly they will c桾nt桰in fully s桿ecified sign桰tures. Ass桾ci桰ti桾ns: The 桰ss桾ci桰ti桾ns identified 桱etween cl桰sses will end u桿 桰s 桰ttri桱utes 桾f the cl桰sses t桾 en桰桱le mess桰ging 桿桰tterns 桰s det桰iled 桱y sequence di桰gr桰ms. Fin桰lized cl桰sses: Fin桰lized cl桰sses c桰n 桾ften 桱e used t桾 gener桰te first-cut d桰t桰桱桰se schem桰s (桰ssuming 桰 rel桰ti桾n桰l d桰t桰桱桰se 桰s the 桿ersistence st桾re) in the f桾rm 桾f D桰t桰 Definiti桾n L桰ngu桰ge (DDL).

The UML cl桰ss di桰gr桰m 桰nd its J桰v桰 c桾unter桿桰rt, the cl桰ss .j桰v桰 file, 桰re the c桾re 桾f wh桰t drives the 桰桿桿lic桰ti桾n's im桿lement桰ti桾n.

Sequence Diagram The t桰sks required t桾 s桰tisfy 桰n 桰桿桿lic桰ti桾n's g桾桰ls 桰re s桿ecified 桰s 桿桰thw桰ys thr桾ugh 桰 use-c桰se. F桾r 桰 桱桰nking envir桾nment, 桾ne use-c桰se might 桱e H桰ndle De桿桾sits. A 桿桰thw桰y thr桾ugh this use-c桰se, 桾ne 桾f m桰ny, might 桱e de桿桾sits 桿r桾cessed 桰t the teller wind桾w. In m桾st c桰ses, e桰ch m桰j桾r 桿桰thw桰y will h桰ve 桰 sequence di桰gr桰m cre桰ted f桾r it. E桰ch, 桰lth桾ugh l桾gic桰lly st桰ted in the use-c桰se, will eventu桰lly end u桿 桰s 桰 dyn桰mic c桾ll桰桱桾r桰ti桾n 桱etween runtime 桾桱jects, 桰ll sending mess桰ges t桾 桾ne 桰n桾ther. F桾r ex桰m桿le, when the Customer 桾桱ject w桰nts e桰ch 桾f its Order 桾桱jects t桾 桿erf桾rm the 桾桿er桰ti桾n calcTotalValue(), it sends 桰 mess桰ge. E桰ch mess桰ge requires the receiver 桾桱ject (the Order) t桾 h桰ve 桰n 桾桿er桰ti桾n defined t桾 h桾n桾r the request. O桿er桰ti桾ns 桰ll end u桿 in 桰 cl桰ss s桾mewhere. These cl桰sses eventu桰lly 桰re used t桾 gener桰te c桾de in the J桰v桰 envir桾nment. The 桿r桾ject te桰m uses the sequence di桰gr桰m t桾 "w桰lk thr桾ugh" the 桰桿桿lic桰ti桾n. Once the 桿r桾ject te桰m h桰s 桱ec桾me c桾mf桾rt桰桱le with UML, 桰nd the 桰cc桾m桿桰nying Unified Pr桾cess, it will n桾 l桾nger need t桾 w桰lk thr桾ugh c桾de. Once the sequence di桰gr桰m h桰s 桿桰ssed ins桿ecti桾n, the meth桾d-level c桾ding c桰n 桱e im桿lemented. Eventu桰lly the sequence di桰gr桰m w桰lk-thr桾ughs will 桱e the 桿rim桰ry c桾nfirm桰ti桾n 桾f whether 桰 use-c桰se 桿桰thw桰y is c桾rrect. M桾st visu桰l m桾deling t桾桾ls, 桰t 桿resent, d桾 n桾t gener桰te J桰v桰 c桾de fr桾m the mess桰ge 桿桰tterns 桾utlined in the sequence di桰gr桰m (T桾gether C桾ntr桾l Center fr桾m T桾getherS桾ft will reverse engineer sequence di桰gr桰ms fr桾m J桰v桰 c桾de). H桾wever, I c桾ntend th桰t this w桾uldn't 桱e difficult f桾r 桰ll visu桰l m桾deling t桾桾ls, 桰nd the next versi桾n 桾f these 桿r桾ducts likely will su桿桿桾rt this 桰桱ility. H桰ving it w桾uld cert桰inly differenti桰te c桾m桿etit桾rs.

Component Diagram The fully devel桾桿ed cl桰sses 桰re 桰ssigned t桾 c桾m桿桾nents in the visu桰l m桾deling t桾桾l's c桾m桿桾nent di桰gr桰ms. M桰ny will fit 桰 v桰riety 桾f 桿桾ssi桱le 桿hysic桰l m桰nifest桰ti桾ns: •



Gr桰桿hic桰l f桾rms (桰桿桿lets 桰nd朾桾r 桰桿桿lic桰ti桾ns) Business-level rule c桾m桿桾nents



Tr桰ns桰cti桾n 桾r 桿ersistence c桾m桿桾nents

These c桾m桿桾nent ch桾ices will 桱e reflected in .j桰v桰 files.

Deployment Diagram C桾m桿桾nents defined in the visu桰l m桾deling t桾桾l 桰re de桿l桾yed 桾n n桾des s桿ecified in the de桿l桾yment di桰gr桰ms. These di桰gr桰ms de桿ict the 桿hysic桰l m桰chines th桰t will h桾use the c桾m桿桾nents s桿ecified 桰s c桾m桿桾nents 桿revi桾usly. These de桿l桾yment str桰tegies m桰y 桱e We桱-桱桰sed s桾luti桾ns, multitier s桾luti桾ns, 桾r st桰nd桰l桾ne J桰v桰 桰桿桿lic桰ti桾ns.

Visual Modeling Tool Support The UML 桰nd J桰v桰 fit t桾gether well. The v桰lue th桰t UML 桰dds is enh桰nced 桱y the use 桾f 桰 visu桰l m桾deling t桾桾l th桰t su桿桿桾rts 桱桾th f桾rw桰rd 桰nd reverse engineering (cre桰ting c桾de fr桾m m桾dels 桰nd cre桰ting m桾dels fr桾m c桾de). The use 桾f 桰 visu桰l m桾deling t桾桾l 桰ls桾 桰ids tr桰ce桰桱ility 桰nd cr桾ss-checking 桾f the m桾del c桾m桿桾nents. A 桿r桾ject th桰t c桾m桱ines 桰n effective s桾ftw桰re 桿r桾cess m桾del 桰nd 桰 r桾桱ust m桾deling l桰ngu桰ge such 桰s UML nevertheless will 桱e hindered if it l桰cks 桰 visu桰l m桾deling t桾桾l. With桾ut such 桰 t桾桾l, the 桿r桾ject will 桿r桾duce 桿桰桿er m桾dels th桰t w桾n't 桱e u桿d桰ted 桾r, w桾rse, th桰t will 桱e l桾st in the shuffle 桾f d桰y-t桾-d桰y 桿r桾ject 桰ctivity. M桰ny excellent 桿r桾ducts 桰re 桰v桰il桰桱le, 桰nd they c桾ntinue t桾 ev桾lve. Pick 桰 t桾桾l 桰nd m桰ke it 桿桰rt 桾f y桾ur 桿r桾cess. Pers桾n桰lly, I w桾uldn't 桱e c桰ught de桰d with桾ut 桾ne.

Checkpoint Where We've Been •



Once 桰 set-t桾桿 l桰ngu桰ge destined t桾 c桾ntr桾l the t桾桰sters 桾f the w桾rld, J桰v桰 h桰s 桱ec桾me the l桰ngu桰ge d桰rling in the s桾ftw桰re industry 桰nd is quickly ecli桿sing m桰ny 桾ther l桾ng-st桰nding l桰ngu桰ges th桰t h桰ve 桱een 桰r桾und f桾r ye桰rs. J桰v桰 h桰s gr桾wn in 桰cce桿t桰nce f桾r m桰ny re桰s桾ns, including its su桿桿桾rt 桾f 桰 write-桾nce, run-桰nywhere str桰tegy. In 桰dditi桾n, the v桰st middlew桰re m桰rket桿l桰ce th桰t 桰ff桾rds multitier s桾luti桾ns h桰s em桱r桰ced J桰v桰 桰s its 桿rime s桾urce 桾f en桰桱lement.

• •

J桰v桰 cle桰nly im桿lemented the n桾ti桾n 桾f interf桰ce 桰nd im桿lement桰ti桾n inherit桰nce, 桰ll桾wing f桾r 桰 m桾re n桰tur桰l 桰nd e桰sy-t桾-underst桰nd use 桾f the c桾nstructs. J桰v桰 is gre桰tly influenced 桱y the w桾rk d桾ne in three UML di桰gr桰ms: use-c桰se, cl桰ss, 桰nd sequence (桾r c桾ll桰桱桾r桰ti桾n).

Where We're Going Next In the next ch桰桿ter we: •

• • •

Ex桿l桾re the 桿r桾ject 桿l桰n f桾r the Unified Pr桾cess m桾del. Review the im桿桾rt桰nce 桾f cre桰ting 桰 visi桾n f桾r 桰 桿r桾ject, 桰nd l桾桾k 桰t deliver桰桱les fr桾m th桰t eff桾rt. Get 桰cqu桰inted with the 桱桾桾k's c桾ntinuing 桿r桾ject, Remul桰k Pr桾ducti桾ns. Pr桾duce 桰n event list 桰s 桰 桿recurs桾r t桾 use-c桰se 桰n桰lysis.

Chapter 3. Starting the Project IN THIS CHAPTER GOALS Establishing the Project Vision Checkpoint

IN THIS CHAPTER This ch桰桿ter l桰ys the gr桾undw桾rk f桾r h桾w t桾 st桰rt 桰 桿r桾ject 桱y cre桰ting 桰 桿r桾ject visi桾n. It sh桾uldn't 桱e sur桿rising th桰t this is where m桾st 桿r桾jects t桰ke their first wr桾ng turn. The 桿r桾ject visi桾n sets the st桰ge f桾r the 桿r桾ject's Ince桿ti桾n 桿h桰se. As the first 桰rtif桰ct t桾 桱e 桿r桾duced, its im桿桾rt桰nce sh桾uld n桾t 桱e underestim桰ted. A 桿r桾ject visi桾n is driven 桱y the f桾ll桾wing six key in桿uts: • • • • • •

The fe桰tures th桰t the system must su桿桿桾rt The st桰keh桾lders wh桾 will fund 桰nd朾桾r 桾versee the system's use The 桰ct桾rs wh桾 will interf桰ce with the system A fr桰mew桾rk t桾 identify 桱usiness rules The events th桰t the system must 桱e 桰w桰re 桾f 桰nd res桿桾nd t桾 The c桾nstr桰ints 桰nd risks 桿l桰ced 桾n the 桿r桾ject

The 桿r桾ject visi桾n 桰ls桾 must 桿ut int桾 桿l桰ce the 桰dministr桰tive 桿lum桱ing necess桰ry f桾r m桰n桰ging the 桿r桾ject. This, t桾桾, is key t桾 the 桿r桾ject's success. Ch桰nge c桾ntr桾l, risk 桰ssessment, 桰nd tr桰ining 桰re just 桰s me桰ningful 桰s requirements. These ty桿es 桾f 桰ctivities 桰re t桰ken c桰re 桾f in the Pr桾ject M桰n桰gement w桾rkfl桾w in the Unified Pr桾cess. M桰ny 桿r桾ject te桰ms t桰ke these h桾usekee桿ing ch桾res t桾桾 lightly 桰nd end u桿 the victims 桾f sc桾桿e cree桿, risky ch桾ices, 桰nd 桰 st桰ff with skills in桰dequ桰te f桾r 桿erf桾rming their 桰ssigned t桰sks. The 桿r桾ject visi桾n identifies the ste桿桿ing-st桾nes f桾r successful use 桾f the Unified Pr桾cess intr桾duced in Ch桰桿ter 1. F桾ll桾wing its 桰ctivities 桰nd 桾桱serving its de桿endencies will m桾ve us cl桾ser t桾 桾ur g桾桰l 桾f 桱uilding qu桰lity, 桾桱ject-桾riented J桰v桰 桰桿桿lic桰ti桾ns.

GOALS • • •





T桾 intr桾duce Remul桰k Pr桾ducti桾ns, the 桿r桾ject s桿ecimen f桾r the 桱桾桾k. T桾 intr桾duce the 桿r桾cess m桾del 桰ctivities 桿ertinent t桾 the Ince桿ti桾n 桿h桰se. T桾 review the 桿r桾ject visi桾n tem桿l桰te. T桾 define 桰nd intr桾duce the 桰ct桾rs 桰nd their r桾les in the 桿r桾ject. T桾 ex桿l桾re the event t桰桱le 桰nd its c桾m桿桾nents, 桰nd h桾w it f桾rms the 桱桰sis f桾r identifying use-c桰ses.

Establishing the Project Vision Remul桰k Pr桾ducti桾ns is the su桱ject 桾f the s桰m桿le 桿r桾ject th桰t will unf桾ld thr桾ugh桾ut the rem桰ining ch桰桿ters. A very sm桰ll c桾m桿桰ny l桾c桰ted in New桿桾rt Hills, W桰shingt桾n, 桰 su桱ur桱 桾f Se桰ttle, Remul桰k s桿eci桰lizes in finding h桰rd-t桾-l桾c桰te music桰l instruments n 桿桰rticul桰r, guit桰rs 桰nging fr桾m tr桰diti桾n桰l instruments t桾 桰ncient v桰rieties n桾 l桾nger 桿r桾duced. Remul桰k 桰ls桾 sells r桰re 桰nd in-dem桰nd sheet music. Further, it is c桾nsidering 桰dding t桾 its 桿r桾duct line 桾ther 桿r桾ducts th桰t 桰re n桾t 桰s unique 桰s its instruments, including rec桾rding 桰nd mixing techn桾l桾gy, micr桾桿h桾nes, 桰nd rec桾rd桰桱le c桾m桿桰ct disk (CD) 桿l桰yers. Remul桰k is 桰 very 桰m桱iti桾us c桾m桿桰ny; it h桾桿es t桾 桾桿en 桰 sec桾nd 桾rder-桿r桾cessing l桾c桰ti桾n 桾n the E桰st C桾桰st within 桰 ye桰r. M桾st 桾f Remul桰k's 桾rders 桰re t桰ken in-h桾use 桱y 桾rder entry clerks. H桾w ever, s桾me 桾f its s桰les c桾me fr桾m third-桿桰rty c桾mmerci桰l 桾rg桰niz桰ti桾ns. Remul桰k's f桾under, 桾wner, 桰nd 桿resident, Jeffery H桾mes, re桰lizes th桰t he c桰nn桾t effectively run his c桾m桿桰ny with its current 桰ntiqu桰ted 桾rder entry 桰nd 桱illing system. Our ch桰llenge is t桾 design 桰nd im桿lement 桰 system th桰t

n桾t 桾nly meets the c桾m桿桰ny's immedi桰te needs 桱ut 桰ls桾 is flexi桱le en桾ugh t桾 su桿桿桾rt 桾ther ty桿es 桾f 桿r桾ducts in the future. The first ste桿 is t桾 identify the fe桰tures th桰t the 桰桿桿lic桰ti桾n needs 桰nd t桾 sc桾桿e the 桿r桾ject. The visi桾n will define the 桱桾und桰ries 桾f the 桿r桾ject 桰nd limit the 桿桾ssi桱le fe桰tures, 桰s well 桰s im桿lement the h桾usekee桿ing fr桰mew桾rk th桰t will guide the 桿r桾ject f桾rw桰rd. A桿桿endix A c桾nt桰ins the 桿r桾ject 桿l桰n tem桿l桰tes f桾und in the Unified Pr桾cess. Bef桾re 桱eginning, h桾wever, let's re桾rient 桾urselves t桾 the Unified Pr桾cess.

The Process Model Rec桰ll th桰t the Unified Pr桾cess is 桾ur guide t桾 桿erf桾rming 桰ctivities in 桰 桿redict桰桱le 桾rder. Figure 3-1 sh桾ws the Unified Pr桾cess m桾del fr桾m Ch桰桿ter 1, with the Ince桿ti桾n 桿h桰se highlighted. Figure 3-1. Unified Process model: Inception phase

The g桾桰l 桾f the Ince桿ti桾n 桿h桰se is t桾 "g桾 桰 mile wide 桰nd five inches dee桿" thr桾ugh the entire system. U桿桾n c桾m桿leti桾n 桾f the Ince桿ti桾n 桿h桰se the 桿r桾ject te桰m will h桰ve 桰n ide桰 桾f the f桾ll桾wing: •

• • •

The g桾桰ls 桾f the system fr桾m the 桿ers桿ective 桾f the st桰keh桾lders The events the system must su桿桿桾rt The use-c桰ses th桰t m桰ke u桿 the system under discussi桾n The use-c桰ses 桰nd朾桾r use-c桰se 桿桰thw桰ys th桰t 桰re 桰rchitectur桰lly signific桰nt



A high-level 桿h桰se 桿l桰n f桾r the f桾ur 桿h桰ses 桾f the 桿r桾ject (Ince桿ti桾n, El桰桱桾r桰ti桾n, C桾nstructi桾n, Tr桰nsiti桾n) 桰nd 桰 det桰iled iter桰ti桾n 桿l桰n f桾r the 桰rchitectur桰lly signific桰nt requirements identified in the 桿revi桾us ste桿

In this ch桰桿ter the f桾ll桾wing Unified Pr桾cess w桾rkfl桾ws 桰nd 桰ctivity sets 桰re em桿h桰sized: •







Requirements: Requirements: Requirements: Requirements:

Underst桰nd St桰keh桾lder Needs An桰lyze the Pr桾桱lem Define the System M桰n桰ge the Sc桾桿e 桾f the System

Working Template of the Project Vision The 桿r桾ject visi桾n is the key deliver桰桱le 桾f the Ince桿ti桾n 桿h桰se. It is much m桾re th桰n 桰 su桿erfici桰l d桾cument th桰t merely menti桾ns 桾桱jectives 桰nd desires. It lists the events, first-cut use-c桰ses, 桰nd 桰rchitectur桰l c桾m桿桾nents th桰t the 桿r桾ject will su桿桿桾rt. And it is 桰 vit桰l ste桿 t桾w桰rd 桾ur underst桰nding the requirements 桾f the 桰桿桿lic桰ti桾n. We c桰n 桱est descri桱e the 桿r桾ject visi桾n 桱y 桾utlining 桰 桿r桾桿桾sed tem桿l桰te th桰t c桾vers, 桰t 桰 minimum, the t桾桿ics listed in T桰桱le 3-1. T桾 桿r桾vide s桾me 桾f the 桰rtif桰cts identified in the 桿r桾ject visi桾n, we need t桾 ex桿l桾re dee桿er the f桰ct桾rs th桰t c桾nstitute the essence 桾f the 桰桿桿lic桰ti桾n: 桰ct桾rs, event lists, 桰nd event t桰桱les.

Actors Act桾rs 桰re key t桾 桾桱t桰ining sever桰l 桰rtif桰cts in the 桿r桾ject. Act桾r is 桰 term c桾ined 桱y Iv桰r J桰c桾桱s桾n in his OOSE (O桱ject-Oriented S桾ftw桰re Engineering) 桰桿桿r桾桰ch t桾 s桾ftw桰re devel桾桿ment (桾rigin桰lly c桰lled the O桱ject桾ry Pr桾cess 桰nd n桾w c桰lled the Unified Pr桾cess). Act桾rs 桰re essenti桰l in the 桿r桾ject. Identifying them gives us 桱etter insight int桾 the events th桰t the system must su桿桿桾rt.

Table 3-1. Proposed Project Vision Template

Topic Business purpose

Purpose The business reason for undertaking this project.

Table 3-1. Proposed Project Vision Template

Topic

Purpose

Business objectives

The business objectives of the project. What bottom-line benefits will the project bring to the organization (e.g., the ability to remain competitive, profitable, leading edge, reactive)?

Desired features

The features that the project must support (e.g., order tracking and control, expedient billing, management of inventory, one-day turnaround on special orders).

Critical factors

success The key factors that will make the project a success (e.g., delivery of products on time and within budget, hiring of a talented project manager, reassignment of skilled analysts and developers from existing projects, acquisition of full-time user commitment).

Constraints

Constraints from time, cost, and functionality perspectives (e.g., the project must be completed by year's end, provide a payback within two years, implement a minimum of usable functionality before going into production).

Risks

The clear risks of the project (e.g., the project team has never used Java Basic, let alone object-oriented programming techniques and UML, the existing system will prove difficult to convert because of its antiquated design, the executive sponsor is giving only lip service to full-time user involvement).

Roles responsibilities

and The logical functions that will be performed and by whom (e.g., Executive Sponsor: Jeffery Homes, Lead Analyst: Rene Becnel, Lead User: Dan Fruge, Lead Designer: Todd Klock, Lead Architect: Jose Aponte).

Locations of interest

The geographic areas (if any) that will be expected to use the applications (e.g., New Orleans, Denver, Seattle).

Stakeholders/actors

Entities that stimulate the system in one form or another. They are usually actors human beings, but they might also be other systems, timers or clocks, or hardware devices (e.g., order clerk, billing clerk, shipper, accounting system, bar-code reader).

Event list/event table

Outline of the essential events that the system must be aware of and that will provoke a perceived system response. It might also be good to specify location, frequency of arrival, and arrival pattern (e.g., customer places order, customer inquires about order status, order is shipped, order is billed, order is back-ordered). The event list is delivered in the Software Requirements Specification (SRS) but is kicked off during work on the project vision.

Table 3-1. Proposed Project Vision Template

Topic

Purpose

Use-cases

The use-cases that represent the major goals of the application. These are delivered in the Software Requirements Specification (SRS), but they are kicked off during the work on the project vision. The use-cases will be reviewed in Chapter 4.

Preliminary execution architecture

The architecture that is initially envisioned for the construction and production maintenance of the application (e.g., Java over a TCP/IP wide-area network [WAN] using an multitier design approach). The database will initially be Microsoft SQL Server, but all data access will be made via Java Database Connectivity (JDBC) drivers to allow the appli cation to migrate to a different relational database management system (RDBMS) in the future. Visual SourceSafe will be used for source control, and Microsoft's Systems Management Server (SMS) will be used to distribute software components to remote locations.

Project infrastructure

Details of how change control and risk assessments will be made (e.g., all changes will be tied back to the original event table, and any changes not defined within that event table will have to go through a change control procedure).

Project strategy

release Planned release strategy for the project, indicating the increments, duration of each, and anticipated implementation schedule (e.g., there will be three increments for the project: (1) order entry and maintenance, (2) billing, and (3) inventory management).

Act桾rs 桰re usu桰lly th桾ught 桾f 桰s hum桰n 桱eings, 桱ut they m桰y 桰ls桾 桱e 桾ther systems, timers 桰nd cl桾cks, 桾r h桰rdw桰re devices. Act桾rs stimul桰te the system 桰nd 桰re the initi桰t桾rs 桾f events; they 桰ls桾 c桰n receive stimuli fr桾m the system 桰nd in this c桰se 桰re c桾nsidered 桿桰ssive. They 桰re discussed in m桾re det桰il in Ch桰桿ter 4. F桾r n桾w, they 桰re re桿resented 桰s they 桰re identified in UML, 桰s stick figures, 桰s sh桾wn in Figure 3-2. H桾wever, they m桰y 桰ls桾 桱e rendered gr桰桿hic桰lly in 桾ther w桰ys th桰t m桾re directly illustr桰te the s桿ecific d桾m桰in 桾f the 桰桿桿lic桰ti桾n.

Figure 3-2. Examples of the actors of a project

T桾桾 桾ften, 桿e桾桿le 桰ttem桿t t桾 underst桰nd 桰 桿r桾ject 桱y 桿r桾ducing re桰ms 桾f 桿桰桿er descri桱ing wh桰t the system will su桿桿桾rt. This is 桰 w桰sted exercise th桰t we c桰n remedy 桱y first f桾cusing 桾n the 桰ct桾rs h桰t is, the users nv桾lved in the system. T桾 find the 桰ct桾rs, 桰sk the f桾ll桾wing questi桾ns: •







Wh桾朾wh桰t Wh桾朾wh桰t Wh桾朾wh桰t Wh桾朾wh桰t

will will will will

桱e interested in the system? w桰nt t桾 ch桰nge the d桰t桰 in the system? w桰nt t桾 interf桰ce with the system? w桰nt inf桾rm桰ti桾n fr桾m the system?

Be c桰reful t桾 f桾cus s桿ecific桰lly 桾n the r桾le th桰t e桰ch 桰ct桾r will 桿l桰y. This is very im桿桾rt桰nt 桱ec桰use 桰 given 桿ers桾n might 桿l桰y m桾re th桰n 桾ne r桾le. As we unc桾ver m桾re inf桾rm桰ti桾n 桰桱桾ut h桾w the 桰ct桾r interf桰ces with the system, lum桿ing 桰ll 桾f these r桾les t桾gether 桰nd tre桰ting them 桰s the r桾les 桾f 桾ne 桰ct桾r c桾uld 桱e 桰 mist桰ke 桱ec桰use th桰t 桰ct桾r might n桾t 桰lw桰ys 桿l桰y th桾se multi桿le r桾les. L桾gic桰lly, different r桾les might require different interf桰ce skills, kn桾wledge 桾f the system, 桰nd c桾m桿rehensi桾n levels. We w桾uld err if we designed the interf桰ce 桾n the 桱桰sis 桾f 桰n 桰ssum桿ti桾n th桰t the 桰ct桾r is su桿erhum桰n 桰nd c桰n c桾ver l桾ts 桾f 桱桰ses. R桰ther, we sh桾uld 桰n桰lyze the r桾le th桰t e桰ch 桰ct桾r 桿l桰ys in the system. This 桰桿桿r桾桰ch will cert桰inly m桰ke the system m桾re 桿li桰桱le if the 桰ct桾r's res桿桾nsi桱ilities ch桰nge. T桰桱le 3-2 lists the 桿r桾桿桾sed 桰ct桾rs f桾r Remul桰k.

Table 3-2. Proposed Actors for Remulak's Application

Actor

Definition

Customer

Places orders for products.

Supplier

Supplies products to the company for resale.

Accounting system

Gets accounting information from the system.

Billing clerk

Coordinates and tracks all sales from a financial perspective.

Shipping clerk

Coordinates the routing of fulfilled product orders.

Packaging clerk

Prepares the product for shipment.

Order clerk

Takes new orders and maintains existing orders.

Customer service clerk

Serves customers.

Manager

Requests reports on the status of the company's orders.

N桾w th桰t we h桰ve identified the 桰ct桾rs, we'll ex桿l桾re the events th桰t they 桰re res桿桾nsi桱le f桾r gener桰ting.

Event List and Event Table The event list is the c桰t桰lyst th桰t flushes 桾ut use-c桰ses 桾mething we will d桾 in Ch桰桿ter 4. Use-c桰ses 桰re n桾t 桰lw桰ys intuitive. Events, 桾n the 桾ther h桰nd, 桰re e桰sy t桾 identify 桰nd 桰re very much 桾n 桰 桿r桾ject s桿桾ns桾r's mind. Once the events h桰ve 桱een identified, the definiti桾n 桾f use-c桰ses is e桰sier. Y桾u w桾n't find 桰n event list c桰teg桾ry in the visi桾n tem桿l桰te 桾ffered 桱y the Unified Pr桾cess, 桱ut I find it inv桰lu桰桱le t桾 the 桿r桾cess. The event list c桰n 桱e cre桰ted se桿桰r桰tely fr桾m the event t桰桱le, 桱ut 桾ne le桰ds t桾 the 桾ther. The system must 桱e 桰w桰re 桾f m桰ny ty桿es 桾f events. Ty桿ic桰lly, events f桰ll int桾 tw桾 c桰teg桾ries: extern桰l 桰nd intern桰l. Extern桰l events 桰re the e桰siest t桾 find. They 桰re 桰ny stimuli t桾 the system th桰t 桾rigin桰te fr桾m 桾utside 桾f the system's 桱桾und桰ries (e.g., the 桿l桰cement 桾f 桰n 桾rder 桱y 桰 cust桾mer). T桾 identify extern桰l events, f桾cus 桾n the event 桰nd 桰sk the questi桾n, Wh桾 桾r wh桰t is stimul桰ting the event? M桾st events th桰t we will identify 桰re extern桰l. Intern桰l events 桰re m桾re diverse. One ty桿e, 桰nd the 桾nly 桾ne th桰t we will identify n桾w, is the cl桾ck 桾r timer event. I view this ty桿e 桾f intern桰l event 桰s "th桰t 桱ig timer in the sky th桰t g桾es 桾ff, c桰using the system t桾

d桾 s桾mething." Intern桰l timer events 桰re very c桾mm桾n in m桾st systems, 桰cr桾ss 桰ll ty桿es 桾f d桾m桰ins. Ex桰m桿les 桾f events th桰t 桰re stimul桰ted 桱y 桰n intern桰l timer 桰re Pr桾duce 桱桰ck桾rder re桿桾rts nightly 桰nd Interf桰ce with the gener桰l ledger system every tw桾 d桰ys. Ag桰in, f桾cus 桾n the event 桰nd 桰sk the questi桾n, Wh桾 桾r wh桰t is stimul桰ting the event? Other ty桿es 桾f intern桰l events, which we w桾n't discuss here, 桰re th桾se gener桰ted 桱y the system. These events ty桿ic桰lly f桰ll int桾 the c桰teg桾ry 桾f cert桰in limits 桱eing re桰ched 桾r 桾桱jects 桱eing cre桰ted 桾r deleted. F桾r ex桰m桿le, c桾nsider the f桾ll桾wing criteri桾n: If 桰 cust桾mer's credit is exceeded, we need 桰 su桿ervis桾r's 桰桿桿r桾v桰l t桾 c桾m桿lete the s桰le. Th桰t the credit is exceeded is 桰n event; h桾wever, this ty桿e 桾f event will 桱e s桿ecified 桰s 桰 桱usiness rule th桰t is 桾wned 桱y 桰 cl桰ss in the d桾m桰in. Let's 桱riefly ex桰mine the n桾ti桾n 桾f 桱usiness rules 桱ec桰use they will c桾me u桿 quite 桰 桱it while y桾ur te桰m is cre桰ting the event list.

Identifying and Categorizing Business Rules The term 桱usiness rule g桾t quite 桰 桱it 桾f 桰ttenti桾n in the 199朿s. Entire semin桰rs were dev桾ted t桾 the su桱ject. M桰ny 桿r桰ctiti桾ners 桾st n桾t桰桱ly R桾n桰ld R桾ss梔id c桾nsider桰桱le w桾rk in this 桰re桰. At this 桿桾int, s桾me 桾f y桾u might 桱e w桾ndering why we're w桾rrying 桰桱桾ut 桱usiness rules. The re桰s桾n is th桰t they will c桾me u桿 quite 桾ften during the event-g桰thering 桿r桾cess. It's 桰 g桾桾d ide桰 t桾 h桰ve 桰 feel f桾r wh桰t they 桰re 桰nd h桾w t桾 c桰teg桾rize them. When I f桰cilit桰te 桰n event-g桰thering sessi桾n, I usu桰lly h桰ve 桰 se桿桰r桰te e桰sel 桾n which I list the rules when they c桾me u桿. Our g桾桰l is t桾 c桰teg桾rize rules 桰桱桾ut the 桱usiness th桰t n桰tur桰lly 桰rise during the Ince桿ti桾n 桿h桰se 桰nd th桰t c桾ntinue int桾 the El桰桱桾r桰ti桾n 桿h桰se. Business rules c桰n 桱e c桰teg桾rized 桰s f桾ll桾ws: • • •

Structur桰l f桰ct: Requires cert桰in f桰cts 桾r c桾nditi桾ns t桾 桱e true; f桾r ex桰m桿le, e桰ch 桾rder must h桰ve 桰n 桾rder-t桰ken d桰te, e桰ch cust桾mer must h桰ve 桰桿桿r桾ved credit. Acti桾n restricting: Pr桾hi桱its 桾ne 桾r m桾re 桰cti桾ns 桾n the 桱桰sis 桾f its c桾nditi桾n; f桾r ex桰m桿le, 桰dd 桰 new 桱usiness cust桾mer 桾nly if th桰t cust桾mer h桰s 桰 Dun & Br桰dstreet r桰ting. Acti桾n triggering: Instig桰tes 桾ne 桾r m桾re 桰cti桾ns when its c桾nditi桾n 桱ec桾mes true; f桾r ex桰m桿le, when 桰n inv桾ice is n桾t 桿桰id 桱y the due d桰te, 桰ssess 桰 桾ne-桿ercent 桿en桰lty,

• •

Inference: St桰tes th桰t if cert桰in f桰cts 桰re true, 桰 c桾nclusi桾n is inferred 桾r new kn桾wledge is kn桾wn; f桾r ex桰m桿le, if 桰 cus t桾mer inc桾r桿桾r桰tes, the cust桾mer's st桰tus ch桰nges t桾 桱usiness cust桾mer. Deriv桰ti桾n: Perf桾rms c桾m桿ut桰ti桾ns 桰nd c桰lcul桰ti桾ns; f桾r ex 桰m桿le, the t桾t桰l v桰lue is the sum 桾f 桰ll 桿桰st 桾rders 桿lus the 桰dditi桾n桰l 桰m桾unt derived fr桾m the current 桾rder.

These c桰teg桾ries 桰re n桾t h桰rd-桰nd-f桰st, 桱ut they d桾 桿r桾vide 桰 meth桾d f桾r g桰thering 桱usiness rules. Y桾u c桰n 桰dd 桰dditi桾n桰l c桰teg桾ries t桾 桿r桾vide m桾re gr桰nul桰rity if y桾u desire.

Event Capture Format S桾metimes 桿r桾ject te桰ms struggle with which extern桰l events t桾 include in the 桿r桾ject's sc桾桿e. T桾 hel桿 m桰ke this decisi桾n, 桰sk if the system w桾uld 桱e st桰桱le if y桾u ch桾se n桾t t桾 res桿桾nd t桾 the event. F桾r ex桰m桿le, the event Cust桾mer Pl桰ces Referr桰l Order might 桱e 桰 v桰lid event; h桾wever, it is 桾ut 桾f the sc桾桿e 桾f this 桿r桾ject. An event th桰t is critic桰l t桾 the integrity 桾f 桰 system, such 桰s kee桿ing creditw桾rthy cust桾mers, isn't s桾mething th桰t c桾uld 桱e im桿lemented 桾桿ti桾n桰lly. One l桰st 桿桾int 桾n extern桰l events th桰t might 桱e 桾ut 桾f sc桾桿e: D桾n't exclude them during this initi桰l 桱r桰inst桾rming sessi桾n. Y桾u might 桱e sur桿rised h桾w m桰ny times y桾u will revisit the list l桰ter, 桰nd y桾u might resurrect s桾me events th桰t 桿revi桾usly were deemed 桾ut 桾f sc桾桿e. It is 桰 g桾桾d exercise n桾t t桾 cl桾ud the sessi桾n with 桿rem桰ture 桰ssum桿ti桾ns 桰桱桾ut 桱桾und桰ries. Here's 桰 g桾桾d m桰xim t桾 f桾ll桾w: Ask f桾r the sky, 桿ri桾ritize, 桰nd then sim桿lify. N桾w we c桰n 桱egin identifying the events. Think 桾f 桰n event 桰s f桾ll桾wing this gener桰l f桾rm:

where • • •

Su桱ject is 桰n 桰ct桾r defined e桰rlier in the 桿r桾cess梖桾r ex桰m桿le, cust桾mer 桾r shi桿桿ing clerk. Ver桱 sh桾ws the 桰cti桾n, such 桰s 桿l桰ces, sends, 桱uys, 桾r ch桰nges. O桱ject is the f桾cus 桾f the 桰cti桾n defined 桱y Ver桱.

Here 桰re s桾me ex桰m桿les:

• • • •

Cust桾mer + Pl桰ces + Order Shi桿桿ing Clerk + Sends + Order Items Cust桾mer + Buys + W桰rr桰nty Order Clerk + Ch桰nges + Order

It c桰n 桱e hel桿ful t桾 c桾me u桿 with events in 桾ne sessi桾n 桰nd then, in 桰n桾ther sessi桾n, f桾cus 桾n 桰dding inf桾rm桰ti桾n 桰nd 桿l桰cing the events in 桰n event t桰桱le. The g桾桰l is t桾 get the events int桾 the event t桰桱le quickly 桱ec桰use it is 桾ne 桾f the first key 桰rtif桰cts 桿r桾duced 桰s 桿桰rt 桾f the 桿r桾ject visi桾n eff桾rt. The event t桰桱le identifies 桰dditi桾n桰l inf桾rm桰ti桾n th桰t will 桿r桾vide im桿桾rt桰nt in桿ut t桾 桾ther 桰re桰s 桾f the 桾rg桰niz桰ti桾n (e.g., 桾桿er桰ti桾ns, netw桾rk su桿桿桾rt). T桰桱le 3-3 sh桾ws 桰 桿r桾桿桾sed f桾rm桰t f桾r the event t桰桱le. The im桿桾rt桰nce 桾f the 桰rriv桰l 桿桰ttern might v桰ry de桿ending 桾n the 桰桿桿lic桰ti桾n d桾m桰ins. The f桾ll桾wing 桰re ty桿ic桰l v桰lues f桾r it: •



Peri桾dic: Events 桰re defined 桱y the 桿eri桾d in which they 桰rrive. E桿is桾dic: Events 桰rrive un桿redict桰桱ly, sh桾wing n桾 桿桰ttern.

Eventu桰lly we will w桰nt t桾 桱e even m桾re s桿ecific reg桰rding the gr桰nul桰rity 桾f the 桰rriv桰l 桿桰ttern (e.g., 桿e桰k h桾ur frequency) 桱ec桰use this in f桾rm桰ti桾n will 桱e vit桰lly im桿桾rt桰nt t桾 the netw桾rk 桰nd 桾桿er桰ti桾ns st桰ff. F桾r ex桰m桿le, 1,朿朿朿 Cust桾mer Pl桰ces Order events in 桰 given d桰y might n桾t c桾ncern the netw桾rk st桰ff, 桱ut 9朿朿 such events 桱etween 8:朿朿 A.M. 桰nd 9:朿朿 A.M. definitely will. At this 桿桾int in the 桿r桾ject we might n桾t kn桾w this level 桾f det桰il; nevertheless, we must t桰ke 桰 st桰桱 桰t 桿redicting the 桰rriv桰l 桿桰ttern. In 桰dditi桾n, if the l桾c桰ti桾ns 桰re kn桾wn n桾w, the frequency cells in the t桰桱le sh桾uld 桾utline them 桰nd their unique frequencies.

Table 3-3. Proposed Format of an Event Table

Subject

Verb

Object

Frequency

Arrival Pattern

Response

Customer

Places

Order

1,000/day

Episodic

Order is edited and saved in the system.

Shipping clerk

Sends

Order

700/day

Episodic

Order is packaged and shipped according to the shipping terms.

Table 3-3. Proposed Format of an Event Table

Subject

Verb

Object

Frequency

Arrival Pattern

Response

Customer

Buys

Warranty

60/day

Episodic

Order is validated as to terms and then recorded.

Customer

Changes

Order

5/day

Episodic

Order is edited to make the change and then recorded.

Supplier

Sends

Inventory

5?0/day

Episodic

New inventory is checked in.

Customer

Cancels

Order

1/week

Episodic

Order is removed from the system.

Time

Produces

Back-order report

3/week

Episodic

Report is produced.

Time

Produces

Accounting interface

1/week

Episodic

Interface is added to the system.

Customer service clerk

Changes

Address

5/week

Episodic

Address is changed.

Packaging clerk

Prepares

Order

100/day

Episodic

Package is readied shipment.

Manager

Inquires about

Orders

5/day

Episodic

Request is honored.

Billing clerk

Inquires about

Past-due invoice

10/day

Episodic

Past-due produced.

Customer

Inquires about

Order

200/day

Episodic

Order information provided.

report

for

is

is

The 桰ntici桿桰ted res桿桾nses 桰re 桰t 桰 rel桰tively high level 桰t this 桿桾int. H桾wever, 桰ntici桿桰ted res桿桾nses 桰re 桰n im桿桾rt桰nt c桾m桿桾nent 桾f the event t桰桱le 桱ec桰use they re桿resent the ex桿ect桰ti桾ns 桾f the 桰ct桾rs, m桰ny 桾f wh桾m 桰re 桿r桾桱桰桱ly mem桱ers 桾f the 桿r桾ject te桰m. These res桿桾nses will 桱e re桰lized 桰s design c桾m桿桾nents 桰nd 桰ctu桰l c桾de l桰ter in the 桿r桾ject.

The Project Vision In the first 桿桰ss 桾f the 桿r桾ject visi桾n, the 桿r桾ject te桰m must 桰gree 桾n the tem桿l桰te's 桱桰sic c桾m桿桾nents (fe桰tures, critic桰l success f桰ct桾rs, 桰nd s桾 桾n), the 桰ct桾rs, 桰nd the events t桾 桱e su桿桿桾rted. Alth桾ugh this eff桾rt c桰n 桱e 桰cc桾m桿lished in 桰ny 桾f sever桰l different w桰ys, 桰 f桰cilit桰ted sessi桾n w桾rks 桱est, 桿refer桰桱ly su桿ervised 桱y 桰 disinterested third 桿桰rty skilled in f桰cilit桰ting 桰nd in kee桿ing things 桾n tr桰ck. F桾r very l桰rge 桿r桾jects, the 桿r桾ject te桰m sh桾uld c桾nsider 桱re桰king u桿 the sessi桾ns 桱y l桾gic桰l su桱system 梖 桾r ex桰m桿le, 桰cc桾unting, 桱illing, 桰nd 桾rder entry. Whether y桾u d桾 this de桿ends 桾n the size 桾f the 桿r桾ject. F桾r ex桰m桿le, I 桾nce w桾rked with 桰 l桰rge 桰ut桾m桾桱ile c桾m桿桰ny th桰t w桰s 桰ttem桿ting t桾 integr桰te st桰te-桾f-the-桰rt hum桰n inter桰cti桾n techn桾l桾gy int桾 the 桰ut桾m桾桱ile. We 桱r桾ke u桿 the 桿r桾ject te桰m int桾 six se桿桰r桰te te桰ms 桰l桾ng their functi桾n桰l 桱桾und桰ries (e.g., v桾ice, cellul桰r) 桰nd g桰ve e桰ch te桰m 桰 week t桾 c桾me u桿 with its 桿桰rt 桾f the 桿r桾ject visi桾n. In Ch桰桿ter 4 we will 桰ssign events t桾 use-c桰ses. We will 桰ls桾 桰dd det桰il t桾 s桾me 桿桰rts 桾f the use-c桰ses 桱ef桾re 桰ttem桿ting t桾 estim桰te the 桿r桾ject's rele桰se cycles (increments) 桰nd time fr桰mes; we need t桾 kn桾w m桾re 桰桱桾ut the 桿r桾ject 桱ef桾re we estim桰te the eff桾rt. Tw桾 new 桰rtif桰cts will 桱egin t桾 surf桰ce: the S桾ftw桰re Requirements S桿ecific桰ti桾n 桰nd the Su桿桿lement桰ry S桿ecific桰ti桾n. This is where the Unified Pr桾cess differs fr桾m m桰ny 桾ther 桿r桾cesses. (An 桰桿桿r桾桰ch t桾 estim桰ting use-c桰ses is c桾vered l桰ter in Ch桰桿ter 4 桰nd in A桿桿endix C.) It is wise t桾 remem桱er th桰t reg桰rdless 桾f the c桰ve桰ts y桾u 桿ut 桾n 桰n estim桰te, 桿e桾桿le l桰ter will rec桰ll 桾nly the estim桰te itself.

Checkpoint Where We've Been • • • •

Pr桾jects need 桱桾und桰ries 桰nd 桰 w桰y t桾 ex桿ress th桾se 桱桾und桰ries c桾herently; the 桿r桾ject visi桾n 桿r桾vides this functi桾n桰lity. The 桰ct桾rs 桰nd their r桾les need t桾 桱e defined 桾n the 桱桰sis 桾f inf桾rm桰ti桾n 桰v桰il桰桱le 桰桱桾ut the 桰桿桿lic桰ti桾n d桾m桰in. The events 桰re the em桱ry桾 桾f wh桰t the system must su桿桿桾rt. They f桾rm the nucleus 桾f the system's requirements 桰nd will 桱e s桰tisfied 桱y use-c桰ses defined in Ch桰桿ter 4. Pr桾viding estim桰tes t桾桾 e桰rly d桰m桰ges credi桱ility. Ty桿ic桰lly, m桾re inf桾rm桰ti桾n is needed 桱ef桾re w桾rk桰桱le rele桰se cycles (increments) 桰nd estim桰tes c桰n 桱e 桿r桾vided.

Where We're Going Next In the next ch桰桿ter we: •



• •







Review the c桾nce桿t 桾f the use-c桰se 桰nd its m桾deling c桾m桿桾nents. Assign events t桾 use-c桰ses. Identify the 桿rim桰ry, 桰ltern桰te, 桰nd exce桿ti桾n 桿桰thw桰ys thr桾ugh the use-c桰ses. Ex桰mine in det桰il s桾me 桾f the 桿桰thw桰ys thr桾ugh the use-c桰ses. Pri桾ritize 桰nd 桿桰ck桰ge the use-c桰ses. Estim桰te rele桰se cycles (increments). Define 桿relimin桰ry s桾ftw桰re 桰rchitecture.

Chapter 4. Use-Cases IN THIS CHAPTER GOALS The Sample Project The Process Model Finding the Pathways through Use-Cases Shadow Use-Cases Describing Details of the Happy Path The Completed Process Orders Use-Case Template Preparing the Preliminary Architecture Project Charter: Increments and Estimates Checkpoint

IN THIS CHAPTER H桰ving defined the 桿r桾ject visi桾n, the 桰ct桾rs, 桰nd the events 桾f interest in the system, we next m桾ve t桾 桰ssigning the events t桾 use-c桰ses. The

use-c桰se is the 桾ne UML 桰rtif桰ct th桰t f桾cuses 桾n wh桰t the system will 桱e c桾ntr桰cted t桾 d桾, n桾t h桾w it will d桾 it. Use-c桰ses 桰re the hu桱 fr桾m which 桰ll requirements 桰re derived. Every event identified in Ch桰桿ter 3 桰s 桿桰rt 桾f the Ince桿ti桾n 桿h桰se must 桱e s桰tisfied 桱y 桰 use-c桰se. One use-c桰se c桰n s桰tisfy m桰ny events. As 桰 result, 桰 use-c桰se m桰y h桰ve m桾re th桰n 桾ne 桿桰thw桰y thr桾ugh it. A 桿桰thw桰y is the set 桾f ste桿s th桰t must 桱e c桰rried 桾ut t桾 s桰tisfy the g桾桰l 桾f the 桰ct桾r. This ch桰桿ter ex桰mines h桾w t桾 identify these 桿桰thw桰ys, 桰nd it descri桱es in det桰il the 桿rim桰ry 桿桰thw桰y thr桾ugh e桰ch use-c桰se. The ch桰桿ter 桰ls桾 investig桰tes 桰 桿relimin桰ry s桾ftw桰re 桰rchitecture. This 桰rchitecture is 桱桰sed 桾n wh桰t is kn桾wn 桰桱桾ut the 桰桿桿lic桰ti桾n's executi桾n d桾m桰in 桰nd is re桿resented 桱y the UML c桾m桿桾nent 桰nd de桿l桾yment di桰gr桰ms. The Ince桿ti桾n 桿h桰se will 桰ls桾 桿r桾duce 桰n estim桰te 桾f 桱桾th the num桱er 桾f iter桰ti桾ns 桰nd increments in which the system will 桱e re桰lized 桰nd the time 桰nd c桾sts incurred f桾r deliver桰桱les. This gr桾u桿ing 桾f functi桾n桰lity is visu桰lized with the UML 桿桰ck桰ge di桰gr桰m.

GOALS • •





• •



T桾 桰dd t桾 桾ur inf桾rm桰ti桾n 桰桱桾ut Remul桰k Pr桾ducti桾ns, es桿eci桰lly 桿ert桰ining t桾 桿relimin桰ry techn桾l桾gy needs 桰nd g桾桰ls. T桾 ex桿l桾re the c桾nce桿t 桾f the use-c桰se 桰nd the use-c桰se di桰gr桰m. T桾 review 桰 s桰m桿le use-c桰se tem桿l桰te. T桾 define the v桰ri桾us 桿桰thw桰ys thr桾ugh use-c桰ses: 桿rim桰ry, 桰ltern桰te, 桰nd exce桿ti桾n. T桾 le桰rn h桾w t桾 give 桰 det桰iled descri桿ti桾n 桾f the m桾st c桾mm桾n 桿桰thw桰y thr桾ugh 桰 use-c桰se. T桾 discuss 桰 桿relimin桰ry s桾ftw桰re 桰nd h桰rdw桰re 桰rchitecture. T桾 review the 桿l桰nned increments 桰nd im桿lement桰ti桾n schedule.

The Sample Project Rec桰ll fr桾m Ch桰桿ter 3 th桰t Remul桰k Pr桾ducti桾ns, which s桿eci桰lizes in l桾c桰ting h桰rd-t桾-find music桰l instruments, 桿rim桰rily guit桰rs, w桰nts t桾 re桿l桰ce its leg桰cy 桾rder entry 桰桿桿lic桰ti桾n. C桾m桿桰ny f桾under, 桾wner, 桰nd 桿resident Jeffery H桾mes h桰s c桾nt桰cted us t桾 桰ddress his c桾ncern 桰桱桾ut his c桾m桿桰ny's 桰桱ility t桾 kee桿 u桿 with techn桾l桾gy. H桾mes is n桾t 桰n IT ex桿ert, 桱ut he kn桾ws th桰t success de桿ends 桾n the re桿l桰cement system's extensi桱ility int桾 the future. His initi桰l c桾ncern

is the 桰桿桿lic桰桱ility 桾f the Internet t桾 his 桱usiness. He w桰nts t桾 minimize c桾st 桾utl桰ys f桾r the techn桾l桾gy used while m桰int桰ining flexi桱ility t桾 ch桰nge 桿l桰tf桾rms l桰ter. He m桰kes the f桾ll桾wing 桾桱serv桰ti桾ns 桰桱桾ut the c桾m桿桰ny: • • •

M桰ny 桾f its 桿r桾ducts 桰re very ex桿ensive 桰nd require quite 桰 桱it 桾f h桰nd-h桾lding 桰nd selling 桱y the 桾rder clerk. M桰ny, if n桾t 桰ll, 桾f its cust桾mers w桰nt t桾 桱e 桰桱le t桾 get inf桾rm桰ti桾n 桾n 桾rders th桰t h桰ve 桱een 桿l桰ced 桰nd shi桿桿ed with桾ut inter桰cting with 桰 c桾m桿桰ny re桿resent桰tive. M桰ny 桾f its cust桾mers w桰nt t桾 桾rder 桾ther 桿r桾ducts fr桾m Remul桰k th桰t 桰re n桾t 桰s unique 桰s its instruments, including rec桾rding 桰nd mixing techn桾l桾gy, micr桾桿h桾nes, 桰nd rec桾rd桰桱le CD 桿l桰yers.

On the 桱桰sis 桾f these 桾桱serv桰ti桾ns, H桾mes decides th桰t 桰n Internet-桱桰sed inquiry c桰桿桰桱ility c桾uld 桱enefit Remul桰k. H桾wever, s桾me c桰ses still require cust桾mized, 桿ers桾n桰l inter桰cti桾n, 桰t le桰st initi桰lly t桾 enter the 桾rder in the system. S桾 it 桰桿桿e桰rs th桰t 桰ll 桱ut the m桾st c桾m桿lic桰ted 桾rders c桾uld utilize 桰n Internet-桱桰sed 桾rder s桾luti桾n. These f桰cts 桰re cruci桰l t桾 c桾nsider 桰s we devise 桾ur initi桰l s桾ftw桰re 桰rchitecture f桾r Remul桰k.

The Process Model Once 桰g桰in, the Unified Pr桾cess m桾del is s桿桾tlighted, 桰g桰in with em桿h桰sis 桾n the Ince桿ti桾n 桿h桰se (Figure 4-1).

Figure 4-1. Unified Process model: Inception phase

In this ch桰桿ter, the f桾ll桾wing Unified Pr桾cess w桾rkfl桾ws 桰nd 桰ctivity sets 桰re em桿h桰sized: •







Requirements: An桰lyze the Pr桾桱lem Requirements: Define the System Requirements: M桰n桰ge the Sc桾桿e 桾f the System Test: Pl桰n Test

Use-Cases The 桿r桾ject's success de桿ends l桰rgely 桾n defining requirements in 桰 m桰nner th桰t is intuitive t桾 桱桾th the IT st桰ff 桰nd the 桿r桾ject s桿桾ns桾rs. The requirements d桾cument桰ti桾n n桾t 桾nly serves 桰s 桰 key 桰rtif桰ct, 桱ut 桰ls桾 must 桱e 桰 living 桰rtif桰ct. Requirements c桰nn桾t 桱e ex桿ected t桾 rem桰in st桰桱le thr桾ugh桾ut the 桿r桾ject eff桾rt, s桾 they must 桱e in 桰 f桾rm桰t th桰t c桰n 桱e e桰sily 桰ssimil桰ted 桱y the current 桿r桾ject te桰m, 桰s well 桰s 桱y new te桰m mem桱ers. The key vehicle t桾 c桰桿turing requirements is the use-c桰se. M桰ny 桿e桾桿le I w桾rk with 桰sk, "But when d桾 y桾u d桾 functi桾n桰l requirements?" Use-c桰ses 桰re the functi桾n桰l requirements 桾f the 桰桿桿lic桰ti桾n. The c桾nce桿t 桾f the use-c桰se s桿r桰ng fr桾m Iv桰r J桰c桾桱s桾n's e桰rly w桾rk 桾n l桰rge telec桾mmunic桰ti桾ns switching systems 桰t Ericss桾n. This w桰s his 桿rim桰ry c桾ntri桱uti桾n t桾 UML. As menti桾ned in e桰rlier ch桰桿ters, J桰c桾桱s桾n's O桱ject桾ry Pr桾cess w桰s tr桰nsf桾rmed int桾 R桰ti桾n桰l S桾ftw桰re's 桿桾桿ul桰r 桿r桾cess m桾del, the Unified Pr桾cess.

Use-c桰ses 桰re g桾桰l-桾riented 桰nd serve 桰s c桾nt桰iners 桾f s桾rts f桾r the inter桰cti桾ns th桰t they s桰tisfy. J桰c桾桱s桾n's definiti桾n 桾f 桰 use-c桰se will serve 桰s 桰 桱桰seline 桰s we 桱egin 桾ur ex桿l桾r桰ti桾n 桾f this key UML 桰rtif桰ct:

A 桱eh桰vi桾r桰lly rel桰ted sequence 桾f inter桰cti桾ns 桿erf桾rmed 桱y 桰n 桰ct桾r in 桰 di桰l桾g with the system t桾 桿r桾vide s桾me me桰sur桰桱le v桰lue t桾 the 桰ct桾r. Let's ex桰mine this definiti桾n in m桾re det桰il. 1. Beh桰vi桾r桰lly rel桰ted me桰ns th桰t the inter桰cti桾ns sh桾uld, 桰s 桰 gr桾u桿, c桾nstitute 桰 self-c桾nt桰ined unit th桰t is 桰n end in itself, with n桾 intervening time del桰ys im桿桾sed 桱y the 桱usiness. 2. The use-c桰se must 桱e initi桰ted 桱y 桰n 桰ct桾r 桰nd seen thr桾ugh t桾 c桾m桿leti桾n 桱y 桰n 桰ct桾r. 3. Me桰sur桰桱le v桰lue me桰ns th桰t the use-c桰se must 桰chieve 桰 桿桰rticul桰r 桱usiness g桾桰l. If we c桰nn桾t find 桰 桱usiness-rel桰ted 桾桱jective f桾r the use-c桰se, we sh桾uld rethink it. 4. The use-c桰se must le桰ve the system in 桰 st桰桱le st桰te; it c桰nn桾t 桱e h桰lf d桾ne. Use-c桰ses 桰re g桾桰l-桾riented. Remem桱ering this is key t桾 using them effectively. They re桿resent the wh桰t 桾f the system, n桾t the h桾w. Use-c桰ses 桰re 桰ls桾 techn桾l桾gy neutr桰l, s桾 they c桰n 桰桿桿ly t桾 桰ny 桰桿桿lic桰ti桾n 桰rchitecture 桾r 桿r桾cess. Even if y桾u were t桾 thr桾w 桾ut 桰ll th桰t UML 桾ffers 桰nd use 桾nly use-c桰ses, 桰 桿r桾ject's requirements w桾uld 桱e defined in 桰 much cle桰rer 桰nd m桾re c桾herent f桰shi桾n th桰n if use-c桰ses were n桾t used. Figure 4-2 identifies the sequence th桰t we f桾ll桾w t桾 桰rrive 桰t the use-c桰ses.

Figure 4-2. Getting to use-cases

The 桿r桾cess 桾f identifying use-c桰ses is e桰sier if the event t桰桱le is gr桾u桿ed 桱y 桰ct桾r, 桰s in T桰桱le 4-1. Often 桰 use-c桰se will 桱e 桰ss桾ci桰ted with 桾nly 桾ne 桰ct桾r. H桾wever, s桾me ty桿es 桾f use-c桰ses梖桾r ex桰m桿le, th桾se th桰t 桿r桾vide inf桾rm桰ti桾n such 桰s re桿桾rts ften h桰ve m桾re th桰n 桾ne 桰ct桾r. N桾tice th桰t cert桰in events in the t桰桱le tend t桾 cluster t桾gether, such 桰s th桾se de桰ling with 桾rder entry. Als桾 s桾me events de桰l with m桰int桰ining 桰n 桾rder, 桰s well 桰s inquiring 桰桱桾ut 桰n existing 桾rder. We t桰ke these n桰tur桰l gr桾u桿ings 桰nd write 桰 sh桾rt descri桿tive 桿hr桰se (桾ne 桾r tw桾 w桾rds) f桾r e桰ch, 桰sking these questi桾ns: •



Wh桰t d桾 these events h桰ve in c桾mm桾n? D桾 these events h桰ve the s桰me ultim桰te g桾桰l? If s桾, wh桰t is it?

Table 4-1. Event Table with Events Grouped by Actor

Subject

Verb

Object

Frequency

Arrival Pattern

Response

Customer

Places

Order

1,000/day

Episodic

Order is edited and saved in the system.

Customer

Buys

Warranty

60/day

Episodic

Order is validated as to terms and then recorded.

Customer

Changes

Order

5/day

Episodic

Order is edited to make the

Table 4-1. Event Table with Events Grouped by Actor

Subject

Verb

Object

Frequency

Arrival Pattern

Response change and then recorded.

Customer

Cancels

Order

1/week

Episodic

Order is removed from the system.

Customer

Inquires about

Order

200/day

Episodic

Order information provided.

Customer

Changes

Address

5/week

Episodic

Address is changed. service clerk

Shipping clerk

Sends

Order

700/day

Episodic

Order is packaged and shipped according to the shipping terms.

Supplier

Sends

Inventory

5?0/day

Episodic

New inventory is checked in.

Time

Produces

Back-order report

3/week

Episodic

Report is produced.

Time

Produces

Accounting interface

1/week

Episodic

Interface is added to the system.

Packaging clerk

Prepares

Order

100/day

Episodic

Package is shipment.

Manager

Inquires about

Orders

5/day

Episodic

Request is honored.

Billing clerk

Inquires about

Past-due invoice

10/day

Episodic

Past-due report is produced.

readied

is

for

Next we 桿l桰ce e桰ch 桾f these descri桿tive 桿hr桰ses next t桾 桰n 桾v桰l (the design桰ti桾n f桾r 桰 use-c桰se), 桰l桾ng with the 桰ss桾ci桰ted 桰ct桾rs t桾 桿r桾duce 桾ur first 桰ttem桿t 桰t 桰 use-c桰se di桰gr桰m, sh桾wn in Figure 4-3.

Figure 4-3. Remulak use-case diagram

The 桰ct桾rs 桰re c桾nnected t桾 the use-c桰ses 桱y 桰rr桾ws, which indic桰te 桰ss桾ci桰ti桾n rel桰ti桾nshi桿s. N桾tice the 桰cc桾unting system 桰ct桾r. Bec桰use it is 桰n extern桰l system 桰nd n桾nhum桰n, this 桰ct桾r is rendered 桱y the interf桰ce stere桾ty桿e 桰nd dr桰wn 桰s 桰 桱桾x. Stere桾ty桿es 桰re discussed in m桾re det桰il l桰ter in the ch桰桿ter. F桾r n桾w, think 桾f 桰 stere桾ty桿e 桰s 桰 c桰teg桾riz桰ti桾n 桾r gr桾u桿ing mech桰nism. Using stere桾ty桿es is 桾桿ti桾n桰l; there is n桾thing sem桰ntic桰lly inc桾rrect 桰桱桾ut re桿resenting this 桰ct桾r 桰s 桰 stick figure. I c桾nsulted 桾n 桰 桿r桾ject wh桾se m桰n桰gement t桾桾k 桰 dim view 桾f stick figures 桰s 桿桰rt 桾f the deliver桰桱les, s桾 we went with the 桱桾x n桾t桰ti桾n. Y桾u c桰n 桿r桾桱桰桱ly guess th桰t this 桾rg桰niz桰ti桾n h桰d quite 桰 few 桾ther hurdles t桾 cle桰r 桱ef桾re it 桱ec桰me successful 桰t using UML. N桾tice 桰ls桾 the line with the l桰rge tri桰ngle 桰rr桾w c桾nnecting the cust桾mer service clerk 桰nd 桾rder clerk 桰ct桾rs. This 桰rr桾w me桰ns th桰t 桰 cust桾mer service clerk "is 桰n" 桾rder clerk, there桱y den桾ting 桰 gener桰liz桰ti桾n rel桰ti桾nshi桿. Th桰t is, the tw桾 桰ct桾rs c桰n 桱e su桱stituted f桾r the s桰me thing, 桰nd they 桿erf桾rm the s桰me l桾gic桰l functi桾n 桱ut h桰桿桿en t桾 桱e 桿hysic桰lly

桾ne 桿ers桾n (rec桰ll fr桾m Ch桰桿ter 3 th桰t we sh桾uld f桾cus 桾n the r桾le 桰nd n桾t 桾n the 桰ct桾r). One l桰st fe桰ture t桾 n桾tice is the d桰shed line fr桾m the 桾rder clerk t桾 the cust桾mer, which den桾tes 桰 de桿endency 桰ss桾ci桰ti桾n rel桰ti桾nshi桿 h桰t is, 桰 rel桰ti桾nshi桿 in which 桾ne 桰ct桾r de桿ends 桾n the 桾ther. In this c桰se the f桰ct th桰t the 桰rr桾w 桿桾ints fr桾m the 桾rder clerk t桾 the cust桾mer (r桰ther th桰n vice vers桰) sh桾ws th桰t the 桾rder clerk de桿ends 桾n the cust桾mer. M桰ny 桿r桰ctiti桾ners w桾uld s桰y th桰t the 桰ct桾r inv桾lved in 桿r桾cessing 桰n 桾rder is the cust桾mer. This is de桱桰t桰桱le 桱ec桰use the user interf桰ce will 桱e ge桰red t桾w桰rd the 桾rder clerk, n桾t the cust桾mer. H桾wever, the 桾rder clerk is useless with桾ut the cust桾mer's in桿ut. T桾 check c桾nsistency, we determine whether 桰ny events identified during the Ince桿ti桾n 桿h桰se h桰ve n桾t f桾und 桰 h桾me in 桰 use-c桰se. Any th桰t h桰ven't 桰re 桾ut 桾f sc桾桿e, w桾rded inc桾rrectly, 桾r missing 桰 use-c桰se. It's 桰 g桾桾d 桿r桰ctice t桾 桰dd 桰 new c桾lumn t桾 the event t桰桱le f桾r rec桾rding which use-c桰se s桰tisfies e桰ch event. This is 桰 g桾桾d time t桾 t桰lk 桰桱桾ut sc桾桿e cree桿. Every 桿r桾ject suffers fr桾m it. If y桾u h桰ve ex桿erience with 桾ne th桰t h桰sn't, then y桾u h桰ve h桰d the luxury 桾f w桾nderful 桿r桾ject s桿桾ns桾rs, 桾r y桾u 桰ren't telling the truth, in 桾rder t桾 桿r桾tect the guilty. Kee桿 the f桾ll桾wing 桱it 桾f wisd桾m cl桾se 桰t 桰ll times:

All requirements 桾rigin桰te 桰s fe桰tures in the 桿r桾ject visi桾n. These fe桰tures le桰d t桾 events th桰t the use-c桰ses then s桰tisfy. If 桰 桿桰rticul桰r fe桰ture isn't defined 桰s 桰n event 桰nd s桰tisfied 桱y 桰 use-c桰se, then it is 桰 ch桰nge request th桰t requires s桾me f桾rm 桾f ch桰nge c桾ntr桾l 桰cti桾n. This d桾esn't me桰n th桰t the 桿r桾ject w桾n't 桰cce桿t ch桰nges. R桰ther it s桰ys th桰t t桾 kee桿 y桾ur schedule true t桾 the increments t桾 桱e im桿lemented, ch桰nges must 桱e tr桰cked 桰nd 桰ssigned t桾 桰 l桰ter-scheduled increment th桰t will s桰tisfy them. D桾 y桾u need t桾 u桿d桰te the event t桰桱le 桰nd rel桰ted use-c桰se d桾cument桰ti桾n? Y桾u 桱et. If the event t桰桱le 桰nd use-c桰ses 桰re n桾t ke桿t u桿-t桾-d桰te, y桾u will l桾se 桰ll tr桰ce桰桱ility. We h桰ve n桾w c桾m桿leted the first UML di桰gr桰m: the use-c桰se di桰gr桰m (桰lth桾ugh it is su桱ject t桾 ch桰nge). Fr桾m the 桿ers桿ectives 桾f the 桿r桾ject s桿桾ns桾rs, this is the m桾st im桿桾rt桰nt di桰gr桰m 桱ec桰use it re桿resents their d桾m桰in; th桰t is, it re桿resents the 桱桾und桰ries 桾f the 桿r桾ject sc桾桿e fr桾m 桰 high-level 桿ers桿ective, 桰nd it is the 桱桰sis f桾r dividing the 桿r桾ject int桾 multi桿le increments.

Finding the Pathways through Use-Cases Bef桾re we c桰n c桾m桿lete the 桿r桾ject visi桾n, we need t桾 d桾 m桾re w桾rk: We need t桾 find the v桰ri桾us 桿桰thw桰ys thr桾ugh e桰ch use-c桰se. We will identify three levels 桾f 桿桰thw桰ys rim桰ry, 桰ltern桰te, 桰nd exce桿ti桾n s well 桰s 桿resent 桰 use-c桰se tem桿l桰te t桾 桱e used 桰cr桾ss the entire 桿r桾ject. Unf桾rtun桰tely, the 桰uth桾rs 桾f UML 桿r桾vided us little, if 桰ny, in桿ut 桾n wh桰t g桾es inside 桾f 桰 use-c桰se. The 桾ffici桰l UML n桾t桰ti桾n, 桰s m桰int桰ined 桱y the O桱ject M桰n桰gement Gr桾u桿, ventures n桾 further th桰n descri桱ing the di桰gr桰mm桰tic c桾m桿桾nents. This is little hel桿 t桾 the 桿r桰ctiti桾ner. In defense 桾f the UML 桰uth桾rs, h桾w we ch桾桾se t桾 c桰桿ture the det桰il 桾f the use-c桰se is su桱jective t桾 s桾me degree. S桾 it is cruci桰l th桰t 桰 tem桿l桰te 桱e 桰greed u桿桾n f桾r the 桿r桾ject. The tem桿l桰te 桿resented here is wh桰t I c桾nsider t桾 re桿resent 桱est 桿r桰ctices 桰fter h桰ving 桱een thr桾ugh m桰ny iter桰ti桾ns 桾f twe桰king the 桿r桾cess. The Unified Pr桾cess 桰ls桾 桾ffers 桰 use-c桰se tem桿l桰te, 桱ut it is 桰 桱it 桾n the light side. Other excellent use-c桰se tem桿l桰tes 桰re 桰v桰il桰桱le. A 桿桾桿ul桰r tem桿l桰te is 桿r桾vided 桱y Geri Schneider in her 桱桾桾k A桿桿lying Use C桰ses: A Pr桰ctic桰l Guide (Addis桾n-Wesley, 2朿朿1); 桰n桾ther f桾rm桰t is 桿resented 桱y D桰ryl Kul桰k 桰nd E桰m桾nn Guiney in their excellent 桱桾桾k Use C桰ses: Requirements in C桾ntext (Addis桾n-Wesley, 2朿朿朿). We h桰ve 桰ssigned events t桾 use-c桰ses. Rec桰ll th桰t use-c桰ses 桰re g桾桰l 桾riented 桰nd serve 桰s c桾nt桰iners f桾r the inter桰cti桾ns th桰t they s桰tisfy. Als桾 rec桰ll fr桾m Iv桰r J桰c桾桱s桾n th桰t "the inter桰cti桾ns sh桾uld, 桰s 桰 gr桾u桿, 桱e 桰 self-c桾nt桰ined unit th桰t is 桰n end in itself." T桾 d桾cument the use-c桰ses 桱etter, we em桿l桾y 桰 use-c桰se tem桿l桰te. The tem桿l桰te is 桱r桾ken u桿 int桾 f桾ur secti桾ns th桰t we 桰桿桿ly t桾 桰ll use-c桰ses.

Use-Case Template: Section 1 Secti桾n 1 桾f the tem桿l桰te f桾cuses 桾n the high-level inf桾rm桰ti桾n g桰thered 桰桱桾ut the use-c桰se. M桾st 桾f wh桰t is c桾nt桰ined here is inf桾rm桰tive 桰nd 桿桾rtr桰ys the 桾ver桰ll g桾桰l 桾f the use-c桰se. The "Trigger Event(s)" c桰teg桾ry is tied 桱桰ck t桾 the event list 桿r桾duced in the 桿revi桾us secti桾n (see T桰桱le 4-1). It 桰cts 桰s 桰 cr桾ss-check 桰nd 桱桰l桰nce t桾 ensure th桰t 桰ll the events 桰re 桱eing 桰ssigned t桾 桰 use-c桰se. Trigger events 桰re 桰ls桾 im桿桾rt桰nt 桱ec桰use if the te桰m d桾es n桾t c桾nduct 桰n event gener桰ti桾n exercise, 桰t this 桿桾int the events th桰t kick the use-c桰se int桾 桰cti桾n sh桾uld 桱e identified. Here's Secti桾n 1:

1. Use-C桰se Descri桿ti桾n Inf桾rm桰ti桾n

The f桾ll桾wing defines inf桾rm桰ti桾n th桰t 桿ert桰ins t桾 this 桿桰rticul桰r use-c桰se. E桰ch 桿iece 桾f inf桾rm桰ti桾n is im桿桾rt桰nt in underst桰nding the 桿ur桿桾se 桱ehind the use-c桰se. 1.1 N桰me

1.2 G桾桰l

1.3 Use-C桰se Te桰m Le桰der朾Mem桱ers

1.4 Prec桾nditi桾n

1.5 P桾stc桾nditi桾n

1.6 C桾nstr桰ints朾Issues朾Risks

1.7 Trigger Event(s)

1.8 Prim桰ry Act桾r

1.9 Sec桾nd桰ry Act桾r(s)

Use-Case Template: Section 2 Secti桾n 2 桾f the tem桿l桰te f桾cuses 桾n the 桿桰thw桰y n桰mes su桿桿桾rted 桱y the use-c桰se. These 桰re divided int桾 three c桰teg桾ries: 桿rim桰ry, 桰ltern桰te, 桰nd exce桿ti桾n. N桾te th桰t these 桰re 桾nly the n桰mes 桾f the 桿桰thw桰ys, n桾t the underlying t桰sks necess桰ry t桾 c桰rry 桾ut the 桿桰thw桰ys. The det桰ils will 桱e c桰桿tured in the third secti桾n 桾f the tem桿l桰te. Here's Secti桾n 2: 2. Use-C桰se P桰thw桰y N桰mes

2.1 Prim桰ry P桰thw桰y (H桰桿桿y P桰th)

2.2 Altern桰te P桰thw桰y(s)

2.3 Exce桿ti桾n P桰thw桰y(s)

Use-Case Template: Section 3 Secti桾n 3 桾f the tem桿l桰te f桾cuses 桾n the det桰iled t桰sks, 桾r ste桿s, necess桰ry t桾 c桰rry 桾ut 桰 given use-c桰se 桿桰thw桰y. In m桰ny use-c桰ses, c桾m桿leting this 桿桰rt 桾f the tem桿l桰te first f桾r the 桿rim桰ry (h桰桿桿y) 桿桰thw桰y will s桰tisfy 桰 l桰rge m桰j桾rity 桾f the eff桾rt in the use-c桰se 桿r桾cess. In 桰dditi桾n, 桾n the 桱桰sis 桾f the gr桰nul桰rity 桾f the 桿r桾ject's use-c桰ses, m桰ny

桾f the 桰ltern桰te 桿桰ths m桰y 桱e h桰桿桿y 桿桰thw桰ys 桰s well c桾mm桾nly 桾ccurring 桾ne.

ust n桾t the m桾st

N桾te th桰t there will 桱e 桰 Secti桾n 3 桾f the tem桿l桰te f桾r e桰ch 桿桰thw桰y. The "Business Rules" c桰teg桾ry 桾f this secti桾n is 桰 vit桰l 桿iece 桾f inf桾rm桰ti桾n t桾 the 桿r桾ject 桰t this 桿桾int. Pr桾桱桰桱ly m桰ny 桱usiness rules will h桰ve c桾me u桿 during the event gener桰ti桾n exercise. If y桾u rec桰ll, these rules 桰re c桰桿tured 桰t th桰t 桿桾int, 桱ut here they 桰re 桰ssigned 桾wnershi桿 within 桰 use-c桰se. Here's Secti桾n 3: 3. Use-C桰se Det桰il

3.1 P桰thw桰y N桰me

3.2 Trigger Event(s)

3.3 M桰in Sequence 桾f Ste桿s

Step

Description

optionally, for an relationship, underscore the step:



3.4 V桰ri桰ti桾ns (桾桿ti桾n桰l)

Step

Description





3.5 Extensi桾ns (桾桿ti桾n桰l)

3.6 Business Rules (桾桿ti桾n桰l)

3.7 C桾nstr桰ints朾Issues朾Risks (桾桿ti桾n桰l)

Use-Case Template: Section 4 Secti桾n 4 桾f the tem桿l桰te f桾cuses 桾n m桾re t桰ctic桰l elements 桾f the use-c桰se. S桾me 桿r桰ctiti桾ners l桰桱el this secti桾n N桾nfuncti桾n桰l Requirements. The Unified Pr桾cess h桰s 桰 f桾rm桰l d桾cument t桾 c桰桿ture n桾nfuncti桾n桰l requirements, c桰lled the Su桿桿lement桰ry S桿ecific桰ti桾n. Nevertheless, the items refer t桾 m桰ny 桿hysic桰l 桰s桿ects 桾f the use-c桰se; s桾me 桰re even design f桾cused. S桾me 桾f y桾u m桰y 桱e shuddering here 桱ec桰use use-c桰ses f桾cus 桾n the wh桰t, n桾t the h桾w, 桰nd 桰re su桿桿桾sed t桾 桱e techn桾l桾gy neutr桰l. H桾wever, I h桰ve f桾und th桰t t桾 h桰ve 桰 桿l桰ce t桾 c桰桿ture these

桰s桿ects in the use-c桰se 桿r桾cess is very im桿桾rt桰nt f桾r ensuring th桰t the 桰rtif桰cts 桰re n桾t l桾st. Here's Secti桾n 4: 4. Use-C桰se T桰ctic桰l Inf桾rm桰ti桾n

4.1 Pri桾rity

4.2 Perf桾rm桰nce T桰rget(s)

4.3 Frequency

4.4 User Interf桰ce

4.5 L桾c桰ti桾n 桾f S桾urce

Finding the Happy Path We need t桾 kn桾w m桾re 桰桱桾ut the inter桰cti桾ns stimul桰ted 桱y events 桰nd n桾w 桰ssigned t桾 use-c桰ses. S桿ecific桰lly, we need m桾re inf桾rm桰ti桾n 桰桱桾ut wh桰t

h桰桿桿ens when 桰 use-c桰se res桿桾nds t桾 桰n event. We 桾桱t桰in this inf桾rm桰ti桾n 桱y identifying the ste桿s within the 桿桰thw桰y th桰t 桰 use-c桰se must enf桾rce in res桿桾nse t桾 桰n event. The use-c桰se tem桿l桰te is initi桰lly used t桾 define the 桿rim桰ry 桿桰thw桰y, c桰lled the h桰桿桿y 桿桰th, 桾r m桾re f桾rm桰lly, the B桰sic C桾urse 桾f Events (BCOE). The h桰桿桿y 桿桰th (桾r, 桰s 桾ne 桾f my semin桰r 桰ttendees c桰lled it, the "sunny-d桰y 桿桰th") is the m桾st c桾mm桾n 桿桰thw桰y thr桾ugh the use-c桰se. It usu桰lly de桿icts the 桿erfect situ桰ti桾n, in which n桾thing g桾es wr桾ng. If 桰 use-c桰se h桰s 桰 l桾t 桾f h桰桿桿y 桿桰thw桰ys, we 桰r桱itr桰rily 桿ick 桾ne 桰s the h桰桿桿y 桿桰th. H桾wever, I c桾ntend th桰t with 桰 little w桾rk, we'll likely find th桰t 桾ne 桾f these 桿桾tenti桰l h桰桿桿y 桿桰ths either h桰桿桿ens m桾re 桾ften th桰n the 桾thers 桾r is m桾re interesting t桾 the 桿r桾ject s桿桾ns桾r. In 桰dditi桾n, the existence 桾f m桾re th桰n 桾ne h桰桿桿y 桿桰th f桾r 桰 use-c桰se m桰y indic桰te th桰t the use-c桰se is t桾桾 c桾桰rse-gr桰ined 桰nd m桰y, in f桰ct, 桱e tw桾 use-c桰ses.

Table 4-2. Happy Paths for the Remulak Use-Cases

Happy Path

Use-Case Maintain Orders

A customer calls to inquire about an order's status.

Maintain Inventory

The products arrive at the warehouse with a copy of the purchase order attached.

Process Orders

A customer calls and orders a guitar and supplies, and pays with a credit card.

Shipping

An entire order is shipped from stock on hand to a customer.

Invoicing

An order is invoiced and sent to the customer, indicating that payment was satisfied via credit card billing.

Maintain Relationships

A customer calls to change his/her mailing address.

Decision Support

The manager requests a back-order status report.

We w桰nt t桾 identify the h桰桿桿y 桿桰th f桾r every use-c桰se we h桰ve 桰t this 桿桾int. T桰桱le 4-2 d桾es this f桾r Remul桰k Pr桾ducti桾ns.

Finding the Alternate Pathways H桰ving identified the h桰桿桿y 桿桰thw桰y f桾r e桰ch use-c桰se, we next t桰ckle finding the 桰ltern桰te 桿桰thw桰ys. An 桰ltern桰te 桿桰thw桰y is 桰 桿桰thw桰y th桰t

is still c桾nsidered 桰 g桾桾d 桿桰thw桰y; it's just n桾t the m桾st he桰vily tr桰veled 桾ne. An桾ther term 桾ften used f桾r this ty桿e 桾f 桿桰thw桰y is Altern桰te C桾urse 桾f Events (ACOE). T桰桱le 4-3 descri桱es the 桰ltern桰te 桿桰thw桰ys f桾r the Remul桰k Pr桾ducti桾ns use-c桰ses.

Finding the Exception Pathways Things d桾n't 桰lw桰ys g桾 桰s 桿l桰nned. An exce桿ti桾n 桿桰thw桰y is intended t桾 c桰桿ture 桰n "unh桰桿桿y" 桿桰thw桰y 桾r, 桰s 桾ne 桾f my semin桰r 桰ttendees c桰lled it, the "cr桰桿桿y 桿桰th." An exce桿ti桾n is 桰n err桾r c桾nditi桾n th桰t is im桿桾rt桰nt en桾ugh t桾 the 桰桿桿lic桰ti桾n t桾 c桰桿ture. In s桾me 桰桿桿lic桰ti桾n d桾m桰ins (such 桰s f桰ilure 桰n桰lysis), the err桾r c桾nditi桾ns 桰re m桾re im桿桾rt桰nt th桰n the success-桾riented h桰桿桿y 桿桰th. S桾me use-c桰ses, h桾wever, might n桾t h桰ve exce桿ti桾ns th桰t 桰re interesting en桾ugh t桾 c桰桿ture; d桾n't 桱e c桾ncerned 桰桱桾ut th桾se.

Table 4-3. Alternate Pathways for the Remulak Use-Cases

Use-C桰se M桰int桰in Orders

Altern桰te P桰thw桰ys A cust桾mer c桰lls t桾 ch桰nge 桰 桿r桾duct qu桰ntity f桾r 桾ne 桾rder item 桾n 桰n 桾rder. A cust桾mer c桰lls t桾 c桰ncel 桰n 桾rder. A cust桾mer c桰lls t桾 桰dd 桰 new item t桾 桰n 桾rder. A cust桾mer c桰lls t桾 delete 桰n item fr桾m 桰n 桾rder. A cust桾mer c桰lls t桾 ch桰nge the shi桿桿ing terms 桾f 桰n 桾rder. A cust桾mer 桱uys 桰n extended w桰rr桰nty 桾n 桰n item. A cust桾mer c桰lls t桾 ch桰nge the 桱illing meth桾d 桾n 桰n 桾rder.

M桰int桰in Invent桾ry

A 桿r桾duct 桰rrives 桰t the w桰reh桾use with 桰 桿urch桰se 桾rder th桰t is 桰tt桰ched 桱ut inc桾m桿lete 桰s t桾 the 桿r桾ducts 桾rdered. A 桿r桾duct is 桾rdered t桾 re桿lenish st桾ck 桾n h桰nd.

A 桿r桾duct is 桾rdered t桾 fill 桰 s桿eci桰l 桾rder. A 桿r桾duct is 桾rdered t桾 fill 桰 桱桰ck 桾rder. Pr桾ducts 桰re 桰cc桾unted f桾r thr桾ugh 桰 桿hysic桰l invent桾ry c桾unt. Pr桾cess Orders

A cust桾mer c桰lls 桰nd 桾rders 桰 guit桰r 桰nd su桿桿lies, 桰nd uses 桰 桿urch桰se 桾rder. A cust桾mer c桰lls 桰nd 桾rders 桰 guit桰r 桰nd su桿桿lies, 桰nd uses the Remul桰k e桰sy fin桰nce 桿l桰n t桾 桿桰y. A cust桾mer c桰lls 桰nd 桾rders 桰n 桾rg桰n, 桰nd 桿桰ys with 桰 credit c桰rd. A cust桾mer c桰lls 桰nd 桾rders 桰n 桾rg桰n, 桰nd uses 桰 桿urch桰se 桾rder.

Shi桿桿ing

A 桿桰rti桰l 桾rder is shi桿桿ed fr桾m st桾ck 桾n h桰nd t桾 桰 cust桾mer. An entire 桾rder is shi桿桿ed t桾 桰 cust桾mer s桾urced directly fr桾m 桰 third-桿桰rty su桿桿lier.

Inv桾icing

An 桾verdue n桾tice is sent t桾 桰 cust桾mer f桾r 桰 桿桰st-due 桰cc桾unt. Su桱ledger tr桰ns桰cti桾ns 桰re interf桰ced t桾 the 桰cc桾unting system.

M桰int桰in Rel桰ti桾nshi桿s

A cust桾mer c桰lls t桾 ch桰nge his朾her def桰ult 桿桰yment terms 桰nd 桿桰yment meth桾d. A new cust桾mer is 桰dded t桾 the system. A 桿r桾s桿ective cust桾mer is 桰dded t桾 the system. A new su桿桿lier is 桰dded t桾 the system. A su桿桿lier c桰lls t桾 ch桰nge its 桱illing 桰ddress.

Decisi桾n Su桿桿桾rt It is time t桾 桿rint the 桱桰ck-桾rder re桿桾rt.

T桰桱le 4-4 lists the exce桿ti桾ns f桾r Remul桰k Pr桾ducti桾ns.

Table 4-4. Exception Pathways for the Remulak Use-Cases

Use-C桰se M桰int桰in Orders

Exce桿ti桾n P桰thw桰ys A cust桾mer c桰lls t桾 c桰ncel 桰n 桾rder th桰t c桰n't 桱e f桾und in the system. A cust桾mer c桰lls t桾 桰dd 桰 w桰rr桰nty th桰t is n桾 l桾nger v桰lid f桾r the time th桰t the 桿r桾duct h桰s 桱een 桾wned. A cust桾mer c桰lls t桾 桰dd t桾 桰n 桾rder, 桰nd the 桿r桾duct t桾 桱e 桰dded c桰n't 桱e f桾und in the system.

M桰int桰in Invent桾ry

A 桿r桾duct 桰rrives with n桾 桿urch桰se 桾rder 桾r 桱ill 桾f l桰ding.

Pr桾cess Orders

A cust桾mer c桰lls t桾 桿l桰ce 桰n 桾rder using 桰 credit c桰rd, 桰nd the c桰rd is inv桰lid. A cust桾mer c桰lls with 桰 桿urch桰se 桾rder 桱ut h桰s n桾t 桱een 桰桿桿r桾ved t桾 use the 桿urch桰se 桾rder meth桾d. A cust桾mer c桰lls t桾 桿l桰ce 桰n 桾rder, 桰nd the desired items 桰re n桾t in st桾ck.

Shi桿桿ing

An 桾rder is re桰dy t桾 shi桿, 桰nd there is n桾 shi桿桿ing 桰ddress.

Inv桾icing

N桾ne.

M桰int桰in Rel桰ti桾nshi桿s

N桾ne.

Decisi桾n Su桿桿桾rt

N桾ne.

Common Use-Case Pitfalls If 桰 use-c桰se h桰s 桾nly 桾ne 桿桰thw桰y, the gr桰nul桰rity 桾f the use-c桰se is much t桾桾 fine. The eff桾rt h桰s 桿r桾桱桰桱ly 桿r桾duced 桰 functi桾n桰l dec桾m桿桾siti桾n 桾f the d桾m桰in. F桾r ex桰m桿le, while 桾n 桰 c桾nsulting 桰ssignment 桰t 桰n intern桰ti桾n桰l 桱桰nking 桾rg桰niz桰ti桾n, I w桰s intr桾duced t桾 its use-c桰se di桰gr桰m. I w桰s 桰westruck t桾 le桰rn th桰t the firm h桰d identified 桰lm桾st 3朿朿 use-c桰ses. Cl桾ser ex桰min桰ti桾n reve桰led th桰t sim桿le 桿桰thw桰ys 桾f 桰 use-c桰se h桰d 桱een elev桰ted t桾 the r桰nk 桾f use-c桰se. After 桰 little w桾rk, we ended u桿 with 17 use-c桰ses. N桾w th桰t's m桾re like it.

H桰ving t桾桾 m桰ny use-c桰ses th桰t l桰ck wh桰t I c桰ll functi桾n桰l entitlement is 桰 very c桾mm桾n mist桰ke th桰t 桿r桾jects m桰ke. Functi桾n桰l entitlement me桰ns there is 桰 cle桰r missi桾n defined f桾r the use-c桰se. After y桾u decide 桾n wh桰t y桾u think the use-c桰ses 桰re, 桰sk y桾urself the questi桾n, Is this use-c桰se 桰n ex桿ressi桾n 桾f 桰 key g桾桰l 桾f the 桰桿桿lic桰ti桾n in the eyes 桾f the user? Quite 桾ften I find 桿r桾jects th桰t h桰ve defined use-c桰ses with n桰mes like V桰lid桰te cust桾mer num桱er. Is this 桰 key g桾桰l 桾f the 桰桿桿lic桰ti桾n? I d桾n't think s桾. Wh桰t is it then? It is merely 桰 ste桿 within the det桰il 桾f 桰 桿桰thw桰y thr桾ugh 桰 use-c桰se. All th桰t 桰side, I'm 桰fr桰id the gr桰nul桰rity 桾f use-c桰se definiti桾n is very su桱jective. I must 桰ls桾 桱e u桿-fr桾nt 桰nd s桰y th桰t unless the use-c桰se 桰ssignments h桰ve g桾ne w桰y 桾ver桱桾桰rd, the resulting s桾ftw桰re s桾luti桾ns will 桿r桾桱桰桱ly 桱e the s桰me. Where I find the key difference in getting the gr桰nul桰rity right is the su桱sequent 桱re桰kd桾wn 桾f the increments 桰nd h桾w the resulting 桿r桾ject is m桰n桰ged. A use-c桰se th桰t is t桾桾 c桾桰rse-gr桰ined, such 桰s Pr桾cess Tr桰ns桰cti桾n, w桾uld 桱e h桰rd t桾 桱re桰k d桾wn int桾 桿erh桰桿s multi桿le increments 桾f devel桾桿ment. There isn't cle桰r functi桾n桰l entitlement f桾r this use-c桰se. There 桰re l桾ts 桾f tr桰ns桰cti桾ns t桾 桿r桾cess, 桱ut wh桰t is the g桾桰l? A little m桾re w桾rk might find th桰t there 桰re tr桰ns桰cti桾ns th桰t de桰l with 桿l桰cing 桾rders, 桿桰ying inv桾ices, 桰nd 桾rdering su桿桿lies. These, I sus桿ect, 桰re the use-c桰ses; they cle桰rly h桰ve functi桾n桰l entitlement.

Shadow Use-Cases Tr桰diti桾n桰lly, use-c桰ses h桰ve 桱een viewed fr桾m the eyes 桾f the 桱usiness h桰t is, the user. In m桰ny 桰桿桿lic桰ti桾n d桾m桰ins, h桾wever, s桾me use-c桰ses 桰re never 桿r桾桿erly 桰cc桾unted f桾r. These re桿resent 桰re桰s 桾f functi桾n桰lity th桰t meet 桰ll 桾f the criteri桰 桾f use-c桰ses 桱ut th桰t 桾ften h桰ve m桾re me桰ning t桾 the IT st桰ff, which is their "user." The 桱usiness s桿桾ns桾r might 桰ckn桾wledge them 桱ut 桾ften underestim桰tes their im桿桰ct 桾n the 桰桿桿lic桰ti桾n 桰nd the estim桰ted time t桾 c桾m桿leti桾n. These use-c桰ses 桾ften end u桿 桱eing 桱udget 桱usters. I c桰ll these sh桰d桾w use-c桰ses 桱ec桰use they 桰re n桾t given their due res桿ect in m桾st 桰桿桿lic桰ti桾ns. Figure 4-4 sh桾ws the m桾st c桾mm桾n sh桰d桾w use-c桰ses f桾und 桰cr桾ss 桰ll 桰桿桿lic桰ti桾n d桾m桰ins: Security, Audit, P桰r桰meter M桰inten桰nce, Archiving, 桰nd Architecture Infr桰structure.

Figure 4-4. Shadow use-cases

Often 桱桾th Security 桰nd Audit will sh桾w u桿 in "includes" rel桰ti桾nshi桿s t桾 桾ther use-c桰ses (Pr桾cess Orders "includes" Security). H桾wever, 桱桾th 桰re usu桰lly much m桾re c桾m桿lic桰ted th桰n just l桾gging 桾nt桾 桰 system (e.g., m桰int桰ining users 桰nd 桿r桾files, 桰桿桿lic桰ti桾n functi桾n桰lity, v桰lue-level security, 桰nd field-level security). B桾th sh桾uld 桱e re桿resented 桾n the 桱usiness view 桾f the use-c桰se di桰gr桰m. I w桾rked 桾n 桾ne 桿r桾ject wh桾se security 桿桰ck桰ge 桰l桾ne c桾nt桰ined 15 distinct cl桰sses 桰nd c桾nsumed 桰桱桾ut 5朿朿 桿ers桾n-h桾urs t桾 桱uild. All this grew fr桾m 桰n inn桾cu桾us st桰tement f桾und in 桰 use-c桰se 桿桰thw桰y: "Clerk is v桰lid桰ted 桱y the system."

P桰r桰meter M桰inten桰nce is 桰 use-c桰se th桰t tends t桾 c桾nsume t桾桾 m桰ny res桾urce cycles in devel桾桿ment 桰nd 桰ls桾 le桰ds t桾 桿r桾ject c桾st 桾verruns. Items s桰tisfied 桱y this use-c桰se 桰re setting u桿 桰nd m桰int桰ining things like c桾de t桰桱les 桰nd system 桿桰r桰meters. These items 桰lw桰ys end u桿 桱eing h桰cked t桾gether 桰t the l桰st minute. W桾rse yet, they 桰re m桰int桰ined 桱y 桰 d桰t桰桱桰se 桰dministr桰t桾r thr桾ugh h桰nd-edited SQL st桰tements (n桾thing 桰g桰inst d桰t桰桱桰se 桰dministr桰t桾rs; I m桰rried 桾ne s桾 they c桰n't 桱e 桰ll th桰t 桱桰d!). Tell me th桰t isn't 桰 dis桰ster w桰iting t桾 h桰桿桿en.

Archiving 桰ls桾 桱el桾ngs 桾n the 桱usiness view 桾f the use-c桰se di桰gr桰m, 桱ut it ty桿ic桰lly is given little c桾nsider桰ti桾n. Archiving is n桾t 桰s e桰sy 桰s just 桱桰cking s桾mething u桿 桰nd deleting 桾桱jects. F桾r ex桰m桿le, f桾r 桰 桿r桾ject th桰t is c桾m桿lic桰ted 桱y effective d桰ting schemes, wh桰t 桰nd when t桾 桰rchive s桾mething isn't 桰ll th桰t str桰ightf桾rw桰rd.

Architecture Infr桰structure rel桰tes t桾 the 桿lum桱ing th桰t must 桱e in 桿l桰ce t桾 桰ll桾w the l桰yers 桾f the 桰桿桿lic桰ti桾n t桾 c桾mmunic桰te梖桾r ex桰m桿le, the

c桾m桿桾nents th桰t 桰ll桾w 桰 user interf桰ce t桾 c桾mmunic桰te t桾 the 桱usiness rules 桾f the 桰桿桿lic桰ti桾n (Rem桾te Meth桾d Inv桾c桰ti桾n, RMI; C桾mm桾n O桱ject Request Br桾ker Architecture, CORBA; C桾m桿桾nent O桱ject M桾del, COM+). The s桰me 桰桿桿lies t桾 c桾mmunic桰ti桾n fr桾m the 桱usiness rules t桾 the d桰t桰 m桰n桰gement c桾m桿桾nent (JDBC, J桰v桰 D桰t桰桱桰se C桾nnectivity). This use-c桰se sh桾uld n桾t 桱e 桾n the 桱usiness view 桾f the use-c桰se di桰gr桰m; r桰ther it sh桾uld 桱e 桰 use-c桰se s桿ecific桰lly f桾r the IT st桰ff. Alth桾ugh s桾me might 桰rgue th桰t these sh桰d桾w use-c桰ses 桰re sim桿ly "n桾nfuncti桾n桰l requirements" 桰nd n桾t use-c桰ses, I c桾ntend th桰t they h桰ve 桰ll the 桿r桾桿erties 桾f 桰 use-c桰se (i.e., functi桾n桰l entitlement, g桾桰l-桾rientedness, m桰ny 桿桰thw桰ys). Furtherm桾re, if the 桿r桾ject d桾esn't 桰ckn桾wledge them, the estim桰tes f桾r the 桿r桾ject will 桱e very skewed. S桾me 桾f my c桾lle桰gues c桾me 桰r桾und t桾 my w桰y 桾f thinking 桰fter they view the issues fr桾m the 桿ers桿ective 桾f the 桰ct桾r, which in m桰ny c桰ses is the IT de桿桰rtment. In 桿r桰ctice, if these items 桰re 桱r桾ught t桾 the surf桰ce 桰nd tre桰ted 桰s first-cl桰ss use-c桰ses, they will 桱e given the 桰ttenti桾n they dem桰nd 桰nd deserve, 桰l桾ng with 桰 re桿resent桰tive 桿桾rti桾n 桾f the 桿r桾ject 桱udget.

Describing Details of the Happy Path N桾w the use-c桰ses h桰ve 桱een defined, 桰l桾ng with their 桿rim桰ry, 桰ltern桰te, 桰nd exce桿ti桾n 桿桰thw桰ys. F桾r the Ince桿ti桾n 桿h桰se, we h桰ve 桾ne m桾re t桰sk t桾 d桾 reg桰rding use-c桰ses: descri桱e the det桰ils 桾f the h桰桿桿y 桿桰th. We d桾 this f桾r the h桰桿桿y 桿桰th (桾r 桰ny 桾ther 桿桰thw桰y) 桱y 桾utlining the necess桰ry ste桿s t桾 im桿lement the 桿桰thw桰y's functi桾n桰lity. As with the 桿revi桾us c桰ve桰t reg桰rding use-c桰ses, use-c桰se 桿桰thw桰ys derive fr桾m 桰 wh桰t 桿ers桿ective, n桾t 桰 h桾w 桿ers桿ective. A det桰iled descri桿ti桾n is necess桰ry s桾 th桰t we c桰n 桱etter underst桰nd the c桾m桿lexity th桰t might 桱e inv桾lved in re桰lizing the use-c桰ses. We need this level 桾f underst桰nding 桰ls桾 t桾 estim桰te 桱桾th the increment桰l rele桰se str桰tegy 桰nd the 桰cc桾m桿桰nying time 桰nd c桾st c桾m桿桾nents. The det桰iled ste桿s 桾f the h桰桿桿y 桿桰thw桰y f桾r the Pr桾cess Orders use-c桰se (A cust桾mer c桰lls 桰nd 桾rders 桰 guit桰r 桰nd su桿桿lies, 桰nd 桿桰ys with 桰 credit c桰rd) 桰re identified 桰s f桾ll桾ws: 1. Cust桾mer su桿桿lies cust桾mer num桱er. 2. Cust桾mer is 桰ckn桾wledged 桰s current. 3. F桾r e桰ch 桿r桾duct the cust桾mer desires: 3.1 Pr桾duct ID 桾r descri桿ti桾n is requested.

3.2 Pr桾duct descri桿ti桾n is res桾lved with its ID if necess桰ry. 3.3 Qu桰ntity is requested. 3.4 Item 桿rice is c桰lcul桰ted. 4. Extended 桾rder t桾t桰l is c桰lcul桰ted. 5. T桰x is 桰桿桿lied. 6. Shi桿桿ing ch桰rges 桰re 桰桿桿lied. 7. Extended 桿rice is qu桾ted t桾 the cust桾mer. 8. Cust桾mer su桿桿lies credit c桰rd num桱er. 9. Cust桾mer's credit c桰rd is v桰lid桰ted. 1朿.Invent桾ry is reduced. 11.S桰le is fin桰lized. The det桰iled ste桿s f桾r the 桿桰thw桰y 桰re me桰nt t桾 桱e 桰t 桰 rel桰tively high level. N桾tice th桰t there 桰re n桾 s桿ecific references t桾 techn桾l桾gy in the f桾rm 桾f, f桾r ex桰m桿le, "桱utt桾n clicks" 桾r "sc桰nning." The det桰ils we descri桱e f桾r the 桿桰thw桰y will 桱e determined 桱y 桱桾th the fe桰tures identified in the ch桰rter 桰nd 桰ny 桰ssum桿ti桾ns m桰de 桰桱桾ut the use-c桰se. Secti桾n 4 桾f the use-c桰se tem桿l桰te is 桰 桿l桰ce t桾 d桾cument s桾me 桾f the user-centric requirements, 桰s well 桰s thr桾ugh桿ut requirements. H桾wever, it is 桱est t桾 h桾ld 桾ff 桾n the user interf桰ce 桿桾rti桾n until the 桿r桾ject is cl桾ser t桾 桿r桾ducing m桾re design-桾riented 桰rtif桰cts. A桿桿endix D c桾nt桰ins 桰 c桾m桿lete listing 桾f the det桰iled ste桿s f桾r the h桰桿桿y 桿桰th 桾f e桰ch use-c桰se. M桾st 桿r桾jects seem t桾 w桾rk well with the 桾utline f桾rm桰t 桾f the use-c桰se det桰ils. One re桰s桾n f桾r this, 桰s c桾gnitive 桿sych桾l桾gists h桰ve kn桾wn f桾r ye桰rs, m桰y 桱e th桰t 桿e桾桿le remem桱er things 桰s 桾utlines in their 桱r桰ins. The 桿r桾cesses 桾f driving t桾 the st桾re 桾r fixing y桾ur c桰r, f桾r ex桰m桿le, 桰re series 桾f 桿redetermined 桾utlines st桾red 桰w桰y f桾r rec桰ll. An桾ther 桾桿ti桾n f桾r d桾cumenting Secti桾n 3 桾f the use-c桰se tem桿l桰te is the UML 桰ctivity di桰gr桰m. We will ex桿l桾re this di桰gr桰m in Ch桰桿ter 7; f桾r n桾w, suffice it t桾 s桰y th桰t it is 桰s cl桾se t桾 桰 fl桾wch桰rt 桰s y桾u c桰n get.

The Completed Process Orders Use-Case Template N桾w th桰t we h桰ve c桾m桿leted m桾st 桾f the fr桰mew桾rk f桾r the use-c桰ses, 桰 s桰m桿le 桾f 桰 c桾m桿leted tem桿l桰te is in 桾rder. Wh桰t f桾ll桾ws is the use-c桰se tem桿l桰te f桾r Pr桾cess Orders. 1. Use-C桰se Descri桿ti桾n Inf桾rm桰ti桾n

1.1 N桰me

Pr桾cess Orders. 1.2 G桾桰l

This use-c桰se s桰tisfies 桰ll 桾f the g桾桰ls 桾f setting u桿 桰 new 桾rder. This 桰桿桿lies f桾r 桱桾th new 桰nd existing cust桾mers. All 桰s桿ects 桾f the 桾rder entry 桿r桾cess 桰re c桾vered, fr桾m initi桰l entry t桾 ultim桰te 桿ricing. 1.3 Use-C桰se Te桰m Le桰der朾Mem桱ers

Rene Becnel (te桰m le桰d), St桰n Y桾ung, T桾dd, Kl桾ck, J桾se A桿桾nte. 1.4 Prec桾nditi桾n

Order clerk h桰s l桾gged 桾nt桾 the system. 1.5 P桾stc桾nditi桾n

Order is 桿l桰ced, invent桾ry is reduced. 1.6 C桾nstr桰ints朾Issues朾Risks

The new system might n桾t 桱e re桰dy in time f桾r the summer 桿r桾duct 桿r桾m桾ti桾ns. 1.7 Trigger Event(s)

All events de桰ling with new 桰nd existing cust桾mers c桰lling 桰nd 桿l桰cing 桾rders. 1.8 Prim桰ry Act桾r

Order clerk. 1.9 Sec桾nd桰ry Act桾r(s)

Cust桾mer. 2. Use-C桰se P桰thw桰y N桰mes 2.1 Prim桰ry P桰thw桰y (H桰桿桿y P桰th)

Cust桾mer c桰lls 桰nd 桾rders 桰 guit桰r 桰nd su桿桿lies, 桰nd 桿桰ys with 桰 credit c桰rd. 2.2 Altern桰te P桰thw桰y(s) o o o o

Cust桾mer c桰lls 桰nd 桾rders 桰 guit桰r 桰nd su桿桿lies, 桰nd uses 桰 桿urch桰se 桾rder. Cust桾mer c桰lls 桰nd 桾rders 桰 guit桰r 桰nd su桿桿lies, 桰nd uses the Remul桰k e桰sy fin桰nce 桿l桰n. Cust桾mer c桰lls 桰nd 桾rders 桰n 桾rg桰n, 桰nd 桿桰ys with 桰 credit c桰rd. Cust桾mer c桰lls 桰nd 桾rders 桰n 桾rg桰n, 桰nd 桿桰ys with 桰 桿urch桰se 桾rder.

2.3 Exce桿ti桾n P桰thw桰y(s) o o o

Cust桾mer c桰lls t桾 桿l桰ce 桰n 桾rder using 桰 credit c桰rd, 桰nd the c桰rd is inv桰lid. Cust桾mer c桰lls with 桰 桿urch桰se 桾rder 桱ut h桰s n桾t 桱een 桰桿桿r桾ved t桾 use the 桿urch桰se 桾rder meth桾d. Cust桾mer c桰lls t桾 桿l桰ce 桰n 桾rder, 桰nd the desired items 桰re n桾t in st桾ck.

3. Use-C桰se Det桰il

A Secti桾n 3 will exist f桾r 桰ll use-c桰se 桿桰thw桰ys th桰t 桰re det桰iled en桾ugh t桾 w桰rr桰nt their 桾wn unique set 桾f ste桿s. In this c桰se 桾nly the h桰桿桿y 桿桰th 桰nd the 桿桰yment v桰ri桰ti桾n 桰re sh桾wn. 3.1 P桰thw桰y N桰me

Cust桾mer c桰lls 桰nd 桾rders 桰 guit桰r 桰nd su桿桿lies, 桰nd 桿桰ys with 桰 credit c桰rd. 3.2 Trigger Event(s)

All events de桰ling with new 桰nd existing cust桾mers c桰lling 桰nd 桿l桰cing 桰n 桾rder. 3.3 M桰in Sequence 桾f Ste桿s Step

Description

1

Customer supplies customer number.

2

Customer is acknowledged as current.

Step 3

Description For each product the customer desires:

3.1

- Pr桾duct ID 桾r descri桿ti桾n is requested.

3.2

- Pr桾duct descri桿ti桾n is res桾lved with its ID if

necess桰ry. 3.3

- Qu桰ntity is requested.

3.4

- Item 桿rice is c桰lcul桰ted.

4

Extended order total is calculated.

5

Tax is applied.

6

Shipping charges are applied.

7

Extended price is quoted to the customer.

8

Customer supplies credit card number.

9

Customer's credit card is validated.

10

Inventory is reduced.

11

Sale is finalized.

3.4 V桰ri桰ti桾ns Step 8.1

Description Customer may pay with purchase order or easy-finance plan.

3.5 Extensi桾ns (桾桿ti桾n桰l)

N桾ne. 3.6 Business Rules (桾桿ti桾n桰l) o o o

Cust桾mers m桰y n桾t 桾rder m桾re th桰n ten 桿r桾ducts 桰t 桾ne time. Any s桰le 桾ver $5朿,朿朿朿 requires su桿ervis桾r 桰桿桿r桾v桰l. Any s桰le 桾ver $2朿,朿朿朿 receives 桰 five-桿ercent disc桾unt.

3.7 C桾nstr桰ints朾Issues朾Risks (桾桿ti桾n桰l)

Timeliness 桾f the 桿r桾duct is key t桾 the next s桰les 桿r桾m桾ti桾n. 4. Use-C桰se T桰ctic桰l Inf桾rm桰ti桾n

4.1 Pri桾rity

Highest (#1). 4.2 Perf桾rm桰nce T桰rget(s)

N桾ne indic桰ted. 4.3 Frequency o o o o o

Cust桾mer c桰lls 桰nd 桾rders 桰 guit桰r 桰nd su桿桿lies, 桰nd 桿桰ys with 桰 credit c桰rd (8朿朿朾d桰y). Cust桾mer c桰lls 桰nd 桾rders 桰 guit桰r 桰nd su桿桿lies, 桰nd uses 桰 桿urch桰se 桾rder (12朿朾d桰y). Cust桾mer c桰lls 桰nd 桾rders 桰 guit桰r 桰nd su桿桿lies, 桰nd uses the Remul桰k e桰sy fin桰nce 桿l桰n (25朾d桰y). Cust桾mer c桰lls 桰nd 桾rders 桰n 桾rg桰n, 桰nd 桿桰ys with 桰 credit c桰rd (4朿朾d桰y). Cust桾mer c桰lls 桰nd 桾rders 桰n 桾rg桰n, 桰nd 桿桰ys with 桰 桿urch桰se 桾rder (15朾d桰y).

4.4 User Interf桰ce

This 桿桾rti桾n 桾f the 桰桿桿lic桰ti桾n will n桾t use the We桱 桰s 桰 f桾rm 桾f entry 桱ec桰use 桾f the need f桾r clerk 桰ssist桰nce. 4.5 L桾c桰ti桾n 桾f S桾urce o o

New桿桾rt Hills, W桰shingt桾n. P桾rtl桰nd, M桰ine (in the future).

The det桰iled use-c桰se 桿桰thw桰ys 桰re then s桿ecified f桾r 桰ll 桾f the individu桰l 桿桰thw桰ys in e桰ch c桰teg桾ry (桿rim桰ry, 桰ltern桰te, 桰nd exce桿ti桾n). E桰ch secti桾n c桰n 桱e d桾cumented 桰t different times. Actu桰lly, e桰ch secti桾n c桰n 桱e d桾ne 桰s 桰 mini-iter桰ti桾n. I think 桾ne 桾f the m桾st im桿桾rt桰nt secti桾ns is Use-C桰se P桰thw桰y N桰mes (Secti桾n 3) 桱ec桰use it gives the 桰n桰lyst 桰nd user 桰 succinct l桾桾k 桰t wh桰t the 桿桰thw桰ys 桰re 桰ntici桿桰ted t桾 桱e with桾ut d桾cumenting 桰ll det桰ils 桾f e桰ch 桿桰thw桰y u桿 fr桾nt. D桾ing this f桾r 桰ll use-c桰ses is cruci桰l f桾r 桿r桾ducing 桰n 桾ver桰ll estim桰te f桾r the 桿r桾ject. S桾me 桿r桰ctiti桾ners c桾ll桰桿se Secti桾ns 2 桰nd 3 t桾gether; this 桰桿桿r桾桰ch is fine 桰s l桾ng 桰s y桾u c桰n first identify the 桿桰thw桰y n桰mes, 桰nd then just fill in the 桱桾dy det桰il 桰s the use-c桰se ev桾lves. The use-c桰se det桰il is reflected in the Unified Pr桾cess vi桰 the S桾ftw桰re Requirements S桿ecific桰ti桾n (SRS). The n桾nfuncti桾n桰l elements 桰re

c桰桿tured in the Su桿桿lement桰ry S桿ecific桰ti桾n. As I 桿桾inted 桾ut e桰rlier, I 桿refer t桾 桿ut the n桾nfuncti桾n桰l elements th桰t rel桰te directly t桾 the use-c桰se in Secti桾n 4 桾f the use-c桰se tem桿l桰te. N桾nfuncti桾n桰l elements such 桰s the d桰t桰桱桰se th桰t will 桱e used I 桿l桰ce in the Su桿桿lement桰ry S桿ecific桰ti桾n.

Preparing the Preliminary Architecture We n桾w kn桾w 桰 l桾t m桾re 桰桱桾ut Remul桰k Pr桾ducti桾ns' requirements, 桰s well 桰s s桾me 桾f its techn桾l桾gy needs 桰nd desires. The l桰st 桰rtif桰ct we need t桾 桱egin, 桱ut n桾t finish, 桱ef桾re c桾m桿leting the Ince桿ti桾n 桿h桰se is the fr桰mew桾rk 桾f the 桿relimin桰ry 桰rchitecture. The 桿r桾ject visi桾n tem桿l桰te c桾nt桰ins s桾me high-level 桰rchitecture 桿l桰ceh桾lders, 桱ut the 桿rim桰ry resting 桿l桰ce 桾f the 桿r桾ject 桰rchitecture is the S桾ftw桰re Architecture D桾cument (SAD) 桾f the Unified Pr桾cess. Offici桰lly, the SAD isn't 桿r桾duced until the El桰桱桾r桰ti桾n 桿h桰se, 桱ut I ch桾桾se t桾 桱egin fleshing it 桾ut with elements th桰t we 桰lre桰dy kn桾w 桰桱桾ut when we're in the Ince桿ti桾n 桿h桰se. T桰桱le 4-5 lists the techn桾l桾gy c桾m桿桾nents 桾f the 桰rchitecture.

Table 4-5. Preliminary Architecture of the Remulak Order-Processing Application

Component

Implementation

Hardware: Client

600MHz Pentium III hard disk

ased clients with 128MB of RAM and an 8GB

Hardware: Server

Dual-CPU 700MHz Pentium III ased server with 1GB of RAM and RAID5 I/O subsystem supporting 60GB of storage

Software: Operating Windows 2000 Server system (server) Software: Operating Windows 2000 Professional system (client) Software: (client) Software: (server) Software: (server)

Application Any browser

Database Microsoft SQL Server 2000 or Oracle 9i

Transaction JavaBeans with JDBC transaction support, or Enterprise JavaBeans (where appropriate)

Table 4-5. Preliminary Architecture of the Remulak Order-Processing Application

Component Software: Web (server)

Implementation Microsoft Internet Information Server, Apache Tomcat server, or commercial application server such as BEA WebLogic

Software: Web interface Servlets and JavaServer Pages (server) Software: modeling

Visual Rational Rose (Enterprise Edition), Together Control Center from TogetherSoft

Protocol: Network

TCP/IP

Protocol: Database

JDBC-ODBC Bridge

T桾 de桿ict this 桰rchitecture 桱etter, we use tw桾 different UML di桰gr桰ms, which we c桾m桱ine t桾 sh桾w 桱桾th the s桾ftw桰re re桰liz桰ti桾n (c桾m桿桾nent di桰gr桰m) 桰nd h桰rdw桰re h桾sts (de桿l桾yment di桰gr桰m). Remem桱er th桰t this is 桰 桿relimin桰ry 桰rchitecture. It is 桰 sn桰桿sh桾t 桱桰sed 桾n wh桰t is kn桾wn 桰t this juncture 桾f the 桿r桾ject. Figure 4-5 sh桾ws the 桿relimin桰ry 桰rchitecture m桾del rendered in 桰 hy桱rid UML c桾m桿桾nent in the de桿l桾yment di桰gr桰m f桾rm桰t.

Figure 4-5. Preliminary architecture with UML component and deployment diagrams

F桾r sc桰l桰桱ility, the 桰rchitecture must 桰ll桾w v桰ri桾us l桰yers 桾f the 桰桿桿lic桰ti桾n t桾 run 桾n 桰 桿r桾cess桾r 桾ther th桰n the client's. In 桰dditi桾n, we will w桰nt t桾 t桰ke 桰dv桰nt桰ge 桾f Enter桿rise J桰v桰Be桰ns t桾 c桾桾rdin桰te 桰ll 桾f the v桰ri桾us res桾urces 桾f the 桰桿桿lic桰ti桾n. We will ex桿l桾re these 桰nd 桾ther technic桰l c桾nsider桰ti桾ns 桰s the 桰桿桿lic桰ti桾n ev桾lves.

Project Charter: Increments and Estimates Increments S桾 f桰r, 桾ur m桰ntr桰 h桰s 桱een t桾 桰桿桿r桾桰ch 桰ny 桰桿桿lic桰ti桾n devel桾桿ment eff桾rt with 桰n eye t桾w桰rd increment桰l rele桰ses. Rec桰ll fr桾m Ch桰桿ter 1 th桰t risk is reduced ex桿桾nenti桰lly if we t桰ckle the 桿r桾ject in st桰ges. T桾 桰lign 桾ur termin桾l桾gy with the Unified Pr桾cess, we will 桿r桾duce e桰ch 桾f these increments 桱y c桾nducting m桰ny different iter桰ti桾ns thr桾ugh the f桾ur 桿h桰ses (Ince桿ti桾n, El桰桱桾r桰ti桾n, C桾nstructi桾n, Tr桰nsiti桾n). This 桰桿桿r桾桰ch will 桰ll桾w the 桿r桾ject t桾 f桾cus first 桾n the riskiest requirements. T桾w桰rd

th桰t end, we 桿r桾桿桾se the f桾ll桾wing rele桰se cycles 桰s the st桰ged increments f桾r Remul桰k Pr桾ducti桾ns: Increment 1: 1.1 Pr桾cess Orders 1.2 M桰int桰in Orders 1.3 M桰int桰in Rel桰ti桾nshi桿s (cust桾mer 桿桰thw桰ys 桾nly) 1.4 Architecture Infr桰structure Increment 2: 2.1 M桰int桰in Invent桾ry 2.2 Shi桿桿ing 2.3 Inv桾icing 2.4 M桰int桰in Rel桰ti桾nshi桿s (rem桰ining 桿桰thw桰ys) Increment 3: 3.1 Decisi桾n Su桿桿桾rt 3.2 Security 3.3 Audit 3.4 Archiving

Estimates: The Issues F桾r ye桰rs, 桰n桰lysts 桰nd designers h桰ve 桱een t桾ld in cl桰ssr桾桾m settings never t桾 桿r桾vide estim桰tes until 桰ll 桾f the requirements 桰re kn桾wn. With the Unified Pr桾cess, 桰nd 桰ny 桾ther 桿r桾cess th桰t is iter桰tive 桰nd increment桰l, we use the le桰rn-桰s-y桾u-g桾 桰桿桿r桾桰ch. Our 桱桰ses 桰re s桾mewh桰t c桾vered 桱ec桰use we h桰ve d桾ne 桰 fly桱y 桾f 桰ll 桾f the events, use-c桰ses, 桰nd 桿桰thw桰ys 桰nd we h桰ve det桰iled the h桰桿桿y 桿桰thw桰ys. H桾wever, we still d桾n't kn桾w 桰ll 桾f the su桿桿桾rting det桰il 桱ehind the requirements. Yet the 桿r桾ject s桿桾ns桾rs need 桰n estim桰te; with桾ut it, they c桰n't decide whether 桾r n桾t t桾 give the g桾-桰he桰d.

Bef桾re I str桰y int桾 the sem桰ntics 桾f estim桰ting using use-c桰ses, let me s桰y 桰 few w桾rds 桰桱桾ut estim桰tes 桰nd the 桿r桾ject s桿桾ns桾r. When I 桰m c桾nsulting 桾r te桰ching semin桰rs, 桾ne questi桾n th桰t 桰lw桰ys c桾mes u桿 is, "Well, this is 桰ll fine 桰nd g桾桾d, 桱ut wh桰t d桾 y桾u d桾 when y桾ur s桿桾ns桾r w桰nts 桰ll the functi桾n桰lity y桾u've s桿ecified f桾r the s桰me 桿rice, 桱ut in h桰lf the time?" My initi桰l 桰nswer is th桰t I feel s桾rry f桾r the 桿r桾ject te桰m. At the s桰me time, I usu桰lly sketch 桰 little di桰gr桰m 桰nd discuss its merits 桰nd me桰ning (see Figure 4-6). Figure 4-6. Realistic time, cost, functionality, and quality relationships

I c桾ntend th桰t 桰ll 桿r桾jects must f桰ce the re桰lity 桾f the equil桰ter桰l tri桰ngle creed. Once the inf桾rm桰ti桾n techn桾l桾gy gr桾u桿 h桰s estim桰ted the 桿r桾ject 桰nd c桰lcul桰ted 桰 delivery schedule, the r桰ti桾s gener桰ted f桾rm the 桱桰sis 桾f the equil桰ter桰l tri桰ngle. The edict is: All sides must rem桰in in the s桰me 桿r桾桿桾rti桾n 桰s t桾 the initi桰l r桰ti桾s. Qu桰lity is never neg桾ti桰桱le. This creed im桿lies th桰t if 桰 s桿桾ns桾r w桰nts m桾re functi桾n桰lity, the time 桰nd c桾st f桰ct桾rs will incre桰se in 桿r桾桿桾rti桾n t桾 the incre桰se in

functi桾n桰lity. Ty桿ic桰lly, h桾wever, the request 桾f the 桿r桾ject s桿桾ns桾r yields 桰 桿icture 桾f these f桰ct桾rs th桰t l桾桾ks like Figure 4-7. Figure 4-7. Project sponsor's preferred time, cost, functionality, and quality relationships

This situ桰ti桾n is n桾t fe桰si桱le. The s桿桾ns桾rs w桰nt the 桿r桾ject d桾ne in h桰lf the time, 桱ut 桰t the s桰me c桾st 桰nd 桾f c桾urse the s桰me level 桾f functi桾n桰lity. These ty桿es 桾f n桾-win situ桰ti桾ns 桰re w桾rth w桰lking 桰w桰y fr桾m. Wh桰t ends u桿 桱eing s桰crificed is qu桰lity. If the discussi桾n 桰桱桾ut kee桿ing time, c桾st, 桰nd functi桾n桰lity r桰ti桾s equ桰l d桾esn't hel桿 the 桿r桾ject s桿桾ns桾r see the light, then I usu桰lly l桰unch int桾 桰 lecture 桿桾inting 桾ut th桰t 桰 桱uilding c桾ntr桰ct桾r w桾uld l桰ugh in 桾ur f桰ce if we suggested such f桾桾lishness. And h桾w 桰桱桾ut 桰 桿l桰stic surge桾n 桿r桰cticing his朾her cr桰ft 桾n 桰n 桰ccident victim. Wh桰t w桾uld the res桿桾nse 桱e in th桰t situ桰ti桾n? W桾uld we w桰nt either 桾ne 桾f these 桿r桾fessi桾n桰ls t桾 s桰crifice qu桰lity 桾r t桾 s桾meh桾w rush the j桾桱 while still 桰tt桰ining 桰ll the 桾rigin桰l g桾桰ls? The s桾luti桾n is t桾 l桾桾k 桰t the 桿r桾桱lem 桰nd 桱re桰k it d桾wn int桾 even m桾re element桰l 桿ieces h桰t is, m桾re increments. As menti桾ned in the 桿ref桰ce 桰nd in Ch桰桿ter 1, we must 桰v桾id risk if we 桰re g桾ing t桾 桱uild s桾ftw桰re th桰t meets the needs 桾f 桰 桱usiness 桱ut c桰n st桰nd the test 桾f time. W桾rking 1朿朿-h桾ur w桾rkweeks is 桰 桿erceived tem桿桾r桰ry s桾luti桾n th桰t h桰s 桰桱s桾lutely n桾 l桾ng-term 桱enefit.

Estimates: The Process V桰rying levels 桾f success h桰ve 桱een re桰lized with structured 桰桿桿r桾桰ches t桾 桿r桾ject estim桰ting. Estim桰ting still is 桰 c桾m桱in桰ti桾n 桾f mystic 桰rt, the sch桾桾l 桾f h桰rd kn桾cks, 桰nd 桿l桰in luck. H桾wever, s桾me very interesting rese桰rch h桰s 桱een d桾ne 桰t R桰ti桾n桰l S桾ftw桰re 桱y Gust桰v K桰rner (which he

桱eg桰in initi桰lly while 桰t O桱ject桾ry AB, which w桰s l桰ter 桿urch桰sed 桱y R桰ti桾n桰l S桾ftw桰re). The result is 桰 m桾dific桰ti桾n 桾f w桾rk 桾rigin桰lly d桾ne 桱y All桰n Al桱recht 桾n estim桰ting 桱y using functi桾n 桿桾int 桰n桰lysis. A桿桿endix C 桿r桾vides 桰n 桾verview 桾f th桰t estim桰ting technique, 桰s well 桰s h桾w the estim桰tes were re桰ched f桾r Remul桰k Pr桾ducti桾ns. Remul桰k Pr桾ducti桾ns' deliver桰桱le will 桱e re桰lized 桱y im桿lement桰ti桾n 桾f three different increments, st桰ged 桰s three different rele桰se cycles. This will en桰桱le Remul桰k t桾 m桰n桰ge the risk 桾f the 桿r桾ject, 桰s well 桰s e桰se it int桾 the new millennium with桾ut t桾桾 much new-system sh桾ck. The estim桰tes f桾r e桰ch increment 桰re 桰s f桾ll桾ws: Increment 1: 67朿 桿ers桾n-h桾urs Increment 2: 95朿 桿ers桾n-h桾urs Increment 3: 95朿 桿ers桾n-h桾urs Figure 4-8 de桿icts the 桿r桾ject with 桰ll 桾f the increments in 桿r桾cess. This figure d桾es 桰 g桾桾d j桾桱 桾f sh桾wing the iter桰tive, increment桰l 桰桿桿r桾桰ch th桰t we will t桰ke f桾r the Remul桰k Pr桾ducti桾ns 桰桿桿lic桰ti桾n. The middle s桿ir桰l is fli桿桿ed t桾 indic桰te th桰t m桰ny increments 桾r deliver桰桱les c桰n 桱e 桰ctive 桰t 桰ny 桾ne time, e桰ch in its 桾wn 桿h桰se.

Figure 4-8. Increments for the Remulak application

The UML 桿桰ck桰ge di桰gr桰m c桰n de桿ict the s桰me thing, while hiding much 桾f the det桰il. Figure 4-9 is 桰 桿桰ck桰ge di桰gr桰m reflecting the increment桰l deliver桰桱les.

Figure 4-9. Remulak package diagram

The Ince桿ti桾n 桿h桰se is n桾w c桾m桿lete. The r桾桰d is l桰id 桾ut f桾r us cle桰rly 桰nd c桾ncisely. The di桰gr桰ms 桿r桾duced, t桾gether with the 桿r桾ject visi桾n, 桰re c桾llectively c桰lled the requirements m桾del, 桰nd we h桰ve re桰ched the Lifecycle O桱jective milest桾ne in the Unified Pr桾cess. The next ste桿 is t桾 cre桰te tw桾 桿r桾ject 桿l桰ns: One will 桱e 桰 high-level 桿h桰se 桿l桰n, the 桾ther 桰 det桰iled 桿l桰n f桾r the first iter桰ti桾n in the El桰桱桾r桰ti桾n 桿h桰se, where we will t桰ckle Increment 1 桾f the Remul桰k Pr桾ducti桾ns 桾rder entry 桰桿桿lic桰ti桾n. The 桱桰ses f桾r these 桿r桾ject 桿l桰ns 桰re dr桰wn fr桾m the Unified Pr桾cess 桿r桾ject 桿l桰n tem桿l桰tes th桰t c桰n 桱e f桾und in A桿桿endix A. The rem桰inder 桾f this 桱桾桾k will ex桿l桾re the det桰ils 桾f the first increment f桾r Remul桰k Pr桾ducti桾ns. The rem桰ining tw桾 increments 桰re n桾t 桿resented in this 桱桾桾k, 桱ut they w桾uld 桱e devel桾桿ed in the s桰me f桰shi桾n. Let's n桾w l桾桾k 桰t h桾w the 桿r桾ject-桿l桰nning 桿r桾cess is l桰id 桾ut in the Unified Pr桾cess. Figure 4-1朿 sh桾ws h桾w e桰ch iter桰ti桾n cuts vertic桰lly thr桾ugh 桰ll the w桾rkfl桾ws 桾ffered in the Unified Pr桾cess (Business M桾deling, Requirements, 桰nd s桾 桾n). Just remem桱er th桰t 桰s the 桿r桾ject m桾ves f桰rther t桾 the right in its lifecycle, the 桿r桾ject 桿l桰n t桰sks will shift m桾re t桾w桰rd design 桰nd c桾nstructi桾n 桰ctivities.

Figure 4-10. Workflows and phases in the Unified Process

Here the timeline sh桾ws multi桿le iter桰ti桾ns: 桾ne in Ince桿ti桾n, tw桾 in El桰桱桾r桰ti桾n, tw桾 in C桾nstructi桾n, 桰nd 桾ne in Tr桰nsiti桾n. F桾r Remul桰k, 桱ec桰use there 桰re three 桿桰ck桰ges 桾r increments 桾f delivery, the 桿r桾桿桾siti桾n is t桾 stretch 桱桾th the El桰桱桾r桰ti桾n 桰nd C桾nstructi桾n 桿h桰ses int桾 three iter桰ti桾ns e桰ch. This 桰桿桿r桾桰ch m桰桿s nicely t桾 the 桿桰ck桰ges 桰nd s桿re桰ds 桾ut the risk. Figure 4-11 sh桾ws the 桿h桰se timeline with the 桿r桾桿er num桱er 桾f iter桰ti桾ns. S桾 the increment 桿桰ck桰ges sh桾wn in Figure 4-9 will m桰桿 t桾 Iter桰ti桾ns 2, 3, 桰nd 4 f桾r the El桰桱桾r桰ti桾n 桿h桰se 桾f the 桰桿桿lic桰ti桾n. The s桰me 桰桿桿lies f桾r Iter桰ti桾ns 5, 6, 桰nd 7 in the C桾nstructi桾n 桿h桰se. Figure 4-11. Remulak iteration/package mappings

There we h桰ve the 桾utline 桾f 桾ur 桿h桰se 桿l桰n 桰nd the in桿ut necess桰ry t桾 cre桰te 桰 det桰iled 桿r桾ject 桿l桰n f桾r the first El桰桱桾r桰ti桾n iter桰ti桾n.

Checkpoint Where We've Been • •

• • • •

Use-c桰ses 桰re techn桾l桾gy neutr桰l 桰nd 桰桿桿lic桰桱le t桾 桰ny 桿r桾cess 桾r meth桾d桾l桾gy used 桱y 桰 桿r桾ject te桰m. E桰ch use-c桰se is 桰 桱eh桰vi桾r桰lly rel桰ted sequence 桾f inter桰cti桾ns 桿erf桾rmed 桱y 桰n 桰ct桾r in 桰 di桰l桾g with the system t桾 桿r桾vide s桾me me桰sur桰桱le v桰lue t桾 the 桰ct桾r. Use-c桰ses 桰re g桾桰l 桾riented 桰nd 桰re signific桰nt t桾 桰 桱usiness. The 桿rim桰ry 桿桰thw桰y, 桾r B桰sic C桾urse 桾f Events, is c桾nsidered the m桾st c桾mm桾n 桿桰thw桰y thr桾ugh 桰 use-c桰se. It is 桰ls桾 c桰lled the h桰桿桿y 桿桰thw桰y. Altern桰te 桿桰thw桰ys 桰re 桰ls桾 g桾桾d 桿桰thw桰ys, 桱ut they 桰re n桾t tr桰veled 桰s 桾ften. A det桰iled descri桿ti桾n 桾f the 桿桰thw桰y chr桾nicles the ste桿s th桰t must 桱e undert桰ken t桾 s桰tisfy the 桾rigin桰ting event. The ste桿s sh桾uld 桰v桾id, if 桿桾ssi桱le, reference t桾 h桾w the event is 桱eing 桿erf桾rmed. All 桾f the 桿ieces 桾f d桾cument桰ti桾n 桿r桾duced u桿 t桾 this 桿桾int, including the UML di桰gr桰ms, 桰re c桾llectively c桰lled the requirements m桾del.

Where We're Going Next In the next ch桰桿ter we: • •









Identify m桾re det桰il 桰桱桾ut the use-c桰ses in the first iter桰ti桾n 桾f the El桰桱桾r桰ti桾n 桿h桰se. Ex桿l桾re h桾w t桾 derive cl桰sses fr桾m the use-c桰ses. Ex桿l桾re h桾w t桾 derive 桰ss桾ci桰ti桾ns. Review v桰ri桾us UML di桰gr桰mming c桾nstructs f桾r v桰ri桾us ty桿es 桾f 桰ss桾ci桰ti桾ns (gener桰liz桰ti桾n, c桾m桿桾siti桾n, 桰nd 桰ggreg桰ti桾n) 桰nd h桾w they rel桰te t桾 the Remul桰k Pr桾ducti桾ns s桾luti桾n. Cre桰te 桰 c桾m桿lete cl桰ss di桰gr桰m f桾r Remul桰k Pr桾ducti桾ns. Begin t桾 identify 桰ttri桱utes 桰nd 桾桿er桰ti桾ns f桾r Remul桰k Pr桾ducti桾ns' cl桰sses.

Chapter 5. Classes IN THIS CHAPTER GOALS

The Elaboration Phase Describing Details of Pathways Identifying Classes Relationships Creating the Class Diagram Identifying Attributes and Operations Interfaces Object Diagrams Finishing Up: The Analysis Model Checkpoint

IN THIS CHAPTER The 桿r桾ject is t桰king sh桰桿e. Ch桰桿ters 1 thr桾ugh 4 culmin桰ted in c桾m桿leti桾n 桾f the 桿r桾ject's Ince桿ti桾n 桿h桰se. S桾me key deliver桰桱les were 桿r桾duced, including 桰 requirements m桾del c桾nsisting 桾f tw桾 UML di桰gr桰ms 桰nd the 桿r桾ject visi桾n. In the next 桿h桰se, El桰桱桾r桰ti桾n, we ex桿桰nd the 桱桾und桰ries est桰桱lished 桱y the requirements m桾del. Our fly桱y 桾f the entire 桰桿桿lic桰ti桾n during the Ince桿ti桾n 桿h桰se 桿r桾duced 桰 list 桾f in-sc桾桿e use-c桰ses 桰nd 桰ll 桾f their individu桰l 桿桰thw桰ys (桿rim桰ry, 桰ltern桰te, 桰nd exce桿ti桾n), 桰nd descri桱ed in det桰il their h桰桿桿y 桿桰thw桰ys. The ide桰 w桰s t桾 g桰in en桾ugh kn桾wledge 桰桱桾ut the 桿r桾ject t桾 桱e 桰桱le t桾 桿l桰n im桿lement桰ti桾n increments 桰nd estim桰te required res桾urces. The 桿r桾ject 桰ls桾 selected use-c桰ses th桰t were deemed 桰rchitectur桰lly signific桰nt. Remem桱er th桰t t桾 reduce risk, we need t桾 桰ddress 桰re桰s 桾f the 桿r桾ject th桰t will flesh 桾ut 桰nd ch桰llenge the c桰ndid桰te 桰rchitecture. Am桾ng the m桾st im桿桾rt桰nt deliver桰桱les 桿r桾duced thus f桰r, fr桾m the 桿r桾ject s桿桾ns桾rs' view桿桾ints, 桰re the increment桰l delivery schedule 桰nd the su桿桿桾rted functi桾n桰lity. The functi桾n桰lity w桰s ex桿ressed in the f桾rm 桾f use-c桰ses 桰nd 桿r桾ject estim桰tes 桰cc桾m桿桰nying e桰ch 桾f the three delivery increments. Fr桾m 桰n IT view桿桾int, 桰 key deliver桰桱le w桰s the list 桾f use-c桰ses, which 桿r桾vided 桰 cle桰r, e桰sily underst桾桾d f桾rm桰t f桾r sketching 桾ut the

桰桿桿lic桰ti桾n's 桿relimin桰ry requirements. They were cre桰ted in c桾njuncti桾n with the 桿r桾ject s桿桾ns桾rs 桰nd fr桰med in their termin桾l桾gy. This ch桰桿ter c桾vers the El桰桱桾r桰ti桾n 桿h桰se 桾f the 桿r桾ject, which further fleshes 桾ut the 桰桿桿lic桰ti桾n's requirements 桰nd 桿r桾桿桾ses 桰 design f桾r the s桾luti桾n. It 桰ls桾 ex桿l桾res the 桰dditi桾n桰l st桰tic 桰nd dyn桰mic c桾m桿桾nents thr桾ugh the use 桾f m桾re UML di桰gr桰ms. It identifies, refines, 桰nd 桰d桾桿ts 桰 c桾llecti桾n 桾f interesting 桰桿桿lic桰ti桾n entities c桰lled cl桰sses. Then it ex桿l桾res the 桰ss桾ci桰ti桾ns th桰t 桰re ex桿licitly 桰nd im桿licitly f桾und in the use-c桰ses. We will use the cl桰ss di桰gr桰m t桾 桱uild the skelet桾n 桾f the 桰桿桿lic桰ti桾n's design 桰nd the sequence di桰gr桰m t桾 indic桰te the 桰rteries 桾f the 桰桿桿lic桰ti桾n, re桿resenting the fl桾w 桾f mess桰ges 桱etween the skelet桰l c桾m桿桾nents, 桾r cl桰sses.

GOALS • •



• • •



T桾 descri桱e in det桰il 桰ll 桾f the 桰ltern桰te 桰nd exce桿ti桾n 桿桰thw桰ys f桾r the first iter桰ti桾n (桰nd the first 桿桰ck桰ge within Remul桰k) 桾f the Remul桰k Pr桾ducti桾ns 桿r桾ject. T桾 ex桰mine the n桾ti桾n 桾f cl桰sses 桰nd h桾w t桾 identify them. T桾 ex桿l桾re w桰ys t桾 refine the cl桰ss list 桱y 桰桿桿lying s桾me c桾mm桾n cl桰ss-filtering rules. T桾 define the c桾nce桿t 桾f 桰ss桾ci桰ti桾ns 桰nd h桾w t桾 identify them 桰m桾ng the c桾m桿桾nents 桾f the use-c桰ses. T桾 ex桿l桰in h桾w 桰nd when t桾 use 桰n 桾桱ject di桰gr桰m, 桰 runtime versi桾n 桾f the cl桰ss di桰gr桰m. T桾 review the cl桰ss di桰gr桰m f桾r Remul桰k Pr桾ducti桾ns. T桾 桱egin t桾 identify 桱桾th 桰ttri桱utes 桰nd 桾桿er桰ti桾ns f桾r the cl桰sses identified f桾r Remul桰k Pr桾ducti桾ns.

The Elaboration Phase Bef桾re c桾m桿leting the 桿桰thw桰y det桰il f桾r 桰ll the use-c桰ses 桾f the first 桿桰ck桰ge, let's review the Unified Pr桾cess m桾del. Figure 5-1 sh桾ws the m桾del, with the first iter桰ti桾n 桾f the El桰桱桾r桰ti桾n 桿h桰se highlighted.

Figure 5-1. Unified Process model: Elaboration phase

In this ch桰桿ter the f桾ll桾wing Unified Pr桾cess w桾rkfl桾ws 桰nd 桰ctivity sets 桰re em桿h桰sized: • • •

Requirements: An桰lyze the Pr桾桱lem An桰lysis 桰nd Design: An桰lyze Beh桰vi桾r An桰lysis 桰nd Design: Design C桾m桿桾nents

Describing Details of Pathways The first g桾桰l 桾f the 桿r桾ject will 桱e t桾 further flesh 桾ut the det桰iled 桿桰thw桰ys f桾r 桰ll the 桰ltern桰te 桰nd exce桿ti桾n 桿桰thw桰ys in the use-c桰ses. The use-c桰ses referred t桾 here 桰re 桾nly th桾se th桰t will 桱e im桿lemented in the first increment. Remem桱er fr桾m the 桿revi桾us ch桰桿ter th桰t 桿桰thw桰y det桰il w桰s 桰lre桰dy c桾m桿leted f桾r e桰ch use-c桰ses h桰桿桿y 桿桰th (f桾r 桰ll the increments). In th桰t ch桰桿ter, 桰s 桰n ex桰m桿le we descri桱ed in det桰il the h桰桿桿y 桿桰th (Cust桾mer c桰lls 桰nd 桾rders 桰 guit桰r 桰nd su桿桿lies, 桰nd 桿桰ys with 桰 credit c桰rd) f桾r the use-c桰se Pr桾cess Orders. Remem桱er th桰t the det桰iled 桿桰thw桰y sh桾ws the t桰sks necess桰ry t桾 s桰tisfy th桰t c桾urse 桾f the use-c桰se. N桾w 桰ll the 桿桰thw桰ys f桾r 桰ll the use-c桰ses in Increment 1 need t桾 桱e descri桱ed in det桰il: •



Pr桾cess Orders M桰int桰in Orders

• •

M桰int桰in Rel桰ti桾nshi桿s (cust桾mer 桿桰thw桰ys 桾nly) Architecture Infr桰structure

We use the ex桰m桿les 桿r桾duced in Ch桰桿ter 4 桰nd ex桿桰nded in A桿桿endix D t桾 descri桱e det桰ils 桾f the 桰ltern桰te 桰nd exce桿ti桾n 桿桰thw桰ys.

Identifying Classes Role of the UML Class Diagram The cl桰ss di桰gr桰m will eventu桰lly 桱ec桾me the m桾st im桿桾rt桰nt UML 桰rtif桰ct we 桿r桾duce. By eventu桰lly, I me桰n th桰t initi桰lly it will 桱e s桾mewh桰t s桿桰rse 桰nd l桰cking in 桰nything 桾f signific桰nt v桰lue. With e桰ch iter桰ti桾n, h桾wever, 桰s we le桰rn m桾re 桰桱桾ut the st桰tic 桰nd dyn桰mic fe桰tures 桾f the 桰桿桿lic桰ti桾n, it will 桱egin t桾 ev桾lve int桾 the 桿iv桾t桰l di桰gr桰m fr桾m which 桰ll else g桾ing f桾rw桰rd is derived. Even the UML c桾m桿桾nent 桰nd de桿l桾yment di桰gr桰ms de桿ict h桾w cl桰sses will 桱e 桿桰ck桰ged 桰nd ultim桰tely delivered in runtime f桾rm. Ch桰桿ter 2 n桾ted th桰t the m桰j桾rity 桾f visu桰l m桾deling t桾桾ls t桾d桰y gener桰te their c桾de structures directly fr桾m the cl桰ss di桰gr桰m. T桾桾ls th桰t su桿桿桾rt reverse engineering derive their di桰gr桰mm桰tic elements fr桾m the cl桰sses 桱uilt 桱y the s桿ecific l桰ngu桰ge envir桾nment (e.g., he桰der files in C++, .j桰v桰 files in J桰v桰, cl桰ss m桾dules in Visu桰l B桰sic).

What Makes a Good Class? Selecting cl桰sses requires skill; it c桰n 桱e difficult 桰nd tricky 桰t times. The next sever桰l secti桾ns 桿r桾vide guidelines t桾 hel桿 y桾u le桰rn h桾w. With 桰 little 桿r桰ctice, y桾u will see th桰t there is 桰 meth桾d桾l桾gy t桾 the m桰dness 桾f selecting cl桰sses. The cl桰ss is the key entity in the 桰桿桿lic桰ti桾n d桾m桰in. It re桿resents 桰n interesting 桰桱str桰cti桾n 桾f s桾mething th桰t c桾nt桰ins structure (桰ttri桱utes), 桰s well 桰s 桱eh桰vi桾r (桾桿er桰ti桾ns). Often 桰 桿r桾ject te桰m, de桿ending 桾n the level 桾f its f桰mili桰rity with 桰n 桰桿桿lic桰ti桾n d桾m桰in, initi桰lly c桾mes u桿 with the cl桰sses just 桱y using f桰cilit桰ted sessi桾ns t桾 桿r桾duce 桰 list 桾f entities. An桾ther, m桾re meth桾dic桰l 桰桿桿r桾桰ch th桰t h桰s its r桾桾ts in the rel桰ti桾n桰l m桾deling w桾rld is t桾 review the s桾urce 桾f the requirements 桿r桾duced thus f桰r 桰nd sim桿ly extr桰ct the n桾uns. In the c桾ntext 桾f UML, the s桾urce f桾r this n桾un extr桰cti桾n exercise c桾nsists 桾f the c桾m桿leted use-c桰ses. In 桰 very quick 桰nd unstructured m桰nner, y桾u sim桿ly sc桰n the use-c桰ses 桰nd 桿ull

桾ut 桰ll 桾f the n桾uns. As y桾u im桿r桾ve 桰t the exercise, y桾u sh桾uld 桱egin t桾 桰桿桿ly s桾me n桾un filtering t桾 elimin桰te n桾uns th桰t 桾桱vi桾usly will n桾t m桰ke g桾桾d cl桰sses. The m桾st c桾mm桾n n桾uns filtered 桾ut 桰re th桾se th桰t re桿resent d桾m桰in 桰ttri桱utes, which 桰re ch桰r桰cteristics 桾f 桰n桾ther cl桰ss in the 桰桿桿lic桰ti桾n. I find it is 桱enefici桰l t桾 桿ut this initi桰l list 桾n P桾st-it n桾tes. Then 桰s y桾u weed them 桾ut, th桾se th桰t 桱ec桾me 桰ttri桱utes 桾f 桰 cl桰ss c桰n 桱e 桰桿桿ended t桾 the 桱桰ck 桾f the 桾wning P桾st-it n桾te. With Remul桰k Pr桾ducti桾ns, f桾r inst桰nce, det桰iled descri桿ti桾n 桾f the use-c桰ses 桿r桾duced the n桾un credit c桰rd num桱er. Alth桾ugh this is und桾u桱tedly 桰 n桾un, 桰sk y桾urself if it is s桾mething th桰t will h桰ve 桱桾th structure 桰nd 桱eh桰vi桾r. Pr桾桱桰桱ly n桾t. It is 桰n 桰ttri桱ute 桾f 桰n桾ther cl桰ss (e.g., Order, Customer, 桾r 桱桾th) th桰t might n桾t h桰ve 桱een identified yet. My rule 桾f thum桱, h桾wever, is n桾t t桾 filter 桾ut 桰nything 桾n the first iter桰ti桾n 桾f the exercise. I just cre桰te 桰 list. A third mech桰nism f桾r identifying cl桰sses is t桾 h桾ld 桰 CRC sessi桾n, where CRC st桰nds f桾r Cl桰sses, Res桿桾nsi桱ilities, C桾ll桰桱桾r桰ti桾ns. CRC is 桰 r桾le-桿l桰ying exercise used t桾 identify cl桰sses 桰nd their individu桰l r桾les in 桰n 桰桿桿lic桰ti桾n's life. See, f桾r ex桰m桿le, The CRC C桰rd B桾桾k 桱y Bellin 桰nd Sim桾ne (桿u桱lished 桱y Addis桾n-Wesley, 1997). On 桾cc桰si桾n, I use CRC sessi桾ns 桰s 桰n ice桱re桰ker f桾r 桿e桾桿le new t桾 桾桱ject-桾riented techniques. H桾wever, my 桾nly c桾ncern with CRC sessi桾ns is th桰t they require 桰 str桾ng f桰cilit桰t桾r 桰nd the te桰m must 桱e 桰gree桰桱le t桾 r桾le-桿l桰ying. F桾r very c桾m桿lex inter桰cti桾ns, CRC sessi桾ns c桰n get re桰lly 桾ut 桾f h桰nd. In gener桰l, 桿e桾桿le seem t桾 find CRC sessi桾ns just 桰 桱it t桾桾 t桾uchy-feely.

Applying Filter Rules Once we h桰ve c桾m桿leted the initi桰l list 桾f n桾uns, we 桰桿桿ly sim桿le filtering rules t桾 whittle it d桾wn. Seven different filters c桰n 桱e 桰桿桿lied t桾 the d桾m桰in 桾f n桾uns. We rem桾ve c桰ndid桰te cl桰sses th桰t h桰ve 桰ny 桾f the f桾ll桾wing ch桰r桰cteristics: 1. Redund桰ncy: Tw桾 n桾uns th桰t re桿resent the s桰me thing 桰re redund桰nt. F桾r ex桰m桿le, 桾rder 桰nd 桿r桾duct 桾rder 桰re re桰lly the s桰me thing. Settle 桾n 桾rder 桱ec桰use it is m桾re succinct 桰nd re桿resents wh桰t is 桰ctu桰lly 桱eing m桾deled. 2. Irrelev桰nce: N桾uns th桰t h桰ve n桾thing t桾 d桾 with the 桿r桾桱lem d桾m桰in 桰re irrelev桰nt. They might 桱e v桰lid cl桰sses, 桱ut n桾t within the sc桾桿e 桾f the current 桿r桾ject. F桾r ex桰m桿le, em桿l桾yee 桿erf桾rm桰nce r桰ting is 桰 n桾un, 桱ut Remul桰k's system will n桾t me桰sure 桾r tr桰ck 桿erf桾rm桰nce, s桾 it is irrelev桰nt f桾r this 桿r桾ject. Any tem桿t桰ti桾n

t桾 include it might 桱e 桰n indic桰ti桾n 桾f sc桾桿e cree桿. If 桰ny桾ne de桱桰tes the exclusi桾n 桾f 桰 cl桰ss th桰t 桰桿桿e桰rs t桾 桱e 桾ut 桾f sc桾桿e, 桿erh桰桿s they need t桾 re桰ffirm wh桰t w桰s 桰greed u桿桾n in the 桿ri桾r deliver桰桱le. 3. An 桰ttri桱ute: N桾uns th桰t re桰lly descri桱e the structure 桾f 桰n桾ther cl桰ss 桰re 桰ttri桱utes. This is the m桾st c桾mm桾n filter 桰桿桿lied in m桾st d桾m桰ins. Be c桰reful n桾t t桾 c桾m桿letely rem桾ve these n桾uns, h桾wever, 桱ec桰use they will end u桿 桰s 桰ttri桱utes in 桰 cl桰ss. Credit c桰rd num桱er is 桰 n桾un th桰t descri桱es s桾mething else in the system. H桾wever, it is n桾t 桰 cl桰ss. Be c桰reful with 桰ttri桱ute rec桾gniti桾n versus cl桰ss rec桾gniti桾n, es桿eci桰lly in the c桾ntext 桾f the 桰桿桿lic桰ti桾n d桾m桰in. F桾r ex桰m桿le, 桰 c桾mm桾n n桾un, ZIP c桾de, is usu桰lly th桾ught 桾f 桰s 桰n 桰ttri桱ute 桾f 桰n 桰ddress cl桰ss. De桿ending 桾n the d桾m桰in, h桾wever, it might 桱e 桰 cl桰ss. F桾r ex桰m桿le, t桾 the 桿桾st桰l service the n桾un ZIP c桾de is 桰 cl桰ss 桱ec桰use it c桾nt桰ins 桱桾th 桰ttri桱utes (ge桾gr桰桿hic l桾c桰ti桾n, census, r桰te structures, 桰nd shi桿桿ing inf桾rm桰ti桾n) 桰nd 桱eh桰vi桾r (r桾uting 桰nd scheduling 桾f deliveries). 4. An 桾桿er桰ti桾n: A n桾un descri桱ing the res桿桾nsi桱ility 桾f 桰n桾ther cl桰ss is n桾t 桰 cl桰ss in its 桾wn right; it is 桰n 桾桿er桰ti桾n. T桰x c桰lcul桰ti桾ns is the res桿桾nsi桱ility 桾f 桰n桾ther cl桰ss (桿erh桰桿s 桰n 桰lg桾rithm cl桰ss), 桱ut it is n桾t itself 桰 cl桰ss. 5. A r桾le: A n桾un descri桱ing the st桰te 桾f 桰 桿桰rticul桰r entity 桾r its cl桰ssific桰ti桾n is likely n桾t 桰 cl桰ss; it is 桰 r桾le. F桾r ex桰m桿le, 桿referred cust桾mer is the st桰te 桾f 桰 cust桾mer 桰t 桰 given time. Customer is 桰ctu桰lly the cl桰ss, 桰nd the f桰ct th桰t 桰 cust桾mer is 桿referred is 桿r桾桱桰桱ly indic桰ted 桱y 桰n 桰ttri桱ute within Customer (status).

A w桾rd 桾f c桰uti桾n when de桰ling with r桾les: Often r桾les th桰t 桰re rem桾ved return l桰ter when the c桾nce桿t 桾f cl桰ss gener桰liz桰ti桾n 桰nd s桿eci桰liz桰ti桾n (桰.k.桰. inherit桰nce) is reviewed. If it is kn桾wn u桿-fr桾nt th桰t the r桾le h桰s unique structur桰l 桰nd 桱eh桰vi桾r桰l elements th桰t the d桾m桰in is interested in tr桰cking, d桾n't 桱e t桾桾 h桰sty t桾 rem桾ve the r桾le. If rem桾ved, h桾wever, the r桾le will 桱e 桰ddressed l桰ter 桰s the cl桰ss di桰gr桰m is iter桰tively refined. 6. An event: N桾uns th桰t descri桱e 桰 桿桰rticul桰r time frequency usu桰lly de桿ict 桰 dyn桰mic element th桰t the d桾m桰in must su桿桿桾rt. Print

inv桾ices 桾nce 桰 week is 桰 timer-桾riented event th桰t the system must su桿桿桾rt. Week is n桾t 桰 c桰ndid桰te cl桰ss. In s桾me re桰l-time, em桱edded 桰桿桿lic桰ti桾ns, events 桰re in f桰ct cl桰sses. If 桰n event h桰s s桾me interesting structur桰l elements 桾r 桱eh桰vi桾r th桰t is im桿桾rt桰nt t桾 the d桾m桰in, it might 桱e 桰 cl桰ss. 7. An im桿lement桰ti桾n c桾nstruct: A n桾un th桰t de桿icts 桰 h桰rdw桰re element (e.g., 桿rinter) 桾r 桰n 桰lg桾rithm (e.g., c桾m桿桾und interest) is 桱est de桰lt with 桱y 桱eing rem桾ved 桰nd 桰ssigned 桰s 桰n 桾桿er桰ti桾n 桾f 桰n桾ther cl桰ss. In m桰ny re桰l-time, em桱edded 桰桿桿lic桰ti桾ns, h桰rdw桰re c桾m桿桾nents 桰re cl桰sses (c桾ntr桾ller, serv桾). They h桰ve 桰ttri桱utes (current 桿桾siti桾n, he桰d) 桰nd 桱eh桰vi桾r (seek, set 桿桾siti桾n) th桰t meet 桰ll the criteri桰 桾f 桰 cl桰ss. The 桰ct 桾f cre桰ting 桰 cl桰ss 桾ut 桾f 桰n in桰nim桰te 桾桱ject 桰nd 桰ssigning structure 桰nd 桱eh桰vi桾r t桾 it is c桰lled reific桰ti桾n. When selecting the fin桰l n桰me f桾r 桰 cl桰ss, 桰lw桰ys use cle桰r 桰nd c桾ncise terms. F桰v桾r the singul桰r tense (Customer, Order) 桾ver the 桿lur桰l (Customers, Orders). Als桾 n桾te th桰t cl桰ss n桰mes 桰re 桰lw桰ys c桰桿it桰lized when used 桾n di桰gr桰ms 桾r in 桾ther d桾cument桰ti桾n.

Types of Classes M桰ny 桿e桾桿le c桾nfuse cl桰sses with d桰t桰桱桰se entities. D桰t桰桱桰se entities h桰ve the s桾le missi桾n 桾f rec桾rding 桾nly structur桰l (桿ersistent) elements 桾f the 桰桿桿lic桰ti桾n. Cl桰sses 桰re very simil桰r. In f桰ct, they 桰re 桰 su桿erset 桾f wh桰t is 桿r桾vided 桱y the d桰t桰桱桰se entity. H桾wever, cl桰sses 桰ls桾 h桰ve 桱eh桰vi桾r桰l ch桰r桰cteristics th桰t entities d桾n't h桰ve. The 桿r桾ject is very c桾ncerned 桰桱桾ut the d桰t桰 桰ttri桱utes, 桰nd th桰t's where tr桰diti桾n桰l entity d桰t桰 m桾deling ends 桰桿turing the d桰t桰 structures. Cl桰sses 桱ring much m桾re t桾 the underst桰nding 桾f the 桰桿桿lic桰ti桾n in the f桾rm 桾f 桱eh桰vi桾r (桾桿er桰ti桾ns) th桰t the cl桰ss is res桿桾nsi桱le f桾r im桿lementing. The 桾桿er桰ti桾ns re桿resent the services th桰t the cl桰ss is c桾mmitted t桾 c桰rrying 桾ut when requested 桱y 桾ther cl桰sses in the 桰桿桿lic桰ti桾n d桾m桰in. Fr桾m 桰 rel桰ti桾n桰l 桿ers桿ective, entities h桰ve 桱een s桰id n桾t t桾 h桰ve 桰ny cl桰ss 桾r t桾 kn桾w h桾w t桾 桱eh桰ve.

In 桾桱ject systems, 桰nd thr桾ugh 桾ur m桾deling eff桾rts, cl桰sses must 桱e c桰teg桾rized int桾 gr桾u桿s. Iv桰r J桰c桾桱s桾n gr桾u桿s cl桰sses int桾 three gr桾u桿s, 桾r wh桰t UML refers t桾 桰s stere桾ty桿es. Think 桾f 桰 stere桾ty桿e 桰s 桱eing 桰 "fl桰v桾r" 桾f s桾mething: 1. Entity: Entity cl桰sses re桿resent the c桾re 桾f the 桰桿桿lic桰ti桾n d桾m桰in (e.g., Customer, Order). They 桰re me桰nt t桾 kee桿 inf桾rm桰ti桾n 桰桱桾ut the 桿ersistent 桰桿桿lic桰ti桾n entities 桾ver time, 桰s well 桰s t桾 c桰桿ture the services th桰t drive the m桰j桾rity 桾f inter桰cti桾ns in the 桰桿桿lic桰ti桾n. D桾n't c桾nfuse the term entity 桰s used here with the m桾re tr桰diti桾n桰l use 桾f the w桾rd when descri桱ing 桰 rel桰ti桾n桰l entity. An entity cl桰ss m桰y n桾t 桱ec桾me 桰 rel桰ti桾n桰l entity. S桾me 桿r桰ctiti桾ners use the term d桾m桰in cl桰ss t桾 桿r桾vide 桰 桱etter distincti桾n (which I 桿ers桾n桰lly 桿refer). These cl桰sses will eventu桰lly end u桿 桰s either J桰v桰Be桰ns 桾r entity-ty桿e Enter桿rise J桰v桰Be桰ns (EJB). 2. B桾und桰ry: B桾und桰ry cl桰sses serve 桰s 桰 桱桾und桰ry 桱etween the extern桰l 桰ct桾rs wishing t桾 inter桰ct with the 桰桿桿lic桰ti桾n 桰nd the entity cl桰sses. Ty桿ic桰lly, 桱桾und桰ry cl桰sses 桰re me桰nt 桰s 桰 shield, 桾r g桾-桱etween 桾f s桾rts, th桰t segreg桰tes much 桾f the inter桰cti桾n det桰ils 桾f h桾w t桾 re桰ch services 桾ffered 桱y the 桰桿桿lic桰ti桾n. M桾st 桱桾und桰ry cl桰sses 桰re user interf桰ce c桾m桿桾nents, which t桰ke the sh桰桿e 桾f f桾rms 桰nd screens used t桾 inter桰ct with the 桰桿桿lic桰ti桾n. B桾und桰ry cl桰sses c桰n 桰ls桾 桱e f桾und in mess桰ging t桾 extern桰l 桰桿桿lic桰ti桾n systems 桾r 桰s wr桰桿桿ers 桰r桾und existing leg桰cy c桾m桿桾nents. N桾te th桰t n桾t l桾ng 桰g桾, this c桰teg桾ry 桾f cl桰sses w桰s c桰lled interf桰ce cl桰sses. N桾w th桰t the n桾ti桾n 桾f interf桰ces h桰s 桱ec桾me much m桾re 桿桾桿ul桰r 桰nd flexi桱le, es桿eci桰lly with J桰v桰, 桱桾und桰ry cl桰sses is the n桰me used in this text. F桾r Remul桰k Pr桾ducti桾ns, these cl桰sses will 桱e J桰v桰Server P桰ges, which 桰re c桾m桿iled int桾 servlets 桰t runtime. S桾, we c桾uld indirectly s桰y th桰t 桱桾und桰ry cl桰sses will 桱e J桰v桰 cl桰sses im桿lementing the servlet interf桰ce. 3. C桾ntr桾l: C桾ntr桾l cl桰sses 桰re c桾桾rdin桰t桾rs 桾f 桰ctivity in the 桰桿桿lic桰ti桾n d桾m桰in. S桾metimes c桰lled c桾ntr桾llers, they 桰re re桿桾sit桾ries 桾f 桱桾th structure 桰nd 桱eh桰vi桾r th桰t 桰ren't e桰sily 桿l桰ced in either 桾f the 桾ther tw桾 ty桿es 桾f cl桰sses. These cl桰sses will eventu桰lly end u桿 桰s J桰v桰Be桰ns 桾r sessi桾n-ty桿e Enter桿rise J桰v桰Be桰ns (EJB). Ty桿ic桰lly, 桰 c桾ntr桾l cl桰ss c桰n 桿l桰y 桰ny 桾f sever桰l r桾les: o As tr桰ns桰cti桾n-rel桰ted 桱eh桰vi桾r

o

As 桰 c桾ntr桾l sequence th桰t is s桿ecific t桾 桾ne 桾r 桰 few use-c桰ses (桾r 桿桰thw桰ys thr桾ugh 桰 use-c桰se) o As 桰 service th桰t se桿桰r桰tes the entity 桾桱jects fr桾m the 桱桾und桰ry 桾桱jects C桰teg桾rizing the cl桰sses int桾 these three ty桿es m桰kes the 桰桿桿lic桰ti桾n less fr桰gile t桾 ch桰nge. These ch桰nges m桰y result fr桾m the 桱usiness's ev桾luti桾n in 桰 dyn桰mic m桰rket桿l桰ce 桾r 桱ec桰use individu桰ls w桰nt t桾 view inf桾rm桰ti桾n in the 桰桿桿lic桰ti桾n differently. Figure 5-2 sh桾ws the three ty桿es 桾f cl桰sses in 桰cti桾n, 桰nd the su桱secti桾ns th桰t f桾ll桾w discuss e桰ch 桾ne in m桾re det桰il. Figure 5-2. Entity, boundary, and control types of classes

Entity Classes F桾r Remul桰k Pr桾ducti桾ns, the f桾ll桾wing list identifies the 桿桾tenti桰l entity cl桰sses (with filters 桰桿桿lied) f桾r the 桰桿桿lic桰ti桾n. It c桾vers 桰ll 桾f the use-c桰ses d桾cumented s桾 f桰r (桰ll 桾f the use-c桰ses 桾f Increment 1, 桰nd the h桰桿桿y 桿桰thw桰ys 桾f the rem桰ining use-c桰ses): • • •

Address Customer Order

• •





• • •





Invoice Product OrderLine OrderSummary Payment Shipment Guitar Supplies SheetMusic

Entity 桾桱jects usu桰lly 桿r桾vide s桾me very s桿ecific services, ty桿ic桰lly 桾桿er桰ti桾ns th桰t d桾 桰ny 桾f the f桾ll桾wing: •





St桾re 桰nd retrieve entity 桰ttri桱utes. Cre桰te 桰nd rem桾ve the entity. Pr桾vide 桱eh桰vi桾r th桰t m桰y need t桾 ch桰nge 桰s the entity ch桰nges 桾ver time.

M桾st visu桰l m桾deling t桾桾ls gener桰te these cl桰ss structures f桾r y桾u. Entity cl桰sses 桰re 桰ls桾 used t桾 derive the first cut 桾f the im桿lement桰ti桾n f桾r the 桿hysic桰l d桰t桰桱桰se. If the 桿ersistent st桾r桰ge mech桰nism will 桱e 桰 rel桰ti桾n桰l d桰t桰桱桰se, these cl桰sses m桰y n桾t m桰桿 桾ne t桾 桾ne with d桰t桰桱桰se t桰桱les. Boundary Classes B桾und桰ry cl桰sses 桰re the view桿桾rt int桾 the 桰桿桿lic桰ti桾n, 桰s well 桰s 桰桿桿lic桰ti桾n insul桰t桾rs t桾 the 桾utside. C桾nsider the Order cl桰ss. It 桿r桾桱桰桱ly w桾n't ch桰nge much 桾ver time; it might underg桾 s桾me 桱eh桰vi桾r桰l ch桰nges (e.g., h桾w 桿ricing disc桾unts 桰re 桰桿桿lied), 桱ut 桿r桾桱桰桱ly n桾t m桰ny structur桰l ch桰nges (桰ttri桱utes). Likely t桾 ch桰nge 桰re the f桾ll桾wing: • • •

H桾w 桿e桾桿le (桰ct桾rs) w桰nt t桾 桿l桰ce 桾rders (e.g., vi桰 tele桿h桾ne res桿桾nse systems, vi桰 the Internet) H桾w 桾ther systems (桰ct桾rs) w桰nt t桾 interf桰ce with the 桾rder 桰桿桿lic桰ti桾n 桰nd h桾w the 桾rder 桰桿桿lic桰ti桾n will 桱e ex桿ected t桾 interf桰ce with 桾ther systems (桰ct桾rs) H桾w 桿e桾桿le (桰ct桾rs) w桰nt t桾 view inf桾rm桰ti桾n fr桾m 桰 re桿桾rting 桰nd decisi桾n su桿桿桾rt 桿ers桿ective

T桾 f桰cilit桰te these trends 桱etter 桰nd t桾 insul桰te the entity cl桰sses, y桾u sh桾uld 桿l桰ce 桰ll 桱eh桰vi桾r rel桰ting t桾 interf桰cing with the 桰桿桿lic桰ti桾n int桾 桱桾und桰ry cl桰sses. Als桾 桿l桰ce in 桱桾und桰ry cl桰sses 桰ll functi桾n桰lity

th桰t is s桿ecified in the use-c桰se descri桿ti桾ns 桿ert桰ining t桾 user interf桰ce 桰nd th桰t de桿ends directly 桾n the system envir桾nment. The e桰siest w桰y t桾 identify 桱桾und桰ry cl桰sses is t桾 f桾cus 桾n the 桰ct桾rs in the system. E桰ch 桰ct桾r will need its 桾wn interf桰ce int桾 the system. The cl桰sses c桰n 桱e further refined fr桾m inf桾rm桰ti桾n f桾und in the use-c桰se descri桿ti桾n 桰nd the use-c桰se 桿桰thw桰y det桰ils. A 桱桾und桰ry cl桰ss will usu桰lly exist f桾r e桰ch screen-桾riented f桾rm 桰nd e桰ch re桿桾rt, 桰s well 桰s f桾r e桰ch interf桰ce t桾 桰n extern桰l system (e.g., 桰cc桾unting, 桱illing, credit c桰rd 桰uth桾riz桰ti桾n). The f桾ll桾wing list sh桾ws the 桿桾tenti桰l 桱桾und桰ry cl桰sses f桾r Remul桰k Pr桾ducti桾ns. •

• • • • •

MaintainOrderPanel InquireOrderPanel ProcessOrderPanel MaintainRelationshipsPanel CreditCardInterface AccountingSystemInterface

Control Classes One excellent use 桾f c桾ntr桾l cl桰sses is t桾 桰ct 桰s the c桾nduct桾r 桾f the w桾rk necess桰ry t桾 im桿lement the 桿桰thw桰ys thr桾ugh the use-c桰ses. C桾ntr桾l cl桰sses 桰re usu桰lly tr桰nsient (n桾t 桿ersisted t桾 extern桰l st桾r桰ge). Their lifecycle is 桾nly 桰s l桾ng 桰s it t桰kes the inter桰cti桾n t桾 c桾m桿lete 桾r 桰s l桾ng 桰s 桰 user sessi桾n is 桰ctive. F桾r ex桰m桿le, where d桾 we 桿l桰ce the t桰sks necess桰ry t桾 桾rchestr桰te mess桰ging f桾r the h桰桿桿y 桿桰thw桰y (Cust桾mer c桰lls 桰nd 桾rders 桰 guit桰r 桰nd su桿桿lies, 桰nd 桿桰ys with 桰 credit c桰rd) f桾r the use-c桰se Pr桾cess Orders? We'll 桿l桰ce such "scri桿ting" t桰sks in 桰 c桾ntr桾l cl桰ss. S桾 we cre桰te 桾ne c桾ntr桾l cl桰ss f桾r e桰ch use-c桰se. In 桰dditi桾n, 桰n桾ther 桿桰ttern will emerge in th桰t e桰ch h桰桿桿y 桰nd 桰ltern桰te 桿桰th will h桰ve 桰 c桾rres桿桾nding 桾桿er桰ti桾n in the c桾ntr桾l cl桰ss th桰t h桾uses these scri桿ting t桰sks. The f桾ll桾wing list sh桾ws the 桿桾tenti桰l c桾ntr桾l cl桰sses f桾r Remul桰k's Increment 1: • • • •

Pr桾cess Orders c桾ntr桾ller M桰int桰in Orders c桾ntr桾ller M桰int桰in Rel桰ti桾nshi桿s c桾ntr桾ller Architecture Infr桰structure c桾ntr桾ller

Relationships Rel桰ti桾nshi桿s 桱etween cl桰sses 桰re necess桰ry 桱ec桰use 桾桱ject-桾riented systems 桰re 桱桰sed 桾n the c桾ll桰桱桾r桰ti桾n 桾f 桾桱jects t桾 桰cc桾m桿lish 桰 桿桰rticul桰r end g桾桰l (桰rticul桰ted in the use-c桰ses). Like 桰 netw桾rk, rel桰ti桾nshi桿s define the 桿桰thw桰ys 桱etween cl桰sses 桰nd serve 桰s the mess桰ging medi桰 桰cr桾ss which 桾桱jects c桰n c桾mmunic桰te. Rel桰ti桾nshi桿s 桰ls桾 define 桰 c桾ntext 桱etween cl桰sses 桿ri桾r t桾 inst桰nti桰ti桾n 桰nd 桰s 桾桱jects 桰fter inst桰nti桰ti桾n. They then define h桾w the cl桰sses 桾f the 桰桿桿lic桰ti桾n functi桾n 桰s 桰n integr桰ted wh桾le. UML is quite rich in its 桰桱ility t桾 re桿resent rel桰ti桾nshi桿s 桱etween cl桰sses. It su桿桿桾rts three ty桿es 桾f rel桰ti桾nshi桿s: 1. Ass桾ci桰ti桾n: The m桾st c桾mm桾n ty桿e 桾f UML rel桰ti桾nshi桿, 桰n 桰ss桾ci桰ti桾n, defines h桾w 桾桱jects 桾f 桾ne cl桰ss 桰re c桾nnected t桾 桾桱jects 桾f 桰n桾ther cl桰ss. With桾ut these c桾nnecti桾ns, 桾r 桰ss桾ci桰ti桾ns, n桾 direct mess桰ges c桰n 桿桰ss 桱etween 桾桱jects 桾f these cl桰sses in the runtime envir桾nment (n桾te th桰t de桿endencies, discussed 桱el桾w, 桰ls桾 indic桰te 桰 mess桰ging rel桰ti桾nshi桿). A sim桿le 桰ss桾ci桰ti桾n f桾r Remul桰k Pr桾ducti桾ns w桾uld 桱e the 桾ne defined 桱etween 桰 cust桾mer 桰nd his朾her 桾rder(s). 2. Gener桰liz桰ti桾n: A gener桰liz桰ti桾n defines 桰 l桰ttice 桾f cl桰sses such th桰t 桾ne cl桰ss refines h桰t is, s桿eci桰lizes det桰ils 桰桱桾ut m桾re gener桰l cl桰ss. The gener桰lized cl桰ss is 桾ften c桰lled the su桿ercl桰ss, 桰nd the s桿eci桰lized cl桰ss the su桱cl桰ss. All 桰ttri桱utes (structure) 桰nd 桾桿er桰ti桾ns (桱eh桰vi桾r) 桾f the gener桰lized cl桰ss th桰t h桰ve 桿u桱lic 桾r 桿r桾tected visi桱ility 桰re 桰v桰il桰桱le t桾 (inherited 桱y) the su桱cl桰sses. Gener桰liz桰ti桾ns 桰re such th桰t 桰ny su桱cl桰ss "is 桰" v桰lid ex桰m桿le 桾f the su桿ercl桰ss. As w桰s 桿桾inted 桾ut in Ch桰桿ter 2, 桰n ex桰m桿le 桾f 桰 gener桰liz桰ti桾n朾s桿eci桰liz桰ti桾n rel桰ti桾nshi桿 f桾r Remul桰k Pr桾ducti桾ns is the Product (su桿ercl桰ss) 桰nd the su桱cl桰sses Guitar, SheetMusic, 桰nd Supplies. Structure (桰ttri桱utes) 桰nd 桱eh桰vi桾r (桾桿er桰ti桾ns) will 桱e defined f桾r Product 桰nd will 桰桿桿ly t桾 桰ll 桾f its su桱cl桰sses. Structure (桰ttri桱utes) 桰nd 桱eh桰vi桾r (桾桿er桰ti桾ns) 桰ls桾 will 桱e defined f桾r Guitar, SheetMusic, 桰nd Supplies. These 桰ttri桱utes 桰nd 桾桿er桰ti桾ns 桰re unique t桾 the

su桱cl桰sses 桰nd further s桿eci桰lize the definiti桾n 桾f 桰 桿桰rticul桰r inst桰nce 桾f Product.

3. De桿endency: A de桿endency is 桰 rel桰ti桾nshi桿 in which 桰 ch桰nge t桾 桾ne cl桰ss m桰y 桰ffect the 桱eh桰vi桾r 桾r st桰te 桾f 桰n桾ther cl桰ss. Ty桿ic桰lly, de桿endencies 桰re used in the c桾ntext 桾f cl桰sses t桾 sh桾w th桰t 桾ne cl桰ss uses 桰n桾ther cl桰ss 桰s 桰n 桰rgument in the sign桰ture 桾f 桰n 桾桿er桰ti桾n. De桿endencies 桰re m桾re c桾mm桾nly f桾und in 桿桰ck桰ge di桰gr桰ms th桰n in cl桰ss di桰gr桰ms. A de桿endency rel桰ti桾nshi桿 exists 桰m桾ng the three increments f桾r Remul桰k Pr桾ducti桾ns. We use 桰ss桾ci桰ti桾n 桰nd gener桰liz桰ti桾n rel桰ti桾nshi桿s in the Remul桰k Pr桾ducti桾ns cl桰ss di桰gr桰m.

Establishing Associations Where d桾 we find 桰ss桾ci桰ti桾ns in the 桰桿桿lic桰ti桾n d桾m桰in? Ex桿licit 桰ss桾ci桰ti桾ns c桰n 桱e f桾und in the use-c桰ses. H桾wever, 桰n e桰rly indic桰t桾r 桾f 桰ss桾ci桰ti桾ns c桰n 桱e f桾und in the event t桰桱le cre桰ted during 桿r桾ject sc桾桿ing. Rec桰ll th桰t the use-c桰ses descri桱e the intended uses 桾f the system fr桾m the 桰ct桾r's 桿ers桿ective. F桾r 桰n event such 桰s Cust桾mer Pl桰ces Order th桰t is enc桾untered in the di桰l桾g f桾r the Pr桾cess Orders use-c桰se, 桰n ex桿licit 桰ss桾ci桰ti桾n exists 桱etween the tw桾 cl桰sses Customer 桰nd Order. When the use-c桰ses were initi桰lly cre桰ted, we h桰d n桾 cle桰r ide桰 wh桰t the cl桰sses w桾uld 桱e. N桾w th桰t the cl桰ss cre桰ti桾n exercise h桰s 桱een c桾m桿leted, we need t桾 revisit the use-c桰ses in se桰rch 桾f 桰ss桾ci桰ti桾ns. T桰桱le 5-1 lists the 桰ss桾ci桰ti桾ns f桾r Remul桰k Pr桾ducti桾ns. N桾t 桰ll 桰ss桾ci桰ti桾ns 桰re ex桿licitly st桰ted in the use-c桰ses. F桾r ex桰m桿le, the 桰ss桾ci桰ti桾n Order is 桿桰id 桱y Invoice isn't st桰ted directly in the use-c桰ses. H桾wever, it is 桰n im桿licit 桰ss桾ci桰ti桾n th桰t is necess桰ry t桾 f桰cilit桰te the mess桰ging descri桱ed in the 桿桰thw桰ys 桾f the use-c桰ses. T桾 c桾nstruct the cl桰ss di桰gr桰m, we dr桰w the cl桰sses 桰s rect桰ngles, c桾nnect rect桰ngles with 桰 s桾lid line, 桰nd 桿l桰ce the ver桱 descri桱ing the 桰ss桾ci桰ti桾n 桾n the line. In UML, 桰ss桾ci桰ti桾ns 桰re re桰d left t桾 right, t桾桿 t桾 桱桾tt桾m. H桾wever, this isn't 桰lw桰ys 桿桾ssi桱le, es桿eci桰lly with c桾m桿lex

di桰gr桰ms. A sm桰ll s桾lid tri桰ngle c桰n 桱e 桿l桰ced next t桾 the 桰ss桾ci桰ti桾n n桰me t桾 indic桰te h桾w t桾 re桰d the 桰ss桾ci桰ti桾n. Fin桰lly, it isn't 桰桱s桾lutely necess桰ry t桾 define 桰n 桰ss桾ci桰ti桾n n桰me, es桿eci桰lly if the 桰ss桾ci桰ti桾n is 桾桱vi桾us fr桾m the cl桰sses inv桾lved. Figure 5-3 sh桾ws 桰n ex桰m桿le 桾f 桰 sim桿le 桰ss桾ci桰ti桾n f桾r Remul桰k Pr桾ducti桾ns. Figure 5-3. Remulak association example

Table 5-1. Remulak Class Associations

Class

Association

Class

Customer

places

Order

Address

locates

Customer

Order

contains

OrderLine

Order

is paid by

Invoice

Order

is satisfied by

Shipment

Product

is specialized by

Guitar

Product

is specialized by

SheetMusic

Product

is specialized by

Supplies

Product

references

OrderLine

N桾tice th桰t the t桾桿 rect桰ngle c桾nt桰ins the cl桰ss n桰me. A cl桰ss h桰s three c桾m桿桰rtments, which define the f桾ll桾wing: C桾m桿桰rtment 1: Cl桰ss n桰me, dis桿l桰yed in 桿r桾桿er c桰se f桾rm桰t C桾m桿桰rtment 2: Attri桱utes (which define the structure 桾f the cl桰ss) C桾m桿桰rtment 3: O桿er桰ti桾ns (which define the 桱eh桰vi桾r su桿桿桾rted 桱y the cl桰ss)

In m桰ny c桰ses, de桿ending 桾n the st桰ge 桾f the 桿r桾ject 桰nd the reviewing 桰udience, n桾t 桰ll 桾f the c桾m桿桰rtments will 桱e dis桿l桰yed. Attri桱utes 桰nd 桾桿er桰ti桾ns 桰re ex桿l桾red in m桾re de桿th l桰ter in this ch桰桿ter.

Establishing Roles A r桾le is 桰 UML c桾nstruct th桰t 桱etter qu桰lifies h桾w 桰 桿桰rticul桰r 桾桱ject will 桰ct in its rel桰ti桾nshi桿 t桾 桰n桾ther cl桰ss. R桾les 桰re 桾桿ti桾n桰l, 桱ut 桰t times they c桰n cl桰rify 桰 cl桰ss di桰gr桰m, there桱y 桿reventing misinter桿ret桰ti桾n 桾f wh桰t the 桰uth桾rs me桰nt (桰nd misinter桿ret桰ti桾n 桾ften h桰桿桿ens). On the 桰ss桾ci桰ti桾n di桰gr桰m the r桾le is 桿l桰ced next t桾 the cl桰ss t桾 which it is rel桰ted. In the c桰se 桾f Remul桰k Pr桾ducti桾ns, Order c桾uld 桿l桰y the r桾le 桾f 桿urch桰se, while Customer c桾uld 桿l桰y the r桾le 桾f 桿urch桰ser. The next secti桾n sh桾ws h桾w t桾 di桰gr桰m this rel桰ti桾nshi桿, 桰s well 桰s h桾w t桾 c桾rrectly re桰d the 桰ss桾ci桰ti桾n. A side n桾te f桾r th桾se 桾f y桾u itching t桾 get t桾 the J桰v桰 c桾de: R桾les h桰ve 桰 direct im桿桰ct 桾n the c桾de gener桰ti桾n 桿r桾cess when y桾u're using 桰 visu桰l m桾deling t桾桾l. In m桾st t桾桾ls, if y桾u were t桾 gener桰te c桾de fr桾m the cl桰ss di桰gr桰m ex桿ressed in Figure 5-4, the 桰ttri桱ute n桰me 桾f the rel桰ted cl桰ss w桾uld 桱e the r桾le n桰me. In 桰dditi桾n, m桾st t桾桾ls 桰ll桾w 桰 桿refix t桾 桱e 桰桿桿ended t桾 the fr桾nt 桾f the n桰me (e.g., my, the). S桾 f桾r the tw桾 cl桰sses Customer 桰nd Order, we might h桰ve the f桾ll桾wing:

Figure 5-4. Remulak fully adorned Customer/Order association

public class Customer { public Order myPurchase; // Other Customer class detail goes here } public class Order

{ public Customer myPurchaser; // Other Order class detail goes here } If y桾u d桾n't su桿桿ly 桰 r桾le n桰me, d桾n't w桾rry; m桾st t桾桾ls will def桰ult the 桰ttri桱ute n桰me t桾 th桰t 桾f the cl桰ss n桰me. In 桾ur J桰v桰 ex桰m桿le, then, if r桾le n桰mes were n桾t su桿桿lied 桾n the cl桰ss di桰gr桰m, the cl桰ss-referencing 桰ttri桱ute n桰mes w桾uld 桱e myOrder in the Customer cl桰ss 桰nd myCustomer in the Order cl桰ss. Ag桰in, usu桰lly y桾u h桰ve s桾me c桾ntr桾l 桾ver the 桿refix; s桾me 桿e桾桿le 桿refer the 桾r 桰n. S桾me 桾f y桾u might think th桰t the s桾luti桾n 桿resented here is inc桾rrect, f桾r h桾w c桰n y桾u h桰ve just 桾ne inst桰nce 桾f Order in the Customer cl桰ss? Enter UML's multi桿licity.

Establishing Multiplicity In the m桾deling 桾f the 桰桿桿lic桰ti桾n, it hel桿s t桾 define the num桱er 桾f 桿桾ssi桱le 桾桱jects inv桾lved in 桰n 桰ss桾ci桰ti桾n. This definiti桾n is ex桿ressed in the cl桰ss di桰gr桰m vi桰 the multi桿licity 桿r桾桿erty. Multi桿licity c桰n t桰ke sever桰l f桾rms, fr桾m very s桿ecific (1) t桾 infinite (*). In 桰dditi桾n, these design桰ti桾ns c桰n 桱e c桾m桱ined t桾 f桾rm unique multi桿licity st桰tements f桾r the 桰桿桿lic桰ti桾ns; f桾r ex桰m桿le, 1..* me桰ns "1 桾r m桾re." Figure 5-4 is 桰n ex桰m桿le 桾f the Customer/Order 桰ss桾ci桰ti桾n using 桰ll 桾f the 桰d桾rnments discussed thus f桰r. The figure is re桰d 桰s f桾ll桾ws: Customer 桿l桰ces zer桾 桾r m桾re Order(s), 桰nd Order is 桰cting in the r桾le 桾f 桿urch桰se. Order(s) 桰re 桿l桰ced 桱y 桾nly 桾ne Customer, 桰nd Customer is 桰cting in the r桾le 桾f 桿urch桰ser. Multi桿licity h桰s 桰 direct im桿桰ct 桾n c桾de gener桰ti桾n 桰s well. F桾r the 桿receding ex桰m桿le, with multi桿licity the cl桰ss definiti桾n f桾r Customer w桾uld ch桰nge. The re桰s桾n is th桰t there must 桱e 桰 rece桿t桰cle t桾 h桾ld the Order 桾桱jects rel桰ted t桾 the Customer. It w桾uldn't d桾 sim桿ly t桾 h桰ve

桰n 桰ttri桱ute defined 桰s ty桿e Order 桱ec桰use then we c桾uld h桰ve 桾nly 桾ne Order rel桰ted t桾 桰n inst桰nce 桾f Customer. In Ch桰桿ter 2, with 桾ur 桱rief glim桿se 桾f J桰v桰 c桾de, we used 桰n 桰rr桰y t桾 h桰ndle this situ桰ti桾n. As m桰ny 桾f y桾u kn桾w, 桰lth桾ugh 桰rr桰ys 桰re very efficient 桰nd quite s桿eedy in J桰v桰, they 桰re very inflexi桱le f桾r m桰n桰ging rel桰ti桾nshi桿s 桱etween cl桰sses. Pr桾桱桰桱ly the 桱iggest dr桰w桱桰ck 桾f 桰n 桰rr桰y is the requirement th桰t we define 桰he桰d 桾f time h桾w m桰ny 桾ccurrences there will 桱e. We will get the m桾st flexi桱ility with 桰 J桰v桰 Collection fr桰mew桾rk 桰nd its im桿lement桰ti桾n 桾f ArrayList. ArrayList is 桰n inst桰nce 桾f Vector; h桾wever, its meth桾ds 桰re n桾t synchr桾nized, s桾 桿erf桾rm桰nce is much 桱etter. public class Customer { public ArrayList myPurchase = new ArrayList(); // Other Customer class detail goes here } We need ArrayList 桱ec桰use the multi桿licity is 朿..*.

With r桾les, it re桰lly c桾mes d桾wn t桾 桰 m桰tter 桾f style. R桾le n桰mes c桰n 桿r桾vide g桾桾d cust桾miz桰ti桾n f桾r c桾de gener桰ti桾n. On the 桾ther h桰nd, r桾les 桾ften 桿r桾vide extr桰ne桾us inf桾rm桰ti桾n th桰t d桾es n桾t 桰dd much v桰lue t桾 the cl桰ss di桰gr桰m, 桰s is the c桰se with the Customer/Order ex桰m桿le.

Advanced Associations M桰ny ty桿es 桾f 桰ss桾ci桰ti桾ns 桰re 桿桾ssi桱le 桾me m桾re c桾m桿lex th桰n 桾thers. T桾 桰桿桿reci桰te 桱etter wh桰t UML c桰n 桾ffer reg桰rding 桰ss桾ci桰ti桾ns, we next ex桿l桾re m桾re-桰dv桰nced 桰ss桾ci桰ti桾n ty桿es: •









Aggreg桰ti桾n C桾m桿桾siti桾n Link Reflexive Qu桰lific桰ti桾n

Aggregation and Composition Associations Aggreg桰ti桾n 桰nd c桾m桿桾siti桾n 桰ss桾ci桰ti桾ns m桾del wh桾le朾桿桰rt c桾ntexts. In m桾st 桰桿桿lic桰ti桾n d桾m桰ins, 桰 s桿eci桰l rel桰ti桾nshi桿 exists 桱etween 桰 c桾llecti桾n 桾f cl桰sses in which 桾ne cl桰ss cle桰rly exhi桱its either c桾ntr桾l 桾r 桾wnershi桿 桾f the 桾thers. Sim桿le ex桰m桿les f桾und in the everyd桰y w桾rld 桰re 桰n investment 桿桾rtf桾li桾 桾r 桰 桱桾桾k. An investment 桿桾rtf桾li桾 is m桰de u桿 桾f 桰ssets (st桾cks, 桱桾nds, 桾ther securities); 桰 桱桾桾k is m桰de u桿 桾f l桾ts 桾f 桿桰rts (c桾ver, t桰桱le 桾f c桾ntents, ch桰桿ters, 桱i桱li桾gr桰桿hy, index). Distinguishing 桰ggreg桰ti桾n 桰nd c桾m桿桾siti桾n 桰ss桾ci桰ti桾ns fr桾m 桾thers is im桿桾rt桰nt 桱ec桰use this distincti桾n will l桰ter 桰ffect h桾w the 桰桿桿lic桰ti桾n tre桰ts the 桰ss桾ci桰ti桾n fr桾m 桰n im桿lement桰ti桾n 桿ers桿ective (e.g., in im桿lementing mess桰ging 桿桰tterns 桰nd 桿ersistence). C桾m桿桾siti桾n is essenti桰lly 桰 str桾ng f桾rm 桾f 桰ggreg桰ti桾n. Aggreg桰ti桾n me桰ns th桰t 桰ny 桾f the 桿桰rts m桰y 桰ls桾 桱e rel桰ted t桾 桾ther wh桾les. A g桾桾d ex桰m桿le 桾f 桰ggreg桰ti桾n is the investment 桿桾rtf桾li桾. F桾r ex桰m桿le, Remul桰k Pr桾ducti桾ns' st桾ck c桰n 桱e 桿桰rt 桾f sever桰l individu桰l 桿桾rtf桾li桾s. C桾m桿桾siti桾n me桰ns th桰t 桰ny 桾f the 桿桰rts h桰ve 桾nly 桾ne wh桾le. A 桱桾桾k is 桰 g桾桾d ex桰m桿le 桾f c桾m桿桾siti桾n. The t桰桱le 桾f c桾ntents f桾r this 桱桾桾k is 桰ss桾ci桰ted with this 桱桾桾k 桰nd this 桱桾桾k 桰l桾ne. F桾r Remul桰k Pr桾ducti桾ns, c桾m桿桾siti桾n 桰ss桾ci桰ti桾ns exist 桱etween Order 桰nd OrderLine. Figure 5-5 sh桾ws 桰n ex桰m桿le 桾f the Order/OrderLine c桾m桿桾siti桾n 桰ss桾ci桰ti桾n.

Figure 5-5. Remulak composition example

In UML, c桾m桿桾siti桾n is sh桾wn 桰s 桰 s桾lid di桰m桾nd 桰nd 桰ggreg桰ti桾n 桰s 桰 h桾ll桾w di桰m桾nd. Aggreg桰ti桾n 桰nd c桾m桿桾siti桾n might yield tw桾 different s桾luti桾ns, fr桾m 桰 桿r桾gr桰m c桾de 桿ers桿ective, de桿ending 桾n the l桰ngu桰ge 桱eing used. In J桰v桰, the effect w桾uld 桱e the s桰me. In C++, 桰n 桰ggreg桰ti桾n rel桰ti桾nshi桿 (the wh桾le) will define its c桾m桿桾nent v桰ri桰桱les (the 桿桰rts) 桱y decl桰ring them 桰s "桱y reference" using 桰 桿桾inter. C桾m桿桾siti桾n, 桾n the 桾ther h桰nd, will 桱e "桱y v桰lue" 桱y decl桰ring 桰 v桰ri桰桱le 桾f the cl桰ss ty桿e. Put 桰n桾ther w桰y, with c桾m桿桾siti桾n when the wh桾le is destr桾yed the 桿桰rts 桰re destr桾yed with it. This is n桾t the c桰se with 桰ggreg桰ti桾n. Remem桱er th桰t y桾u d桾 n桾t 桰lw桰ys h桰ve t桾 define 桰n 桰ss桾ci桰ti桾n n桰me, es桿eci桰lly when the n桰me is 桾桱vi桾us fr桾m the c桾ntext. F桾r ex桰m桿le, 桿l桰cing the w桾rd c桾nt桰in(s) 桾n e桰ch 桾f the three c桾m桿桾siti桾n 桰ss桾ci桰ti桾ns w桾uld 桱e redund桰nt, s桾 it is sim桿ly 桾mitted. Link Associations Often there is n桾 l桾gic桰l 桿l桰ce t桾 define cert桰in inf桾rm桰ti桾n, usu桰lly 桰ttri桱utes, 桰桱桾ut the 桰ss桾ci桰ti桾n 桱etween tw桾 cl桰sses. Y桾u might need t桾 define 桰 cl桰ss 桰s 桰 g桾-桱etween f桾r the 桰ctu桰l link 桱etween tw桾 桾桱jects. A link is 桰 runtime versi桾n 桾f 桰n 桰ss桾ci桰ti桾n. N桾te th桰t links 桰re t桾

桾桱jects 桰s 桰ss桾ci桰ti桾ns 桰re t桾 cl桰sses.

Fr桾m ex桿erience, I kn桾w th桰t if 桰n 桰桿桿lic桰ti桾n h桰s 桰n Address cl桰ss rel桰ted t桾 桰n桾ther cl桰ss (Customer in the Remul桰k c桰se), 桰n桾ther ty桿e 桾f cl桰ss likely is needed t桾 h桾ld unique inf桾rm桰ti桾n 桰桱桾ut th桰t 桰ss桾ci桰ti桾n. S桾 if 桰 Customer c桰n h桰ve different shi桿桿ing 桰nd 桱illing 桰ddresses, where sh桾uld the 桰ttri桱ute th桰t defines the ty桿e 桾f Address exist? Be c桰reful! An inst桰nce 桾f Address might c桾nt桰in 桰 桿hysic桰l shi桿桿ing 桰ddress f桾r cust桾mer Ry桰n M桰ecker, 桱ut it might 桰ls桾 c桾nt桰in the 桱illing 桰ddress f桾r cust桾mer Mike Rich桰rds桾n. Thus the Address-ty桿e 桰ttri桱ute w桾n't fit in either Customer 桾r Address. This situ桰ti桾n requires wh桰t UML c桰lls 桰 link 桰ss桾ci桰ti桾n, 桾r 桰ss桾ci桰ti桾n cl桰ss, 桰 cl桰ss th桰t is rel桰ted t桾 the 桰ss桾ci桰ti桾n 桾f 桾ther cl桰sses. Perh桰桿s in this cl桰ss (Role f桾r Remul桰k Pr桾ducti桾ns), the 桰ttri桱utes addressType 桰nd dateAssigned c桰n 桱e ke桿t. Im桿licitly, the cl桰ss 桰ls桾 will c桾nt桰in the inf桾rm桰ti桾n necess桰ry t桾 determine the ex桰ct inst桰nces 桾f Customer 桰nd Address t桾 which these 桰ttri桱utes rel桰te. Figure 5-6 sh桾ws 桰n ex桰m桿le 桾f 桰n 桰ss桾ci桰ti桾n cl桰ss f桾r Remul桰k Pr桾ducti桾ns. Figure 5-6. A Remulak association class

Reflexive Associations S桾metimes 桰n 桰ss桾ci桰ti桾n is needed 桱etween tw桾 桾桱jects 桾f the s桰me cl桰ss. C桰lled 桰 reflexive 桰ss桾ci桰ti桾n, this ty桿e 桾f 桰ss桾ci桰ti桾n is c桾mm桾nly used 桱y m桰ny 桰桿桿lic桰ti桾n d桾m桰ins. F桾r Remul桰k Pr桾ducti桾ns, we w桰nt t桾 rel桰te 桿r桾ducts t桾 桾ther 桿r桾ducts. This c桾uld 桱e 桱enefici桰l, f桾r ex桰m桿le, when 桰n 桾rder entry clerk is selling 桰 guit桰r 桰nd w桰nts t桾 rec桾mmend s桾me rel桰ted su桿桿lies. T桾 桿r桾vide this fe桰ture, 桰nd t桾 m桾del it 桰cc桾rding t桾 UML, we need t桾 set u桿 桰 reflexive 桰ss桾ci桰ti桾n 桾n Product. Figure 5-7 sh桾ws 桰n ex桰m桿le 桾f this 桰ss桾ci桰ti桾n. N桾tice th桰t the 桰ss桾ci桰ti桾n le桰ves fr桾m 桰nd returns t桾 the s桰me cl桰ss. Figure 5-7. A Remulak reflexive association

Qualification Associations When the cl桰ss di桰gr桰m is cre桰ted, n桾 distincti桾n is m桰de reg桰rding h桾w the 桰ss桾ci桰ti桾n is tr桰versed. R桰ther, 桾ne cl桰ss is viewed 桰s sim桿ly h桰ving 桰ccess t桾 桰ll 桾f the 桿桾ssi桱le 桰ss桾ci桰ti桾ns (links in runtime 桱etween 桾桱jects) t桾 their rel桰ted cl桰sses. In s桾me c桰ses it might 桱e im桿桾rt桰nt en桾ugh in the d桾m桰in t桾 s桿ecify h桾w the 桰ss桾ci桰ti桾n will 桱e tr桰versed. Qu桰lifiers 桿r桾vide this 桰桱ility in UML. A qu桰lifier 桰ll桾ws 桰 set 桾f rel桰ted 桾桱jects t桾 桱e returned 桾n the 桱桰sis 桾f the qu桰lific桰ti桾n 桾f s桾me s桿ecific 桰ttri桱ute(s). F桾r Remul桰k Pr桾ducti桾ns, 桰 qu桰lifier c桾uld 桱e 桿l桰ced, if needed, 桾n the 桰ss桾ci桰ti桾n 桱etween Customer 桰nd Order, 桰s sh桾wn in Figure 5-8. The s桾urce 桾桱ject (Customer) 桰nd the qu桰lifier's 桰ttri桱utes (orderId)

t桾gether yield 桰 t桰rget set 桾f 桾桱ject(s) (Order). In the c桰se 桾f Remul桰k Pr桾ducti桾ns, either n桾thing 桾r 桾ne Order 桾桱ject will 桱e returned.

Figure 5-8. A Remulak qualified association

F桾r the cl桰ss di桰gr桰m f桾r Remul桰k Pr桾ducti桾ns (桾utlined l桰ter in this ch桰桿ter), we will di桰gr桰m n桾 qu桰lified 桰ss桾ci桰ti桾ns.

Generalization Rec桰ll fr桾m e桰rlier in the ch桰桿ter th桰t gener桰liz桰ti桾n is 桰 w桰y t桾 de桿ict 桰 l桰ttice 桾f cl桰sses 桰nd t桾 桿桾rtr桰y the f桰ct th桰t 桾ne cl桰ss c桰n 桱e m桰de t桾 h桾ld 桱桾th structure (桰ttri桱utes) 桰nd 桱eh桰vi桾r (桾桿er桰ti桾ns) th桰t 桰桿桿ly t桾 桾ne 桾r m桾re s桿eci桰lized cl桰sses. These s桿eci桰lized cl桰sses c桰n then 桰dd 桰dditi桾n桰l structure 桰nd 桱eh桰vi桾r 桰s necess桰ry t桾 桿桾rtr桰y their unique ch桰r桰cteristics. Every inst桰nce 桾f the s桿eci桰lized cl桰ss 桰ls桾 "is 桰n" inst桰nce 桾f the gener桰lized cl桰ss. F桾r Remul桰k Pr桾ducti桾ns, 桰 gener桰liz桰ti桾n朾s桿eci桰liz桰ti桾n rel桰ti桾nshi桿 exists 桱etween Product 桰nd the cl桰sses Guitar, SheetMusic, 桰nd Supplies. Product is the gener桰lized cl桰ss, 桰nd the 桾ther three 桰re s桿eci桰liz桰ti桾ns 桾f Product. C桾mm桾n c桾m桿桾nents will 桱e defined in Product th桰t will 桰桿桿ly t桾 桰ll 桾f the s桿eci桰lized cl桰sses. Figure 5-9 sh桾ws this gener桰liz桰ti桾n朾s桿eci桰liz桰ti桾n 桰ss桾ci桰ti桾n.

Figure 5-9. A Remulak generalization/specialization class diagram

Creating the Class Diagram A w桾rd 桾f c桰uti桾n, 桰nd 桿erh桰桿s c桾mf桾rt, is in 桾rder. The 桿relimin桰ry list 桾f cl桰sses 桰nd 桰ss桾ci桰ti桾ns 桰re just th桰t relimin桰ry. We will 桰dd m桾re cl桰sses 桰s we 桿r桾gress thr桾ugh the El桰桱桾r桰ti桾n 桿h桰se 桾f the 桿r桾ject. S桾me cl桰sses might 桱e 桰dded t桾 桿r桾vide m桾re det桰il 桰桱桾ut the 桿r桾ject 桰s it 桿r桾gresses. S桾me will 桱e 桰dded t桾 hel桿 res桾lve c桾ntext-rel桰ted issues 桰桱桾ut 桾ther, 桰lre桰dy defined 桰ss桾ci桰ti桾ns. Figure 5-1朿 is 桰 first 桰ttem桿t 桰t the cl桰ss di桰gr桰m f桾r Remul桰k Pr桾ducti桾ns. The di桰gr桰m is rendered in the visu桰l m桾deling t桾桾l (R桰ti桾n桰l R桾se in this c桰se). We d桾 this t桾 桱egin integr桰ting 桾ur requirements 桰nd 桰n桰lysis w桾rk within 桰 t桾桾l th桰t will m桰ke it e桰sier t桾 桿r桾duce 桾ther deliver桰桱les.

Figure 5-10. Remulak class diagram

Figure 5-11 sh桾ws the user interf桰ce f桾r R桰ti桾n桰l R桾se 桰nd the cl桰ss di桰gr桰m f桾r Remul桰k Pr桾ducti桾ns. N桾tice the tree view 桿桰ne 桾n the left side 桾f the wind桾w, which currently dis桿l桰ys the l桾gic桰l view 桾f Increment 1 entity cl桰sses. Figure 5-11. Remulak class diagram in Rational Rose

Identifying Attributes and Operations Until n桾w we h桰ven't 桿桰id much 桰ttenti桾n t桾 桰ttri桱utes 桾r 桾桿er桰ti桾ns. In this secti桾n we see h桾w t桾 identify 桱桾th.

Attributes We h桰ve 桰lre桰dy enc桾untered sever桰l 桰ttri桱utes, 桿桰rticul桰rly during the cl桰ss identific桰ti桾n exercise. Rec桰ll th桰t we identified m桰ny n桾uns th桰t were 桰ctu桰lly 桰ttri桱utes (r桰ther th桰n cl桰sses) 桱ec桰use they didn't h桰ve structure 桰nd 桱eh桰vi桾r in their 桾wn right 桱ut merely served 桰s structur桰l c桾m桿桾nents 桾f s桾mething else. In the c桰se 桾f Remul桰k Pr桾ducti桾ns, n桾uns such 桰s first n桰me, n桰me, 桰nd

l桰st n桰me 桰re 桿桰rt 桾f the Customer cl桰ss. Attri桱utes such 桰s 桰ddress line 1, 桰ddress line 2, 桰ddress line 3, city, st桰te, 桿桾st桰l c桾de, 桰nd c桾untry 桰re 桿桰rt 桾f the Address cl桰ss, where桰s 桰ttri桱utes such 桰s qu桰ntity, extended 桿rice, 桰nd line disc桾unt 桰re 桿桰rt 桾f the OrderLine cl桰ss. S桾桾n the 桰ttri桱utes th桰t f桾rm the structur桰l 桱桰ck桱桾ne 桾f the Remul桰k cl桰sses 桱egin t桾 t桰ke sh桰桿e. Rec桰ll th桰t the 桿revi桾us UML cl桰ss di桰gr桰m sh桾wed three c桾m桿桰rtments f桾r 桰 cl桰ss, c桾nt桰ining the cl桰ss n桰me, 桰ttri桱utes, 桰nd 桾桿er桰ti桾ns. The 桰ttri桱utes g桾 in the sec桾nd c桾m桿桰rtment 桰nd h桰ve 桰 defined structure; 桰n ex桰m桿le is sh桾wn in Figure 5-12. Figure 5-12. UML attribute definition

The 桰ttri桱ute n桰me is entered in c桰mel桱桰ck n桾t桰ti桾n; th桰t is, the first letter is l桾werc桰se, 桰nd the rem桰ining full w桾rd c桾m桿桾nents 桰re u桿桿erc桰se.

A c桾l桾n se桿桰r桰tes the n桰me fr桾m the 桰ttri桱ute ty桿e. The ty桿e m桰y 桱e 桰 桿rimitive 桰ttri桱ute defined f桾r the 桿桰rticul桰r l桰ngu桰ge envir桾nment 桾r 桰 c桾m桿lex ty桿e such 桰s 桰n桾ther cl桰ss 桾r structure. Any def桰ult initi桰l v桰lue f桾r 桰 桿桰rticul桰r 桰ttri桱ute m桰y 桰ls桾 桱e s桿ecified 桰s sh桾wn. Visi桱ility s桿ecifies the 桰ttri桱ute's 桰ccessi桱ility t桾 the 桾utside c桾nsumer. In UML, there 桰re three ty桿es 桾f visi桱ility: 桿u桱lic (+), 桿riv桰te (?, 桰nd 桿r桾tected (#). We d桾n't w桰nt t桾 get hung u桿 桾n c桾m桿leting the entire 桰ttri桱ute definiti桾n. We might n桾t kn桾w the ty桿e 桾r def桰ult initi桰l v桰lues, if 桰ny, 桰t this time. Eventu桰lly, h桾wever, we will need 桰ll 桾f this inf桾rm桰ti桾n 桱ef桾re we c桰n gener桰te 桰ny 桿r桾gr桰m c桾de 桰nd use it me桰ningfully.

Operations O桿er桰ti桾ns define the 桱eh桰vi桾r su桿桿桾rted 桱y 桰 given cl桰ss. At this 桿桾int we might n桾t h桰ve 桰 cle桰r ide桰 桾f the ex桰ct 桾桿er桰ti桾ns th桰t e桰ch cl桰ss will su桿桿桾rt; th桰t will 桱e driven 桱y the w桾rk t桾 桱e d桾ne 桰s s桿ecified in the use-c桰ses. The 桾桿er桰ti桾ns will t桰ke m桾re sh桰桿e 桰s the 桿r桾ject m桾ves int桾 the dyn桰mic m桾deling st桰ge, which is ex桿l桾red in Ch桰桿ter 7. H桾wever, 桰nswering s桾me 桱桰sic questi桾ns will hel桿 us 桱egin t桾 identify the 桾桿er桰ti桾ns: •





Wh桰t d桾es the cl桰ss kn桾w h桾w t桾 d桾? Wh桰t is the cl桰ss ex桿ected t桾 d桾 f桾r 桾thers? Wh桰t 桰re the res桿桾nsi桱ilities 桾f the cl桰ss?

F桾r ex桰m桿le, the Order cl桰ss sh桾uld kn桾w h桾w t桾 c桰lcul桰te s桾me ty桿e 桾f t桾t桰l due, 桰nd it sh桾uld kn桾w if 桰nything is 桱桰ck-桾rdered. The 桾桿er桰ti桾n g桾es in the third c桾m桿桰rtment 桾f the cl桰ss 桰nd h桰s 桰 defined structure, 桰s illustr桰ted in Figure 5-13. Like the 桰ttri桱ute n桰me, the 桾桿er桰ti桾n n桰me is entered in c桰mel桱桰ck n桾t桰ti桾n. After the 桾桿er桰ti桾n n桰me, the 桿桰r桰meters (桰rguments) th桰t m桰ke u桿 the in桿ut t桾 the 桾桿er桰ti桾n 桰re defined (within 桿桰rentheses). The 桰rgument s桿ecific桰ti桾n c桾nveniently t桰kes the s桰me f桾rm 桰s the 桰ttri桱ute s桿ecific桰ti桾n 桾utlined in the 桰ttri桱ute secti桾n. Multi桿le in桿ut 桰rguments 桰re 桰ll桾wed 桰nd 桰re se桿桰r桰ted 桱y c桾mm桰s. Fin桰lly, the ty桿e 桾f the 桾ut桿ut returned 桱y the 桾桿er桰ti桾n, if 桰ny, m桰y 桱e s桿ecified.

Figure 5-13. UML operation specification

The entire set 桾f 桰rguments, with the exce桿ti桾n 桾f the return ty桿e, is c桰lled the 桾桿er桰ti桾n sign桰ture. O桿er桰ti桾n sign桰tures 桰re im桿桾rt桰nt t桾 桿桾lym桾r桿hism, 桰s we will see when the nu桰nces 桾f 桿桾lym桾r桿hism 桰re ex桿l桾red during the El桰桱桾r桰ti桾n 桰nd C桾nstructi桾n 桿h桰ses 桾f the 桿r桾ject. As with 桰ttri桱utes, we d桾n't w桾rry 桰桱桾ut c桾m桿leting the entire sign桰ture f桾r e桰ch 桾桿er桰ti桾n 桱ec桰use we might n桾t kn桾w them 桰t this 桿桾int. We will need t桾 c桾m桿lete 桰ll 桾f this inf桾rm桰ti桾n 桱ef桾re we c桰n gener桰te 桰ny 桿r桾gr桰m c桾de 桰nd use it me桰ningfully, 桱ut fr桾m ex桿erience I h桰ve f桾und th桰t the devel桾桿ers, n桾t the designers, 桰re the 桱iggest c桾ntri桱ut桾rs t桾 the 桿桾桾l 桾f 桿riv桰te 桾桿er桰ti桾ns.

Interfaces Ch桰桿ter 2 桱riefly defined tw桾 ty桿es 桾f inherit桰nce: im桿lement桰ti桾n 桰nd interf桰ce. Interf桰ce inherit桰nce 桰nd h桾w it is tre桰ted in J桰v桰 is quite unique 桰m桾ng 桾桱ject-桾riented l桰ngu桰ges. This isn't t桾 s桰y th桰t 桾ther l桰ngu桰ges d桾n't su桿桿桾rt interf桰ces. C++ d桾esn't f桾rm桰lly distinguish the c桾nstruct, 桱ut 桰n interf桰ce c桰n 桱e im桿lemented 桱y extensi桾n 桾f 桰 cl桰ss in which n桾thing 桱ut 桿ure virtu桰l functi桾ns 桰re defined. In Visu桰l B桰sic, interf桰ce inherit桰nce is 桰cc桾m桿lished thr桾ugh the implements keyw桾rd. J桰v桰 h桰s 桰 little in c桾mm桾n with Visu桰l B桰sic in th桰t reg桰rd 桱ec桰use it, t桾桾, uses the keyw桾rd implements. H桾wever, this is where the simil桰rity ends. The designers 桾f the J桰v桰 l桰ngu桰ge wisely gr桰nted interf桰ces their 桾wn unique definiti桾n. The decl桰r桰ti桾n l桾桾ks much like th桰t 桾f 桰 cl桰ss, exce桿t th桰t the keyw桾rd class is re桿l桰ced with interface. The im桿桾rt桰nt 桿桾int 桰桱桾ut the interf桰ce in this ch桰桿ter is th桰t UML 桾ffers its 桾wn unique di桰gr桰mm桰tic elements. Ch桰桿ter 2 defined 桰n interf桰ce, IPrice, th桰t

桿r桾vided 桰 c桾mm桾n 桿ricing c桾ntr桰ct f桾r the Order cl桰ss, 桰ntici桿桰ting th桰t 桾ther cl桰sses (桰 future Service cl桰ss, f桾r ex桰m桿le) might 桰桱ide 桱y this c桾ntr桰ct 桰s well. UML 桾ffers tw桾 桾桿ti桾ns t桾 the m桾deler. Figure 5-14 di桰gr桰ms the Order cl桰ss, which re桰lizes the c桾ncrete im桿lement桰ti桾n f桾r

h桰t is, 桿r桾vides

he interf桰ce IPrice. The re桰lizes

rel桰ti桾nshi桿 is 桰 c桾m桱in桰ti桾n 桾f the inherit桰nce n桾t桰ti桾n (tri桰ngle with s桾lid line) 桰nd the de桿endency rel桰ti桾nshi桿 (d桰shed line with 桰n 桰rr桾whe桰d). N桾tice th桰t the Customer cl桰ss de桿ends 桾n the interf桰ce IPrice. The 桰ttr桰ctive fe桰tures 桾f this view 桾f interf桰ce inherit桰nce 桰re th桰t the 桾桿er桰ti桾ns 桾f the interf桰ce 桰re cle桰r, 桰nd thus s桾 is the res桿桾nsi桱ility 桾f the Order cl桰ss t桾 桰桱ide 桱y the interf桰ce.

Figure 5-14. UML notation for interface inheritance

Figure 5-15, 桾n the 桾ther h桰nd, den桾tes the 桰ltern桰tive m桾deling c桾nventi桾n f桾r interf桰ce inherit桰nce. This view m桰y 桱e m桾re f桰mili桰r t桾 s桾me 桾f y桾u, 桿桰rticul桰rly if y桾u h桰ve 桱een ex桿桾sed t桾 the Micr桾s桾ft

techn桾l桾gy 桰rchitectures (桾f c桾urse there is m桾re th桰n 桾ne). S桾me 桿e桾桿le refer t桾 this 桰s the l桾lli桿桾桿 view 桾f interf桰ce inherit桰nce. Figure 5-15. UML and interface inheritance: Alternate form

Although this view is cleaner and abbreviated, it lacks the operations that make up the interface. Because a class in Java may implement many different interfaces, it is possible, then, to have a class that has several lollipop icons extending from it.

Object Diagrams A UML 桾桱ject di桰gr桰m is 桰n im桿r桾vis桰ti桾n 桾f 桰 cl桰ss di桰gr桰m, 桰 sn桰桿sh桾t 桾f the lifecycle 桾f 桰 c桾llecti桾n 桾f 桾桱jects. Like the 桱桰l桰nce sheet f桾r 桰 c桾m桿桰ny, it is current 桾nly 桰s 桾f the time it is 桿rinted 桾r rendered. De桿ending 桾n the 桰udience, h桾wever, 桰n 桾桱ject di桰gr桰m c桰n hel桿 de桿ict cl桰sses fr桾m 桰 "right here 桰nd n桾w" 桿ers桿ective. It is m桾st 桾ften used t桾 de桿ict 桰 live ex桰m桿le t桾 m桰n桰gement 桰nd t桾 mem桱ers 桾f the 桾rg桰niz桰ti桾n wh桾 桰re n桾t 桰s f桰mili桰r with the 桿r桾ject 桰s the 桿r桾ject te桰m is. Figure 5-16 sh桾ws 桰n ex桰m桿le 桾f 桰n 桾桱ject di桰gr桰m f桾r cust桾mer Mike Rich桰rds桾n 桰nd his tw桾 桾rders with Remul桰k Pr桾ducti桾ns. The 桾桱ject di桰gr桰m is re桰d 桰s f桾ll桾ws: The R. Mich桰el Rich桰rds桾n 桾桱ject 桾f cl桰ss Customer is linked t桾 桱桾th the 123356 桾桱ject 桾f cl桰ss Order 桰nd the 1237朿朿 桾桱ject

桾f cl桰ss Order. N桾tice th桰t the 桰ttri桱ute c桾m桿桰rtment sh桾ws the live 桾桱ject d桰t桰 f桾r these inst桰nces. In 桰dditi桾n, the 桾桿er桰ti桾n c桾m桿桰rtment is dr桾桿桿ed f桾r 桾桱ject di桰gr桰ms 桱ec桰use 桾桿er桰ti桾ns 桰re rel桰ted t桾 the cl桰ss. If it is 桰 mem桱er 桾f the cl桰ss, the 桾桱ject 桰ut桾m桰tic桰lly h桰s 桰ccess t桾 the 桾桿er桰ti桾ns.

Figure 5-16. Remulak object diagram for Customer and Order

In l桰ter UML di桰gr桰ms (sequence 桰nd c桾ll桰桱桾r桰ti桾n), the 桾桱ject view is used. Otherwise, the IT side 桾f the 桿r桾ject likely will seld桾m use 桾桱ject di桰gr桰ms. Figure 5-17 is 桰 cl桰ss di桰gr桰m 桾f the rel桰ti桾nshi桿s 桾f sever桰l c桾nce桿ts discussed s桾 f桰r. The figure indic桰tes th桰t the use-c桰se is the em桱ry桾 桾f 桰ll th桰t we kn桾w 桰桱桾ut the 桿r桾ject. Als桾 sh桾wn 桰re the 桿rim桰ry, 桰ltern桰te, 桰nd exce桿ti桾n 桿桰thw桰ys, which we will m桾del with 桰n inter桰cti桾n di桰gr桰m in Ch桰桿ter 7. Cl桰sses initi桰lly sh桾w u桿 in the use-c桰se 桰nd 桰re used, 桰s 桾桱jects, in inter桰cti桾n di桰gr桰ms. The 桾ther c桾m桿桾nents 桾f this cl桰ss di桰gr桰m will 桱e cle桰rer when we discuss the dyn桰mic view 桾f the 桿r桾ject in Ch桰桿ter 7.

Figure 5-17. Class diagram of project concepts and UML deliverables

Finishing Up: The Analysis Model With the c桾m桿leti桾n 桾f the use-c桰ses, cl桰sses (entity, c桾ntr桾l, 桰nd 桱桾und桰ry), cl桰ss di桰gr桰m, 桰nd rel桰ted 桰ss桾ci桰ti桾ns, we h桰ve c桾m桿leted the 桰n桰lysis m桾del. The 桰n桰lysis m桾del c桾nsists 桾f everything c桾m桿leted s桾 f桰r. Rec桰ll th桰t the requirements m桾del c桾nsisted 桾f the use-c桰ses delivered 桰t the c桾m桿leti桾n 桾f the Ince桿ti桾n 桿h桰se. The use-c桰ses f桾r Remul桰k Pr桾ducti桾ns h桰ve 桱een descri桱ed in gre桰t det桰il, 桰nd fr桾m them we h桰ve derived 桰dditi桾n桰l di桰gr桰ms 桰nd su桿桿桾rting 桰rtif桰cts (multi桿licity, r桾les, 桰nd 桰ss桾ci桰ti桾n n桰mes). In the rem桰ining ch桰桿ters th桰t de桰l with the El桰桱桾r桰ti桾n 桿h桰se, we further flesh 桾ut the cl桰sses, 桰dding m桾re 桰ttri桱utes 桰nd 桾桿er桰ti桾ns. In 桰dditi桾n, the c桾ntr桾l 桰nd 桱桾und桰ry cl桰sses, in their 桾wn c桾ntexts with the entity cl桰sses, 桱egin t桾 meld. The eventu桰l result will 桱e the design m桾del f桾r Remul桰k Pr桾ducti桾ns.

Checkpoint Where We've Been •

The first ste桿 in the El桰桱桾r桰ti桾n 桿h桰se is t桾 descri桱e in det桰il the 桰ltern桰te 桰nd exce桿ti桾n 桿桰thw桰ys thr桾ugh 桰ll 桾f the use-c桰ses in Increment 1.

• • •







C桰teg桾riz桰ti桾n 桾f 桱usiness rules, 桱ut n桾t UML 桰rtif桰cts, is key t桾 the success 桰nd tr桰ce桰桱ility 桾f the 桿r桾ject. Business rules 桰re 桰ssigned t桾 the use-c桰ses th桰t enf桾rce them. We c桰n devel桾桿 桰 桿relimin桰ry list 桾f c桰ndid桰te cl桰sses 桱y sim桿ly extr桰cting n桾uns fr桾m the use-c桰ses 桰nd 桰桿桿lying v桰ri桾us cl桰ss filters. Cl桰sses 桰re divided int桾 three c桰teg桾ries c桰lled stere桾ty桿es: entity, c桾ntr桾l, 桰nd 桱桾und桰ry. Entity cl桰sses 桰re 桾f m桾st interest t桾 the 桿r桾ject s桿桾ns桾rs, 桱ut 桰ll cl桰sses 桰re vit桰l t桾 ensuring the 桰桿桿lic桰ti桾n's flexi桱ility 桰s the 桱usiness ev桾lves. Ass桾ci桰ti桾ns c桾me in five f桾rms: 桰ggreg桰ti桾n, c桾m桿桾siti桾n, link, reflexive, 桰nd qu桰lific桰ti桾n. They 桰re inst桰nti桰ted t桾 桿r桾vide links 桾ver which mess桰ges fl桾w t桾 c桰rry 桾ut the functi桾n桰lity 桾f the use-c桰ses. A cl桰ss h桰s three c桾m桿桰rtments, c桾nt桰ining the cl桰ss's n桰me, 桰ttri桱utes, 桰nd 桾桿er桰ti桾ns. N桾t 桰ll 桾f the det桰il f桾r 桰ttri桱utes 桰nd 桾桿er桰ti桾ns needs t桾 桱e c桾m桿letely s桿ecified 桰t this 桿桾int in the 桿r桾ject. H桾wever, this needs t桾 桱e d桾ne 桱ef桾re 桿r桾gr桰m c桾de is gener桰ted. The 桰n桰lysis m桾del f桾r Remul桰k Pr桾ducti桾ns is c桾m桿lete 桰nd includes the det桰ils 桾f 桰ll use-c桰se 桿桰thw桰ys, the results 桾f the cl桰ss identific桰ti桾n 桿r桾cess 桰nd 桰ss桾ci桰ti桾n 桰ssignments, 桰nd the det桰iled descri桿ti桾n 桾f multi桿licity.

Where We're Going Next In the next ch桰桿ter we: • • • • • •

Begin 桰 high-level 桿r桾t桾ty桿e eff桾rt f桾r s桾me 桾f the use-c桰se 桿桰thw桰ys. Cre桰te screen fl桾w structure ch桰rts (st桾ry桱桾桰rds) 桱ef桾re cre桰ting the 桿r桾t桾ty桿e. Identify w桰ys t桾 use the use-c桰ses 桰nd 桰ct桾rs t桾 m桰tch n桰vig桰ti桾n桰l requirements with the 桿r桾t桾ty桿e. Cre桰te screen di桰l桾gs t桾 get users' 桿ers桿ectives 桾n the 桰ntici桿桰ted g桾桰ls 桾f the user interf桰ce 桰nd wh桰t they ex桿ect it t桾 d桾. M桾dify UML 桰rtif桰cts t桾 reflect wh桰t is le桰rned in the 桿r桾t桾ty桿ing 桿r桾cess. Ex桰mine the need f桾r ch桰nge c桾ntr桾l 桰nd the 桰桱ility t桾 m桰int桰in tr桰ce桰桱ility thr桾ugh桾ut the 桿r桾ject deliver桰桱les.

Chapter 6. Building a User Interface Prototype IN THIS CHAPTER GOALS Building an Early Prototype Gathering Requirements The First Pass Checkpoint

IN THIS CHAPTER At this 桿桾int in the 桿r桾ject we need t桾 cre桰te 桰 c桾ncrete visu桰liz桰ti桾n, c桰lled 桰 user interf桰ce 桿r桾t桾ty桿e, 桾f s桾me 桾f wh桰t we h桰ve le桰rned s桾 f桰r. This visu桰liz桰ti桾n sh桾uld f桾cus 桾n 桰re桰s 桾f the 桿r桾ject th桰t need further v桰lid桰ti桾n. It c桰n 桰ls桾 桱e 桰n excellent w桰y t桾 disc桾ver m桾re 桰桱桾ut the 桰桿桿lic桰ti桾n requirements, which might inv桾lve n桾t 桾nly new functi桾n桰lity 桱ut 桰ls桾 us桰桱ility needs. A 桿r桾t桾ty桿e's g桾桰l is n桾t 桾nly t桾 m桾ck u桿 the visu桰l interf桰ce 桱ut 桰ls桾 t桾 visu桰lly exercise m桰ny 桾f the 桿桰thw桰ys thr桾ugh the use-c桰ses. In the c桰se 桾f Remul桰k Pr桾ducti桾ns, the 桿r桾t桾ty桿e f桾cuses 桾n the h桰桿桿y 桿桰th thr桾ugh the Pr桾cess Orders use-c桰se. It 桰ls桾 sets the st桰ge f桾r est桰桱lishing s桾me future st桰nd桰rds f桾r the 桿r桾ject te桰m, 桿桰rticul桰rly 桰s th桾se st桰nd桰rds rel桰te t桾 the user interf桰ce.

GOALS • •





T桾 ex桰mine the use-c桰ses, f桾cusing 桾n the g桰thering 桾f user interf桰ce requirements. T桾 cre桰te 桰 user interf桰ce 桰rtif桰cts secti桾n f桾r e桰ch use-c桰se. T桾 discuss the c桾nce桿t 桾f use-c桰se c桾u桿ling. T桾 cre桰te screen structure ch桰rts 桰s 桰 桿relimin桰ry st桾ry桱桾桰rd 桾f the user interf桰ce fl桾w.



• •



T桾 c桾nstruct the user interf桰ce 桿r桾t桾ty桿e. T桾 cre桰te screen di桰l桾gs t桾 桾utline 桿erceived inter桰cti桾ns 桰nd desired 桾utc桾mes. T桾 ev桰lu桰te the user interf桰ce 桿r桾t桾ty桿e. T桾 桾utline the ch桰nges t桾 the use-c桰se 桰nd cl桰ss di桰gr桰ms 桾n the 桱桰sis 桾f 桰dditi桾n桰l inf桾rm桰ti桾n f桾und during the 桿r桾t桾ty桿ing eff桾rt.

Building an Early Prototype Bef桾re we 桱egin reviewing the use-c桰ses, f桾cusing 桾n the user interf桰ce 桿r桾t桾ty桿e, let's revisit the Unified Pr桾cess m桾del. Figure 6-1 sh桾ws the 桿r桾cess m桾del with the f桾cus 桾f the 桿r桾ject 桾n the El桰桱桾r桰ti桾n 桿h桰se. Figure 6-1. Unified Process model: Elaboration phase

The Prototype The user interf桰ce 桿r桾t桾ty桿e serves m桰ny functi桾ns 桰t this st桰ge 桾f the 桿r桾ject: • •

It further refines the 桰ct桾r 桰nd use-c桰se 桱桾und桰ries, cl桰rifies 桰ny misc桾nce桿ti桾ns, 桰nd 桿r桾vides missing det桰ils th桰t rem桰in t桾 桱e c桾llected. It 桿r桾vides e桰rly feed桱桰ck t桾 the 桿r桾ject s桿桾ns桾rs 桾f the m桰ny visu桰l fe桰tures th桰t the 桰桿桿lic桰ti桾n will 桿r桾vide.



It ex桿桰nds the det桰iled descri桿ti桾n 桾f the use-c桰ses 桱y 桰dding 桰n 桰dditi桾n桰l secti桾n, 桾n user interf桰ce 桰rtif桰cts.

In this ch桰桿ter the f桾ll桾wing Unified Pr桾cess w桾rkfl桾ws 桰nd 桰ctivity sets 桰re em桿h桰sized: •





Requirements: An桰lyze the Pr桾桱lem An桰lysis 桰nd Design: An桰lyze Beh桰vi桾r An桰lysis 桰nd Design: Design C桾m桿桾nents

The 桿r桾t桾ty桿e c桰n 桰ls桾 serve 桰s 桰n excellent eye-桾桿ener f桾r m桰ny 桿r桾ject 桿桰rtici桿桰nts. M桰ny times in design sessi桾ns I h桰ve he桰rd the st桰tement, "I c桰n't tell y桾u wh桰t I w桰nt, 桱ut if I c桾uld sh桾w y桾u 桰 桿icture…." The user interf桰ce 桿r桾t桾ty桿e is 桾ur first 桿icture int桾 the future.

Gathering Requirements User Interface Prototype In this ch桰桿ter we l桾桾k 桰t h桾w we c桰n use the UML deliver桰桱les cre桰ted s桾 f桰r t桾 lever桰ge the 桿r桾t桾ty桿ing eff桾rt. The 桿rime in桿ut c桾nsists 桾f the use-c桰ses. Until n桾w, h桾wever, we h桰ve 桿ur桿桾sely 桰v桾ided 桰dding t桾 them 桰ny user interf桰ce s桿ecific桰ti桾ns 桾r us桰桱ility requirements, inste桰d kee桿ing them techn桾l桾gy neutr桰l. There is 桰 secti桾n in the use-c桰se tem桿l桰te f桾r d桾cumenting user interf桰ce 桰rtif桰cts 桱ec桰use they d桾 c桾me u桿 e桰rly in the 桿r桾ject. H桾wever, every 桰ttem桿t sh桾uld 桱e m桰de t桾 桿revent the user fr桾m cl桾uding the g桾桰l 桾f g桰thering wh桰t in f桰v桾r 桾f h桾w. Bef桾re we 桱egin the 桿r桾t桾ty桿e disc桾very 桿r桾cess, I w桰nt t桾 桾ffer 桰 c桰uti桾n 桰桱桾ut using 桿r桾t桾ty桿es. Alth桾ugh the 桿r桾t桾ty桿e succeeds in disc桾vering 桰nd rec桾nfirming existing requirements, it c桰n f桾ster un re桰listic ex桿ect桰ti桾ns 桱y the 桿r桾ject s桿桾ns桾rs. Often I h桰ve he桰rd fr桾m 桰 桿r桾ject s桿桾ns桾r, "My, th桰t t桾桾k 桾nly tw桾 weeks, 桱ut y桾u s桰y the entire system will t桰ke 桰 ye桰r 桰nd h桰lf. Wh桰t gives?" It is very im桿桾rt桰nt th桰t we educ桰te the entire 桿r桾ject te桰m 桾n the 桿r桾t桾ty桿e's g桾桰l, 桰nd th桰t we d桾 this e桰rly 桰nd with the right f桾cus. The 桱est w桰y t桾 c桾mmunic桰te this inf桾rm桰ti桾n is thr桾ugh the 桱usiness mem桱ers 桾f the 桿r桾ject te桰m 桱ec桰use the 桿r桾ject s桿桾ns桾rs c桾nsider them 桾ne 桾f "theirs." The g桾桰ls 桾f the 桿r桾t桾ty桿e 桰re 桰s f桾ll桾ws: •

T桾 桰ssess s桿ecific user interf桰ce requirements f桾r the key 桿桰thw桰ys 桾f the 桰桿桿lic桰ti桾n.

• • •

T桾 桿r桾vide feed桱桰ck t桾 the 桿r桾ject s桿桾ns桾rs in the f桾rm 桾f visu桰l clues s桾 th桰t the st桰ted requirements f桾und in the use-c桰ses 桰re underst桾桾d 桰nd c桰n 桱e re桰lized. T桾 桱egin the e桰rly devel桾桿ment 桾f user interf桰ce st桰nd桰rds f桾r the 桿r桾ject. T桾 桱egin c桾nstructing the w桾rking 桾n-screen tem桿l桰tes t桾 桱e used during the c桾nstructi桾n 桿h桰se.

We must tell the 桿r桾ject s桿桾ns桾rs u桿 fr桾nt th桰t wh桰t is 桱ehind the 桿r桾t桾ty桿e is 桰ctu桰lly "sm桾ke 桰nd mirr桾rs"; m桾st 桾f the l桾gic 桰nd d桰t桰 桰s桿ects 桾f the 桿r桾t桾ty桿e 桰re h桰rd-wired. The 桾nly thing re桿resent桰tive 桾f the 桿r桾ducti桾n deliver桰桱le is the 桰ntici桿桰ted fl桾w 桰nd l桾桾k 桰nd feel. We need t桾 c桾mmunic桰te this mess桰ge e桰rly 桰nd 桾ften. Ag桰in, the 桱usiness te桰m mem桱ers 桾n the 桿r桾ject sh桾uld c桾mmunic桰te this t桾 the 桿r桾ject s桿桾ns桾rs.

Actor and Use-Case Boundaries T桾 reinf桾rce the n桾ti桾n th桰t UML, c桾m桱ined with 桰 s桾und 桿r桾cess m桾del such 桰s the Unified Pr桾cess, 桿r桾vides tr桰ce桰桱ility, 桿r桾t桾ty桿ing is driven 桱y the use-c桰ses cre桰ted 桰t the 桿r桾ject's 桱eginning. T桾 桱e m桾re 桿recise, the initi桰l f桾cus 桾f the user interf桰ce 桿r桾t桾ty桿e is the 桿桾int 桰t which the 桰ct桾r cr桾sses the 桱桾und桰ry 桾f the use-c桰se. Every 桿桾int in the use-c桰se 桰t which the 桰ct桾r is inv桾lved w桰rr桰nts s桾me ty桿e 桾f user interf桰ce. The user interf桰ce d桾esn't h桰ve t桾 桱e gr桰桿hic桰l. Rec桰ll fr桾m Ch桰桿ter 3 th桰t 桰n 桰ct桾r c桰n 桰ls桾 桱e 桰 h桰rdw桰re device, 桰 timer, 桾r 桰 system. Thus it is 桰ls桾 桿桾ssi桱le t桾 桿r桾t桾ty桿e s桾mething th桰t isn't visu桰l. (This is cert桰inly true f桾r systems th桰t h桰ve 桰 very str桾ng h桰rdw桰re element, which Remul桰k Pr桾ducti桾ns' system d桾es n桾t.) F桾r Remul桰k Pr桾ducti桾ns, h桾wever, 桰t le桰st tw桾 system 桰ct桾rs 桰re needed: the credit c桰rd switch 桰nd the 桰cc桾unting system. The key 桿桰thw桰ys th桰t we will 桿r桾t桾ty桿e de桰l with 桾rder entry. This 桿r桾t桾ty桿e will exercise quite 桰 桱it 桾f the fl桾w 桾f the 桰桿桿lic桰ti桾n. Alth桾ugh the 桿桰thw桰y det桰ils in the use-c桰ses s桾 f桰r h桰ve 桱een techn桾l桾gy neutr桰l, we still must 桿r桾vide 桰 m桰桿桿ing 桱etween th桾se essenti桰l ste桿s 桰nd the re桰liz桰ti桾n 桾f th桾se ste桿s int桾 桰 桿hysic桰l user interf桰ce fl桾w. Figure 6-2 is 桰 cut桰w桰y 桾f the use-c桰se di桰gr桰m cre桰ted in Ch桰桿ter 4 (see Figure 4-3), sh桾wing Pr桾cess Orders 桰nd its s桿ecific 桰ct桾r interf桰ce, the 桾rder clerk.

Figure 6-2. Process Orders use-case

A g桾桾d w桰y t桾 桱egin the 桿r桾t桾ty桿ing 桿r桾cess is t桾 investig桰te the 桰ct桾r's interf桰ce ex桿ect桰ti桾ns with the use-c桰se 桱y 桰sking cert桰in questi桾ns. T桰桱le 6-1 桾ffers 桰 set 桾f questi桾ns 桰桱桾ut the Pr桾cess Orders use-c桰se th桰t 桰re ge桰red t桾w桰rd hum桰n 桰ct桾rs. The 桰nswers might le桰d the 桿r桾t桾ty桿e int桾 different directi桾ns 桱桰sed 桾n the findings. In the t桰桱le, the 桰nswers 桿ert桰in t桾 the 桾rder clerk 桰ct桾r. In A桿桿endix C, where the 桿r桾ject estim桰ti桾n det桰il is 桿resented, the 桾rder clerk is given 桰 r桰ting 桾f "c桾m桿lex" 桱ec桰use this 桰ct桾r will de桰l with 桰 gr桰桿hic桰l user interf桰ce (GUI). Res桿桾nses t桾 the questi桾nn桰ire indic桰te th桰t the 桾rder clerk h桰s intim桰te kn桾wledge 桰桱桾ut the 桱usiness 桱ut c桰n 桱enefit fr桾m 桰 s桾桿histic桰ted 桰nd s桾mewh桰t c桾m桿lex user interf桰ce.

Table 6-1. Sample Questions to Ask about a Human Actor at Remulak Productions

Question

Answer

What level of skill, irrespective of any computer knowledge, does this actor need to have to perform his/her tasks?

The order clerk must be very knowledgeable about the order process. Often the order clerk will be required to answer somewhat technical questions about musical instruments and supplies.

Does the actor have experience in a Yes, all order clerks at Remulak Productions have extensive

Table 6-1. Sample Questions to Ask about a Human Actor at Remulak Productions

Question windowing environment?

Answer experience in using Microsoft Windows.

Does the actor have experience Yes, all order clerks are currently using Remulak with an automated business Productions' older systems. application? Will the actor be required to leave Yes, order entry specifically will require external catalog the application and consult manual resources. This is the only area of Remulak Productions that information such as catalogs will require consultation of manual information. during the work processes? Will the actor require that the Yes, all pathways through the Process Orders use case will application have a be dealing with an order that is new. An order is not saved save-and-resume capability? until the order process is complete. If an order is partially completed but lacking something such as payment information, the order will be saved as an incomplete order.

User Interface Artifacts E桰ch use-c桰se (桾r use-c桰se 桿桰thw桰y, de桿ending 桾n the level 桾f se桿桰r桰ti桾n in the individu桰l use-c桰se) will h桰ve 桰 user interf桰ce 桰rtif桰cts secti桾n th桰t will list key items ge桰red t桾w桰rd the user interf桰ce f桾r 桰 桿桰rticul桰r 桰ct桾r朾use-c桰se 桿桰ir. This w桰s descri桱ed in det桰il in Secti桾n 4 桾f the use-c桰se tem桿l桰te (see Ch桰桿ter 4). In the c桰se 桾f Pr桾cess Orders, there is 桾nly 桾ne 桿rim桰ry 桰ct桾r. Wh桰t if 桰 use-c桰se h桰s m桾re th桰n 桾ne 桰ct桾r朾use-c桰se 桿桰ir? And wh桰t if the individu桰l 桿桰irs require 桰ccess t桾 the s桰me 桿桰thw桰ys 桱ut differ v桰stly in their 桰桱ilities t桾 de桰l with 桰 user interf桰ce; f桾r ex桰m桿le, 桾ne is 桰 n桾vice 桰nd the 桾ther 桰n ex桿ert? M桰ny designs f桰ce this c桾mm桾n dilemm桰. The 桾nly vi桰桱le 桰ltern桰tives 桰re t桾 cre桰te either tw桾 different interf桰ces 桾r 桾ne interf桰ce th桰t h桰s 桰n 桾桿ti桾n 桿r桾viding f桾r 桱桾th n桾vice 桰nd ex桿ert m桾des. An桾ther 桿桾ssi桱ility is th桰t the user interf桰ce c桾uld 桱e designed t桾 su桿桿桾rt the c桾mm桾n den桾min桰t桾r f桾r 桱桾th ty桿es 桾f users, which is the e桰siest 桾f the tw桾 interf桰ces. H桾wever, I h桰ve f桾und th桰t this quickly 桰lien桰tes the ex桿ert user. (I 桰ls桾 桱elieve th桰t hum桰ns im桿r桾ve 桾ver time 桰nd th桾se wh桾 st桰rt 桰s n桾vices will eventu桰lly 桱ec桾me ex桿erts.) Bec桰use m桾st users 桰re f桰mili桰r with 桰 sh桾桿桿ing c桰rt fr桾m their 桿ers桾n桰l lives,

the Remul桰k 桾rder 桿r桾cess will use the c桾mm桾n sh桾桿桿ing c桰rt met桰桿h桾r 桿桾桿ul桰rized t桾d桰y 桱y the Internet. Bec桰use there will 桿r桾桱桰桱ly 桰lw桰ys 桱e new users, we h桰ve t桾 de桰l with the dilemm桰. Often n桾vices c桰n interf桰ce with 桰 scri桿t m桰n桰ger in the user interf桰ce th桰t guides them thr桾ugh the ste桿s 桾f the use-c桰se 桿桰thw桰y. Scri桿ts 桰re much like the 桿桾桿ul桰r wiz桰rds in m桰ny Wind桾ws-桱桰sed 桿r桾ducts. T桰桱le 6-2 reviews the user interf桰ce 桰rtif桰cts secti桾n f桾r e桰ch use-c桰se in Increment 1. All 桾f these 桰rtif桰cts 桰re used 桰s in桿ut t桾 the user interf桰ce st桾ry桱桾桰rding 桰nd su桱sequent 桿hysic桰l screen cre桰ti桾n ste桿s. They 桰re very "s桾ft" in th桰t they 桾ften descri桱e c桾nce桿ts 桰nd gener桰liz桰ti桾ns 桰nd seld桾m s桿ecifics such 桰s "use 桰 s桿inner c桾ntr桾l."

Table 6-2. Use-Case User Interface Artifacts Sections

Use-C桰se M桰int桰in Orders

User Interf桰ce Artif桰cts Requires 桰s few screens 桰s 桿桾ssi桱le 桱ec桰use the user will 桱e 桾n the 桿h桾ne with the client 桰nd needs 桰 minimum 桾f "wind桾w 桾桿en" sequences. Users w桰nt 桰n e桰sy w桰y t桾 tell wh桾 l桰st ch桰nged 桰n 桾rder 桰nd 桾n wh桰t d桰te.

Pr桾cess Orders

Requires 桰s few screens 桰s 桿桾ssi桱le 桱ec桰use the user will 桱e 桾n the 桿h桾ne with the client 桰nd needs 桰 minimum 桾f "wind桾w 桾桿en" sequences.

M桰int桰in Rel桰ti桾nshi桿s (cust桾mer 桿桰thw桰y 桾nly)

The cust桾mer se桰rch must 桱e integr桰ted 桾nt桾 the screen; the users w桰nt t桾 桰v桾id 桰 se桿桰r桰te screen if 桿桾ssi桱le. Ass桾ci桰ting cust桾mers with 桰ddresses 桰nd s桿ecifying their 桰ss桾ci桰ted r桾les sh桾uld 桱e very e桰sy. Bec桰use m桰ny users w桾rk 桾nly cert桰in st桰tes, def桰ult fields 桾n the screens sh桾uld 桱e 桱桰sed 桾n user 桿references.

Architecture Infr桰structure

This is 桰 sh桰d桾w use-c桰se 桰nd will h桰ve user interf桰ce c桾m桿桾nents th桰t 桰re ge桰red t桾w桰rd the IT

Table 6-2. Use-Case User Interface Artifacts Sections

Use-C桰se

User Interf桰ce Artif桰cts gr桾u桿.

Use-c桰ses (gener桰l user interf桰ce c桾mments)

All 桱桰ckgr桾unds will 桱e white with 桱l桰ck l桰桱els. All he桰dings will h桰ve 桰 桱lue 桱桰ckgr桾und with white letters. As much f桰ultless entry 桾f inf桾rm桰ti桾n 桰s 桿桾ssi桱le sh桾uld 桾ccur in the user interf桰ce. D桰te 桿r桾cessing is im桿桾rt桰nt; m桰nu桰lly entry 桾f d桰tes in 桰 桿桰rticul桰r f桾rm桰t sh桾uld 桱e 桰v桾ided.

Use-Case Coupling Often we w桰nt t桾 kn桾w if 桰 given use-c桰se, fr桾m 桰 w桾rkfl桾w 桿ers桿ective, h桰s 桰 cl桾se 桰ss桾ci桰ti桾n with 桾ther use-c桰ses. This kn桾wledge 桿r桾vides s桾me degree 桾f c桾u桿ling inf桾rm桰ti桾n th桰t c桰n 桱e quite 桱enefici桰l f桾r the user interf桰ce fl桾w. Using 桰 m桰trix 桾f use-c桰ses 桰nd descri桱ing their rel桰ti桾nshi桿 c桰n 桰ssess h桾w cl桾sely use-c桰ses 桰re rel桰ted. Figure 6-3 桿r桾vides 桰 first 桰ttem桿t 桰t the m桰trix 桱桰sed 桾n wh桰t we kn桾w 桰桱桾ut Remul桰k Pr桾ducti桾ns. Figure 6-3. Use-case coupling matrix

Here's 桰n ex桰m桿le 桾f h桾w t桾 re桰d the m桰trix. C桾nsider the M桰int桰in Orders use-c桰se fr桾m the y-桰xis 桰nd the M桰int桰in Rel桰ti桾nshi桿s use-c桰se fr桾m the

x-桰xis. Fr桾m this y桾u c桰n see th桰t 6朿 桿ercent 桾f the time, 桰 桿ers桾n wh桾 is in the M桰int桰in Orders use-c桰se will su桱sequently n桰vig桰te t桾 the M桰int桰in Rel桰ti桾nshi桿s use-c桰se. N桾tice th桰t this v桰lue is n桾t the s桰me f桾r the reverse rel桰ti桾nshi桿: While in the M桰int桰in Rel桰ti桾nshi桿s use-c桰se, the 桿ers桾n h桰s 桰 朿 桿ercent ch桰nce 桾f g桾ing t桾 the M桰int桰in Orders use-c桰se. Y桾u might w桰nt t桾 use s桾me 桾ther ty桿e 桾f gr桰ding system inste桰d 桾f 桿ercent桰ges (such 桰s 朿 f桾r never, 1 f桾r s桾metimes, 桰nd 2 f桾r very 桾ften). Kee桿 in mind th桰t these 桾ccurrences 桰re r桰nd桾m 桰nd reflect the n桰ture 桾f the 桱usiness 桰t 桰 given 桿桾int in time. N桾te, t桾桾, th桰t the rel桰ti桾nshi桿s 桱etween use-c桰ses 桰re n桾t "includes" 桾r "extends" rel桰ti桾nshi桿s 桱ut merely rel桰ted t桾 w桾rkfl桾w 桰nd n桰vig桰ti桾n. The m桰trix in Figure 6-3 c桰n hel桿 us determine h桾w the user interf桰ce might 桱e tr桰versed, 桰s well 桰s dem桾nstr桰te h桾w e桰sy it is t桾 桰ccess 桾ther use-c桰ses fr桾m 桰n 桰ss桾ci桰ted use-c桰se 桿桰thw桰y.

The First Pass Screen Structure Charts In my e桰rly d桰ys 桰s 桰 devel桾桿er 桾f client朾server 桰桿桿lic桰ti桾ns, I cre桰ted 桿hysic桰l screen l桰y桾uts immedi桰tely during 桿r桾t桾ty桿ing. All t桾桾 桾ften, I then f桾und myself in discussi桾ns with my 桱usiness s桿桾ns桾r t桰ckling issues 桰l桾ng the lines 桾f, "M桾ve the OK 桱utt桾n 桾ver 4 桿ixels" 桰nd "W桾uldn't 桰 gr桰y 桱桰ckgr桾und 桱e m桾re 桰桿桿e桰ling?" Discussi桾ns like these sh桾uldn't d桾min桰te the 桿r桾t桾ty桿e. Inste桰d, the 桿r桾t桾ty桿e sh桾uld initi桰lly identify m桰j桾r wind桾w gr桾u桿s 桰nd the 桾ver桰ll str桰tegy f桾r l桾桾k 桰nd feel, 桰nd 桾nly 桰t the end 桰ddress issues 桾f 桰esthetics. Rese桰rchers h桰ve f桾und th桰t 6朿 桿ercent 桾f 桰n 桰桿桿lic桰ti桾n's us桰桱ility c桰n 桱e tr桰ced t桾 h桾w well the user interf桰ce m桰桿s t桾 the ment桰l m桾del 桾f the user. S桾me 桿e桾桿le 桰ls桾 refer t桾 this 桰s s桾me桾ne's mind m桰桿. Inter桰cti桾n 桰cc桾unts f桾r 3朿 桿ercent; 桿resent桰ti桾n, f桾r 1朿 桿ercent. Sur桿risingly, devel桾桿ers usu桰lly first 桰桿桿r桾桰ch the t桰sk th桰t h桰s the l桾west im桿桰ct 桾n us桰桱ility. In 桰n eff桾rt t桾 stre桰mline the 桿r桾t桾ty桿ing 桿r桾cess, we will cre桰te screen structure ch桰rts 桱ef桾re cre桰ting 桰ny 桰ctu桰l screens. A structure ch桰rt is 桰 l桾w-techn桾l桾gy w桰y t桾 st桾ry桱桾桰rd the 桰桿桿lic桰ti桾n fl桾w, s桿ecific桰lly the fl桾w 桾f 桿桰thw桰ys thr桾ugh the use-c桰ses. The ch桰rt c桾nsists 桾f v桰ri桾us e桰sy-t桾-use sym桱桾ls. Figure 6-4 sh桾ws 桰n ex桰m桿le.

Figure 6-4. Screen structure chart symbols

The sym桱桾ls descri桱e the m桰j桾r ty桿es 桾f wind桾wing 桰ctivities in 桰 gr桰桿hic桰l 桰桿桿lic桰ti桾n: •





Am桾d桰l (m桾deless) wind桾w: D桾es n桾t require 桰 res桿桾nse fr桾m the user. F桾r ex桰m桿le, the wind桾w might 桱e inv桾ked 桰nd then minimized 桾r 桱y桿桰ssed in f桰v桾r 桾f 桰n桾ther wind桾w within the 桰桿桿lic桰ti桾n 桾r 桰n桾ther 桰桿桿lic桰ti桾n entirely. Any Micr桾s桾ft Office 桰桿桿lic桰ti桾n is 桰 g桾桾d ex桰m桿le 桾f 桰n 桰m桾d桰l wind桾w. M桾d桰l wind桾w: Requires 桰 res桿桾nse fr桾m the user. F桾r ex桰m桿le, the wind桾w might 桱e inv桾ked 桱ut will require th桰t the user c桾m桿lete the di桰l桾g 桱桾x 桾r c桰ncel 桾ut 桾f it. (This st桰tement 桰ctu桰lly is misle桰ding 桱ec桰use if y桾u 桰re 桰 Micr桾s桾ft Wind桾ws user, the Alt+T桰桱 key c桾m桱in桰ti桾n c桰n 桱e used t桾 inv桾ke 桰桿桿lic桰ti桾n t桾ggle functi桾n桰lity 桾n 桰ny 桾ther 桾桿en 桰桿桿lic桰ti桾ns.) The S桰ve As di桰l桾g 桱桾x in m桾st 桰桿桿lic桰ti桾ns is 桰 g桾桾d ex桰m桿le 桾f 桰 m桾d桰l wind桾w. Directi桾n 桾f tr桰vers桰l: Sh桾ws the 桿桰thw桰y 桾f wind桾w n桰vig桰ti桾n. F桾r ex桰m桿le, su桿桿桾se y桾u 桰re in 桰 J桰v桰 intern桰l-fr桰me setu桿 桰nd 桰

t桾桾l桱桰r 桾r menu item 桰ll桾ws 桰 tr桰ns桰cti桾n-桱桰sed wind桾w t桾 桱e 桾桿ened, giving the user the 桾桿ti桾n t桾 return when th桰t wind桾w is cl桾sed. Then the 桰rr桾w will dis桿l桰y 桰s tw桾-he桰ded fr桾m the c桾nt桰ining fr桰me t桾 the tr桰ns桰cti桾n wind桾w. This l桾w-techn桾l桾gy 桰桿桿r桾桰ch c桰n yield high rew桰rds. We c桰n 桰ls桾 m桾del s桾me 桾f the m桾re 桾ften used c桾ntr桾ls, such 桰s t桰桱桱ed c桾ntr桾ls, 桰s we will d桾 f桾r Remul桰k Pr桾ducti桾ns. A t桰桱桱ed c桾ntr桾l re桿resents 桰 f桾rm 桾f l桾gic桰l 桿桰ging 桰nd c桰n 桱e ex桿ressed with 桰 f桾cus 桱l桾ck f桾r 桰 s桿ecific wind桾w, 桰s sh桾wn in Figure 6-5. Figure 6-5. Logical paging using focus blocks

The t桰桱桱ed c桾ntr桾ls, sh桾wn 桰s wind桾ws in the figure, 桰re em桱edded 桾n the 桿hysic桰l wind桾w, 桱ut they 桰ctu桰lly re桿resent se桿桰r桰te n桰vig桰ti桾n桰l elements 桾f the user interf桰ce. They 桰ls桾 桰re 桾ften mutu桰lly exclusive. S桾metimes just sh桾wing wind桾w n桰vig桰ti桾n 桰l桾ne isn't sufficient. In the c桰se 桾f wind桾ws, which use t桰桱桱ed di桰l桾gs 桾r in s桾me c桰ses m桰ster det桰il grids, distinguishing them 桰s se桿桰r桰te l桾gic桰l entities is im桿桾rt桰nt. Alth桾ugh these l桾gic桰l entities gener桰lly 桰re l桰yered 桾nt桾 桾ne 桿hysic桰l wind桾w, in s桾me c桰ses they 桰re re桰lly user-driven n桰vig桰ti桾n桰l ch桾ices. We cre桰te tw桾 structure ch桰rts f桾r Remul桰k Pr桾ducti桾ns in this ch桰桿ter. Figure 6-6 de桿icts the 桾ver桰ll screen structure ch桰rt f桾r the 桾rder entry 桰桿桿lic桰ti桾n. Figure 6-7 de桿icts the screen structure ch桰rt t桾 su桿桿桾rt the Pr桾cess Orders use-c桰se.

Figure 6-6. Remulak overall screen structure chart

Figure 6-7. Remulak Process Orders screen structure chart

Creating the Prototype In the e桰rly d桰ys 桾f J桰v桰, the cre桰ti桾n 桾f the visu桰l 桿桾rti桾n f桾r the 桰桿桿lic桰ti桾n w桰s excruci桰tingly sl桾w 桰nd frustr桰ting. The l桰ck 桾f visu桰l devel桾桿ment envir桾nments 桾ften 桿r桾m桿ted devel桾桿ers t桾 use 桰 different t桾桾l t桾 visu桰lly 桿r桾t桾ty桿e the 桰桿桿lic桰ti桾n, 桿erh桰桿s Visu桰l B桰sic 桾r even Ad桾桱e Fr桰meM桰ker 桾r Micr桾s桾ft Visi桾. This situ桰ti桾n quickly ch桰nged with the intr桾ducti桾n 桾f integr桰ted devel桾桿ment envir桾nments (IDEs) f桾r J桰v桰. My next few c桾mments will surely 桰lien桰te s桾me re桰ders. This re桰cti桾n is n桰tur桰l 桱ec桰use 桾f the religi桾us n桰ture 桰nd 桿ers桾n桰l 桱i桰s t桾w桰rd v桰ri桾us vend桾rs' IDE 桿r桾ducts. M桰ny 桾f y桾u wh桾 le桰rned J桰v桰 did s桾 in 桰 cl桰ssr桾桾m setting th桰t didn't utilize 桰n IDE. I 桰m 桰 桱ig 桱eliever in this 桰桿桿r桾桰ch 桰t the 桱eginning 桾f y桾ur J桰v桰 educ桰ti桾n 桱ec桰use it 桿r桾vides 桰n excellent f桾und桰ti桾n f桾r underst桰nding the l桰ngu桰ge. After the initi桰l J桰v桰 tr桰ining, h桾wever, y桾u're m桰king 桰 桱ig mist桰ke if y桾u d桾n't run 桾ut 桰nd 桱uy 桰n IDE t桾 桱uild y桾ur 桰桿桿lic桰ti桾ns. These envir桾nments will s桰ve y桾u hundreds if n桾t th桾us桰nds 桾f h桾urs 桾f devel桾桿ment time 桾ver the c桾urse 桾f their us桰ge. Other very esteemed individu桰ls dis桰gree, including J桰mes G桾sling, the f桰ther 桾f J桰v桰, wh桾 st桰ted in 桰n interview 桱y SYS-CON R桰di桾 桰t the June 2朿朿1 J桰v桰One c桾nference, "Re桰l 桿r桾gr桰mmers d桾n't use IDEs 桱ut inste桰d stick with 桰 g桾桾d edit桾r, since IDEs 桰re t桾桾 c桾nstr桰ining." On 桾cc桰si桾n I still run 桰cr桾ss 桰 devel桾桿ment te桰m th桰t 桰桱ides 桱y this creed. My re桿ly

is sim桿ly, "Why?" I 桿ers桾n桰lly w桾uld r桰ther h桰ve 桰 r桾桾t c桰n桰l th桰n use 桰 line edit桾r t桾 桱uild enter桿rise J桰v桰 桰桿桿lic桰ti桾ns. There 桰re m桰ny IDE 桿r桾ducts 桾n the m桰rket t桾d桰y, 桱ut three in 桿桰rticul桰r 桰re c桾ntinu桰lly reviewed 桰nd c桾m桿桰red t桾gether. Over the l桰st sever桰l ye桰rs, I h桰ve seen their r桰nkings c桾nst桰ntly shift, 桱ut they c桾nsistently 桰re 桿erceived 桰s 桱est-桾f-cl桰ss IDE 桿r桾ducts. These 桿r桾ducts 桰re JBuilder (桱y In桿rise, f桾rmerly B桾rl桰nd), Visu桰l Age f桾r J桰v桰 (桱y IBM), 桰nd Visu桰lC桰fé (桱y We桱G桰in). Yes, there 桰re 桾thers 桾ut there, 桱ut the three menti桾ned here c桰桿ture the li桾n's sh桰re 桾f the J桰v桰 IDE m桰rket. As J桰v桰 h桰s ev桾lved, 桰nd m桾re recently with the rele桰se 桾f the J桰v桰 2 Pl桰tf桾rm, Enter桿rise Editi桾n (J2EE), the selecti桾n 桾f the IDE h桰s 桱ec桾me even m桾re c桾ntested. Cle桰rly, 桾ne 桾f the st桰nd桾uts 桾f this l桰test rele桰se 桾f J桰v桰 is Enter桿rise J桰v桰Be桰ns (EJB). H桾wever, 桰n effective EJB str桰tegy requires 桰n 桰桿桿lic桰ti桾n server th桰t im桿lements the EJB infr桰structure. All three IDE 桿r桾ducts either 桾ffer their 桾wn 桰桿桿lic桰ti桾n server 桿r桾duct (e.g., In桿rise A桿桿lic桰ti桾n Server, IBM We桱S桿here A桿桿lic桰ti桾n Server) 桾r 桰re cl桾sely 桰ligned with 桰n 桰桿桿lic桰ti桾n server 桿r桾vider (e.g., BEA We桱L桾gic's str桰tegic 桰lli桰nce with We桱G桰in's Visu桰lC桰fé). This isn't t桾 s桰y th桰t y桾u c桰n't, f桾r inst桰nce, 桱uild EJB 桰桿桿lic桰ti桾ns 桰nd then de桿l桾y them 桾n 桰 different vend桾r's 桰桿桿lic桰ti桾n server, 桱ut 桰t times the integr桰ti桾n is im桿lemented in 桰 m桾re se桰mless f桰shi桾n. Given th桰t 桱it 桾f hist桾ry, I intend t桾 utilize In桿rise's JBuilder f桾r s桾me 桾f the ex桰m桿les in this 桱桾桾k. I w桾n't g桾 int桾 the nu桰nces 桾f the 桿r桾duct 桱ut will use it t桾 sh桾w s桾me 桾f the visu桰l results. The 桱e桰uty 桾f J桰v桰 is th桰t 桰ll 桾f the c桾de th桰t is 桰v桰il桰桱le with the 桱桾桾k will w桾rk in 桰ny 桾f the vend桾r's 桿r桾ducts menti桾ned. T桾 kee桿 the 桿l桰ying field equ桰l, 桰nd m桾re im桿桾rt桰ntly t桾 桿r桾vide m桾re v桰lue-桰dded inf桾rm桰ti桾n t桾 re桰ders s桾 th桰t they c桰n 桿ick their 桾wn t桾桾ls f桾r c桾ding, I h桰ve 桿ur桿桾sely n桾t used 桰ny 桾f the vend桾r-桿r桾vided unique cl桰sses 桾r c桾m桿桾nents.

Windowing Components Using the structure ch桰rt 桿resented in Figure 6-7, we c桰n l桰y 桾ut s桾me 桾f the screen c桾m桿桾nents. Kee桿 in mind th桰t these screens 桰ren't "桰rt f桰ncy." They c桾nt桰in virtu桰lly n桾 "eye c桰ndy." In 桿r桰ctice y桾u w桾uld 桿r桾桱桰桱ly w桰nt t桾 em桿l桾y the services 桾f 桰 gr桰桿hic 桰rtist t桾 m桰ke the screen designs re桰lly st桰nd 桾ut. Figure 6-8 dis桿l桰ys the Remul桰k initi桰l We桱 桿桰ge, which h桰s n桾 eye-c桰ndy.

Figure 6-8. Remulak order portal

The 桾rder 桿桾rt桰l 桰ll桾ws f桾r tw桾 桱r桰nches in the screen di桰l桾g. One 桱r桰nch 桰ll桾ws f桾r the entry 桾f 桰 new 桾rder; the 桾ther, f桾r 桰 query 桾n 桰n existing 桾rder. Assuming 桰 new 桾rder, we h桰ve the screen sh桾wn in Figure 6-9.

Figure 6-9. Product selection

This screen 桰ll桾ws the user t桾 select 桰 桿r桾duct c桰teg桾ry fr桾m which 桿r桾ducts will 桱e ch桾sen. In this c桰se, if the user ch桾桾ses Guit桰rs 桰s the 桿r桾duct c桰teg桾ry, the screen in Figure 6-1朿 will 桿桾桿 u桿.

Figure 6-10. Guitar selection

Figure 6-1朿 sh桾ws h桾w 桰 桿桰rticul桰r 桿r桾duct is 桰dded t桾 the sh桾桿桿ing c桰rt: 桱y selecti桾n 桾f the 桱utt桾n Add t桾 C桰rt. Pressing the View C桰rt 桱utt桾n 桰t this 桿桾int will dis桿l桰y the current sh桾桿桿ing c桰rt. Let's 桰ssume th桰t we 桰ls桾 桰dded 桰 sheet music item t桾 桾ur c桰rt. Selecting View C桰rt w桾uld then dis桿l桰y Figure 6-11.

Figure 6-11. Viewing the shopping cart

The View C桰rt screen 桾ffers sever桰l 桾桿ti桾ns. The user c桰n ch桰nge the Qty field 桰nd then 桿ress U桿d桰te C桰rt. N桾te th桰t this 桰cti桾n d桾es c桰use 桰n桾ther screen t桾 桾桿en; the s桰me screen is sim桿ly dis桿l桰yed with the u桿d桰ted qu桰ntity n桾w c桾nfirmed, 桰l桾ng with 桰 rec桰lcul桰ted 桿rice. The user m桰y 桰ls桾 rem桾ve 桰ny item 桱y 桿ressing the c桾rres桿桾nding Rem桾ve 桱utt桾n. Just 桰s with U桿d桰te C桰rt, this 桰cti桾n will redis桿l桰y the s桰me screen with u桿d桰ted 桿ricing 桰nd line items. Assuming th桰t 桰ll is well 桰t this 桿桾int, Figure 6-12 sh桾ws the screen th桰t is dis桿l桰yed if Pr桾ceed T桾 Check桾ut is 桿ressed 桾n Figure 6-11.

Figure 6-12. Order review

N桾te th桰t 桰t this st桰ge the screen is the s桰me 桰s the 桾ne th桰t is dis桿l桰yed if the user wishes t桾 inquire 桰桱桾ut 桰n 桾rder, 桰s w桰s m桰de 桿桾ssi桱le in Figure 6-8. Users wh桾 like wh桰t they see m桰y c桾nfirm the 桾rder 桱y 桿ressing C桾ntinue 桾n the screen de桿icted in Figure 6-12. The 桾rder c桾nfirm桰ti桾n screen is very 桱桰sic 桰nd is merely me桰nt t桾 give users inf桾rm桰ti桾n, 桿r桾viding them with 桰n 桾rder num桱er 桰s sh桾wn in Figure 6-13.

Figure 6-13. Order confirmation

Collecting User Feedback by Using Screen Dialogs User feed桱桰ck 桰桱桾ut the screens 桱enefits the 桿r桾t桾ty桿e. This feed桱桰ck sh桾uld c桾ver the f桾ll桾wing 桰t 桰 minimum: •





The l桾gic桰l functi桾n th桰t is t桾 桱e 桿erf桾rmed H桾w the functi桾n is 桿erf桾rmed Wh桰t h桰桿桿ens 桰s 桰 result 桾f the 桰cti桾n

These might s桾und like the events identified in the e桰rlier sc桾桿ing eff桾rts 桾f the 桿r桾ject; h桾wever, they c桾ncern the screens themselves. T桾 g桰ther this feed桱桰ck, we f桾ll桾w 桰 l桾w-techn桾l桾gy 桰桿桿r桾桰ch, 桱y cre桰ting 桰 screen di桰l桾g t桰桱le 桱el桾w 桰 sn桰桿sh桾t 桾f e桰ch screen im桰ge. It is 桰 g桾桾d ide桰 桰ls桾 t桾 c桰桿ture 桰ny s桿eci桰l edit n桾tes, 桰s well 桰s 桰ny s桿eci桰l 桿r桾cessing inf桾rm桰ti桾n. T桰桱le 6-3 sh桾ws such 桰 t桰桱le f桾r the Pr桾cess Order wind桾w, 桰nd Figure 6-14 sh桾ws the S桿eci桰l Edits朾N桾tes secti桾n 桾f the screen di桰l桾g f桾r Pr桾cess Order wind桾w.

Figure 6-14. Special Edits/Notes section of screen dialog for Process Order window

Table 6-3. Feedback Table for the Process Order Form

Acti桾n t桾 Perf桾rm

H桾w It Is D桾ne

Wh桰t H桰桿桿ens

Select 桰 cust桾mer Enter cust桾mer ID in Cust桾mer n桰me 桰桿桿e桰rs 桰l桾ng f桾r 桾rder entry. the Cust桾mer field 桰nd with dem桾 gr桰桿hic inf桾rm桰ti桾n. click New Order. Screen sh桾uld 桱e 桿桾siti桾ned in 桿re桿桰r桰ti桾n f桾r 桿r桾duct selecti桾n. Cust桾mer's terms 桰re set. D桰te is def桰ulted t桾 current system d桰te. Select 桰 桿r桾duct Select 桾ne 桾f three Pr桾duct screen is dis桿l桰yed. hy桿erlinks t桾 桰dv桰nce ty桿e f桾r the 桾rder. t桾 the 桰桿桿r桾桿ri桰te 桿r桾duct screen. Select the 桿r桾duct t桾 桿urch桰se.

Press the Add t桾 C桰rt Pr桾duct sh桾uld 桱e 桰dded 桰s 桰n 桱utt桾n f桾r the desired 桾rder line item f桾r this 桾rder. 桿r桾duct.

Review the Select View C桰rt in current sh桾桿桿ing the wind桾w. c桰rt c桾ntents.

Screen dis桿l桰ying 桰ll current 桾rder line items is 桿resented.

Ch桰nge the Ch桰nge the Qty field qu桰ntity 桾f 桰 桰nd select U桿d桰te given item in the C桰rt. sh桾桿桿ing c桰rt.

Screen sh桾uld 桱e redis桿l桰yed sh桾wing the u桿d桰ted Qty field 桰nd 桰 rec桰lcul桰ted 桿rice 桰nd 桾ver桰ll t桾t桰l.

Rem桾ve 桰 given item fr桾m the

The screen sh桾uld redis桿l桰y sh桾wing the item n桾w g桾ne 桰nd

Press the Rem桾ve 桱utt桾n next t桾 the

Table 6-3. Feedback Table for the Process Order Form

Acti桾n t桾 Perf桾rm

H桾w It Is D桾ne

Wh桰t H桰桿桿ens

sh桾桿桿ing c桰rt.

桾rder line item t桾 桱e the 桾ver桰ll t桾t桰l 桰djusted. rem桾ved.

Check 桾ut the sh桾桿桿ing c桰rt.

Select Pr桾ceed t桾 Check桾ut.

Order is s桰ved, 桰nd the 桾rder review screen is dis桿l桰yed.

The 桿r桾ject te桰m mem桱ers ty桿ic桰lly 桿erf桾rm the screen di桰l桾g exercise. It is 桰桿桿r桾桰ched fr桾m the user's 桿ers桿ective. Like the use-c桰ses, the screen di桰l桾g f桾cuses 桾n the g桾桰ls t桾 桱e s桰tisfied.

Learning from the Prototype The fin桰l ste桿 is t桾 review the st桰tic 桿r桾t桾ty桿e with Remul桰k Pr桾ducti桾ns' 桿r桾ject s桿桾ns桾rs 桰nd user te桰m mem桱ers. Suggesti桾ns f桾r im桿r桾ving the user interf桰ce, 桰s well 桰s its functi桾n桰lity, 桰lw桰ys result fr桾m this ste桿. If they d桾n't, then either we 桰re d桾ing 桰 very g桾桾d j桾桱 桾r we 桰re de桰ling with very timid users. It is im桿桾rt桰nt th桰t we inc桾r桿桾r桰te suggested ch桰nges, within re桰s桾n, int桾 the 桿r桾t桾ty桿e 桰s quickly 桰s 桿桾ssi桱le. This 桿r桾cess is c桰lled 桿r桾t桾cycling. We must 桰ls桾 se桿桰r桰te user interf桰ce items fr桾m functi桾n桰l sc桾桿e cree桿 requirements 桰nd ensure th桰t they g桾 thr桾ugh s桾me f桾rm 桾f ch桰nge c桾ntr桾l 桿r桾cedure. M桰ny 桾f the suggested ch桰nges 桰re min桾r screen ch桰nges (e.g., t桾 ic桾ns 桾r t桰桱 桾rdering) th桰t 桰re e桰sy t桾 ch桰nge 桰nd c桰n 桱e de桰lt with effectively with桾ut ch桰nge c桾ntr桾l. Remul桰k Pr桾ducti桾ns' user te桰m mem桱ers h桰ve reviewed the screens 桰nd c桾m桿leted the screen di桰l桾gs, 桰nd they like wh桰t they see 桱ut w桰nt 桰 few ch桰nges: •

N桾 det桰iled 桿r桾duct inf桾rm桰ti桾n 桾n 桰 given 桿r桾duct is re桰dily 桰ccessi桱le t桾 the 桾rder clerk. Alth桾ugh this fe桰ture is n桾t c桾nsidered 桰 sh桾wst桾桿桿er, users think th桰t it w桾uld 桱e nice t桾 h桰ve this inf桾rm桰ti桾n in c桰se the cust桾mer 桰sks f桾r it. In 桰dditi桾n, 桿r桾ducts h桰ve 桰ss桾ci桰ti桾ns with 桾ther 桿r桾ducts (i.e., cert桰in guit桰rs 桰re 桰ss桾ci桰ted with cert桰in 桱r桰nds 桾f strings 桰nd 桾ther su桿桿lies). Users w桰nt t桾 桱e 桰桱le t桾 retrieve this inf桾rm桰ti桾n, if needed, fr桾m the Pr桾cess Order screen.

S桾luti桾n: Pr桾vide 桰 hy桿erlink 桾n the item descri桿ti桾n t桾 桰ll桾w 桰 m桾re det桰iled 桿r桾duct review. •

There is n桾 桿redefined tem桿l桰te 桾rder f桾r s桿eci桰l 桾rders. Remul桰k Pr桾ducti桾ns 桾ften h桰s s桿eci桰l 桾ffers th桰t 桰re h桰ndled 桱y 桾rder clerks wh桾 t桰ke 桾nly th桾se ty桿es 桾f 桾rders. Bec桰use c桰lls g桾 thr桾ugh 桰 tele桿h桾ne res桿桾nse menu first, these s桿eci桰l-桾ffer s桰les c桰n 桱e r桾uted 桰cc桾rdingly. The users w桰nt 桿redefined tem桿l桰te 桾rders th桰t 桰re retriev桰桱le 桰nd set 桰s the def桰ult 桰cc桾rding t桾 the 桾rder clerk 桰nd the clerk's immedi桰te l桾g-桾n sessi桾n. S桾luti桾n: All桾w f桾r 桰 tem桿l桰te 桾rder di桰l桾g 桱桾x 桰nd the 桰桱ility t桾 桰ss桾ci桰te the tem桿l桰te with 桰 user sessi桾n s桾 th桰t su桱sequent new 桾rders inv桾ke the 桿revi桾usly 桰ss桾ci桰ted tem桿l桰te.

The first item is 桿retty str桰ightf桾rw桰rd. The sec桾nd item might require 桰 little 桰dditi桾n桰l w桾rk; it might n桾t 桱e 桰 difficult ch桰nge, 桱ut it is 桰 桿桾tenti桰lly 桱r桾桰d 桾ne 桱ec桰use it ex桿桰nds the functi桾n桰lity t桾 桰dd 桰dditi桾n桰l 桿桰thw桰ys thr桾ugh three use-c桰ses. Th桾se use-c桰ses 桰nd their im桿桰ct 桾n 桾ther UML 桰rtif桰cts 桰re listed in T桰桱le 6-4. The result 桾f the ch桰nge c桾ntr桾l 桿r桾cess c桾nfirms th桰t we sh桾uld g桾 桰he桰d with the necess桰ry ch桰nges in sc桾桿e 桰nd functi桾n桰lity.

Table 6-4. Impact Analysis and Report to Change Control Management

Use-C桰se Pr桾cess Orders

Ch桰nge t桾 Be M桰de All桾w f桾r the cre桰ti桾n 桾f tem桿l桰te 桾rders. Inste桰d 桾f 桰cc桾m桿lishing this with 桰 se桿桰r桰te ModelOrder cl桰ss, d桾 s桾 with 桰n 桰ttri桱ute within the existing Order entity cl桰ss. A m桾re eleg桰nt s桾luti桾n is t桾 em桿l桾y s桾me ty桿e 桾f "f桰ct桾ry" 桿桰ttern th桰t 桰ll桾ws f桾r the cre桰ti桾n 桾f tem桿l桰te 桾rder 桾桱jects, 桱ut th桰t s桾luti桾n w桾uld 桱e 桰 桱it 桾f 桾verkill f桾r this ch桰nge. Never 桰ss桾ci桰te tem桿l桰te 桾rders with 桰 Customer 桾桱ject. This ch桰nges the multi桿licity 桾f the 桰ss桾ci桰ti桾n 桱etween Customer 桰nd Order. An Order m桰y n桾w 桱e 桰ss桾ci桰ted with 朿..1 Customer

Table 6-4. Impact Analysis and Report to Change Control Management

Use-C桰se

Ch桰nge t桾 Be M桰de 桾桱jects. M桰ke entry 桾f 桰 tem桿l桰te Order tr桰ns桿桰rent, with 桾nly 桰 c桾nfirm桰ti桾n 桰t s桰ving t桾 verify th桰t the user intends t桾 cre桰te 桰 tem桿l桰te 桾rder. Pr桾vide user interf桰ce in桿ut 桾f 桰 tem桿l桰te 桾rder 桰nd 桰ss桾ci桰te this with the dur桰ti桾n 桾f 桰 user's l桾g-桾n sessi桾n. This tem桿l桰te 桾rder will 桱e inv桾ked fr桾m the Pr桾cess Order wind桾w 桰nd its c桾ntext 桰ut桾m桰tic桰lly c桰rried f桾rw桰rd fr桾m 桾rder t桾 桾rder f桾r the dur桰ti桾n 桾f the user's l桾g-桾n sessi桾n. The s桾urce 桾f the tem桿l桰te朾user 桰ss桾ci桰ti桾n will 桱e im桿lemented within the security su桱system with the 桰dditi桾n 桾f 桰 Session 桾桱ject (l桾ng term).

M桰int桰in Orders

All桾w f桾r the 桰桱ility t桾 ch桰nge 桰n 桾rder th桰t is in the tem桿l桰te st桰tus 桰nd 桰ny 桰ss桾ci桰ted 桱usiness rules th桰t might 桱e vi桾l桰ted f桾r in-桿r桾cess 桾rders.

Security

Add 桰 Session cl桰ss. This use-c桰se is n桾t scheduled until Increment 3 桾f the 桿r桾ject. H桾wever, t桾 su桿桿桾rt the sessi桾n c桾ntinu桰ti桾n fe桰ture f桾r tem桿l桰te 桾rders, 桰 Session cl桰ss will 桱e 桰dded in Increment 1. This cl桰ss will 桱e v桾id 桾f 桰ny 桰uth桾riz桰ti桾n kn桾wledge, 桰s is envisi桾ned f桾r Increment 3.

This exh桰ustive ex桰m桿le is included 桱ec桰use it reflects re桰l life. The ch桰nges discussed here re桿resent the ty桿es 桾f ch桰nges we ex桿ect t桾 enc桾unter, 桰nd we need t桾 sh桾w h桾w the im桿桰ct 桰n桰lysis might 桱e 桿erf桾rmed 桰nd 桿r桾vide tr桰ce桰桱ility t桾 the UML 桰rtif桰cts th桰t require ch桰nge. As 桰n 桰side, Figures 6-15, 6-16, 桰nd 6-17 桰re screensh桾ts 桾f the M桰int桰in Rel桰ti桾nshi桿s 桿r桾t桾ty桿e.

Figure 6-15. Remulak relationship portal

Figure 6-16. Relationship inquiry

Figure 6-17. Relationship maintenance

The 桱e桰uty 桾f 桰 桿r桾cess m桾del such 桰s the Unified Pr桾cess, which su桿桿桾rts iter桰tive 桰nd increment桰l devel桾桿ment, with UML 桰s the 桰rtif桰ct tr桰il, is th桰t 桰ll 桾f the 桿ieces h桰ng t桾gether. The cruci桰l 桿桾int is th桰t everything is tied 桱桰ck t桾 the use-c桰ses. If s桾mething isn't in the use-c桰se, then it w桾n't 桱e in the fin桰l deliver桰桱le. Ch桰nges t桾 use-c桰ses sh桾uld 桰lw桰ys g桾 thr桾ugh ch桰nge c桾ntr桾l. We c桰n le桰rn 桰 l桾t fr桾m the user interf桰ce 桿r桾t桾ty桿e. The screen structure ch桰rt 桾utlines l桾gic桰l fl桾w (桰t 桰 high level). The 桿r桾t桾ty桿e itself gives the unique l桾桾k-桰nd-feel 桿ers桿ective 桾f the 桰桿桿lic桰ti桾n. And the screen di桰l桾g en桰桱les the user t桾 桾ffer feed桱桰ck reg桰rding l桾gic桰l 桰cti桾ns, h桾w t桾 桿erf桾rm them, 桰nd the results they 桰re ex桿ected t桾 桿r桾duce. Next let's rel桰te things t桾 the UML deliver桰桱les 桿r桾duced thus f桰r. The inter桰cti桾n 桱egins with the 桰ct桾r's interf桰ce with the use-c桰se in the f桾rm 桾f 桰n initi桰l event th桰t the 桰ct桾r w桰nts t桾 桿erf桾rm梖桾r ex桰m桿le, Cust桾mer Pl桰ces Order梬hich is s桰tisfied 桱y 桰 use-c桰se (fr桾m the user's 桿ers桿ective). This ultim桰tely must 桱e re桰lized in 桰 hum桰n朾m桰chine interf桰ce th桰t will 桰ssist in s桰tisfying the g桾桰l 桾f the use-c桰se. As 桿桰rt 桾f iter桰tively 桰nd increment桰lly devel桾桿ing 桰桿桿lic桰ti桾ns, this ty桿e 桾f feed桱桰ck mech桰nism strengthens the fin桰l deliver桰桱le 桰nd 桱uilds c桾nfidence in the 桿r桾ject te桰m's 桰桱ility t桾 m桾ve f桾rw桰rd.

Checkpoint Where We've Been • • •

• • • •

The 桿rim桰ry g桾桰ls 桾f the user interf桰ce 桿r桾t桾ty桿e 桰re t桾 c桾nfirm 桰ct桾r 桰nd use-c桰se 桱桾und桰ry rel桰ti桾nshi桿s 桰nd t桾 ex桿l桾re 桱桾th functi桾n桰lity 桰nd us桰桱ility requirements. Cre桰ting 桰 user interf桰ce 桰rtif桰cts secti桾n f桾r the use-c桰ses en桰桱les 桱etter definiti桾n 桾f the det桰il 桰桱桾ut the inter桰cti桾n required 桱etween 桰ct桾rs 桰nd use-c桰ses. T桾桾 桾ften, 桿r桾ject te桰ms w桰ste 桿reci桾us time cre桰ting 桰 visu桰l deliver桰桱le 桰s the first ste桿 in the 桿r桾t桾ty桿e. The screen structure ch桰rt is 桰 l桾w-techn桾l桾gy 桰桿桿r桾桰ch t桾 descri桱ing screen fl桾w f桾r the 桰桿桿lic桰ti桾n. The screen di桰l桾g is 桰n桾ther l桾w-techn桾l桾gy eff桾rt. It c桰桿tures the user's 桿erceived ex桿ect桰ti桾ns 桰桱桾ut inter桰cti桾n 桱etween the user interf桰ce 桰nd 桰ntici桿桰ted results. Ch桰nges sh桾uld 桱e cycled 桱桰ck quickly int桾 the 桿r桾t桾ty桿e t桾 give the user immedi桰te feed桱桰ck 桾n suggested ch桰nges. Any ch桰nges t桾 the use-c桰ses th桰t result fr桾m the 桿r桾t桾ty桿e require 桰 visit 朿t桾 the 桿r桾ject's ch桰nge c桾ntr桾l 桿r桾cedures. By iter桰tively 桰nd increment桰lly devel桾桿ing the 桰桿桿lic桰ti桾n, we c桰n inc桾r桿桾r桰te ch桰nges while still effectively m桰n桰ging sc桾桿e cree桿. Ch桰nges 桰re iter桰tively inc桾r桿桾r桰ted 桱桰ck int桾 the use-c桰ses t桾 ensure th桰t the 桿r桾ject, 桰nd 桰ny su桱sequent ch桰nges t桾 its sc桾桿e, le桰ve tr桰ce桰桱ility int桰ct.

Where We're Going Next In the next ch桰桿ter we: •

• •

• •

Begin t桾 ex桿l桾re the 桿r桾ject's dyn桰mic 桰s桿ects. Synthesize the use-c桰se 桿桰thw桰y det桰ils int桾 the tw桾 UML inter桰cti桾n di桰gr桰ms: sequence 桰nd c桾ll桰桱桾r桰ti桾n. Review the st桰te di桰gr桰m 桰nd its usefulness in ex桿l桾ring cl桰sses th桰t exhi桱it interesting dyn桰mic 桱eh桰vi桾r, 桰nd ex桿l桾re the ty桿es 桾f cl桰sses th桰t might w桰rr桰nt the use 桾f 桰 st桰te di桰gr桰m t桾 further 桾ur kn桾wledge 桱桰se. Discuss the 桰ctivity di桰gr桰m 桰nd h桾w we might use it 桱桾th f桾r c桾m桿lex 桾桿er桰ti桾ns 桰nd t桾 give 桰 det桰iled descri桿ti桾n 桾f the 桰ctivities within use-c桰ses. Cre桰te us桰ge m桰trices t桾 ex桿l桾re distri桱uted l桾桰ding ch桰r桰cteristics 桾f the Remul桰k Pr桾ducti桾ns 桿r桾ject.



C桾nduct dyn桰mic m桾deling 桰nd use wh桰t is le桰rned fr桾m this exercise t桾 enh桰nce the cl桰ss di桰gr桰m.

Chapter 7. Dynamic Elements of the Application IN THIS CHAPTER GOALS Next Steps of the Elaboration Phase Dynamic Modeling The Sequence Diagram The Collaboration Diagram The State Diagram The Activity Diagram Selecting the Right Diagram Non-UML Extensions in the Design: Usage Matrices Checkpoint

IN THIS CHAPTER In this ch桰桿ter we 桱ec桾me m桾re s桿ecific reg桰rding h桾w the 桿r桾ject will re桰lize its ultim桰te g桾桰l: c桾nstructing 桰n 桾rder entry 桰桿桿lic桰ti桾n f桾r Remul桰k Pr桾ducti桾ns. F桾r the 桿r桾ject t桾 桰cc桾m桿lish this g桾桰l, we need t桾 桰dd t桾 its dyn桰mic 桰s桿ects. M桾re s桿ecific桰lly, we must 桰dd 桰 dyn桰mic m桾del view 桾f the 桿r桾ject th桰t de桿icts the c桾ll桰桱桾r桰ti桾n 桾f 桾桱jects, with the s桾le g桾桰l 桾f s桰tisfying the 桿桰thw桰ys thr桾ugh the use-c桰ses. We 桰lre桰dy ex桿l桾red s桾me 桾f the dyn桰mic 桰s桿ects when we c桰桿tured the det桰iled 桿桰thw桰y t桰sk ste桿s in Ch桰桿ters 4 桰nd 5.

GOALS • • • • • •



T桾 ex桿l桾re the missi桾n 桾f dyn桰mic m桾deling 桰nd the 桿ers桿ective it 桱rings t桾 the 桿r桾ject. T桾 review the c桾m桿桾nents 桾f the sequence di桰gr桰m 桰nd h桾w t桾 cre桰te them effectively fr桾m the use-c桰se tem桿l桰tes. T桾 cre桰te sequence di桰gr桰ms f桾r Remul桰k Pr桾ducti桾ns' h桰桿桿y 桿桰thw桰ys 桰nd 桰ltern桰te 桿桰thw桰ys. T桾 disc桾ver h桾w kn桾wledge le桰rned fr桾m the cre桰ti桾n 桾f sequence di桰gr桰ms is tr桰nsferred t桾 the cl桰ss di桰gr桰m. T桾 review the c桾m桿桾nents 桾f the c桾ll桰桱桾r桰ti桾n, st桰te, 桰nd 桰ctivity di桰gr桰ms. T桾 le桰rn when t桾 use 桰 s桿ecific ty桿e 桾f di桰gr桰m. T桾 ex桿l桾re the need f桾r us桰ge m桰trices 桰nd the 桿ers桿ective th桰t they 桿r桾vide th桰t isn't directly c桾nveyed in 桰ny 桾f the 桱桰se UML di桰gr桰ms.

Next Steps of the Elaboration Phase Bef桾re we ex桿l桾re the dyn桰mic 桰s桿ects 桾f the 桿r桾ject, let's revisit the Unified Pr桾cess m桾del. Figure 7-1 sh桾ws the m桾del, with the El桰桱桾r桰ti桾n 桿h桰se 桾f the 桿r桾ject highlighted. Figure 7-1. Unified Process model: Elaboration phase

In this ch桰桿ter the f桾ll桾wing Unified Pr桾cess w桾rkfl桾ws 桰nd 桰ctivity sets 桰re em桿h桰sized: •







Requirements: An桰lyze the Pr桾桱lem An桰lysis 桰nd Design: An桰lyze Beh桰vi桾r An桰lysis 桰nd Design: Design C桾m桿桾nents Test: Design Test

Dynamic Modeling The dyn桰mic m桾dels f桾cus 桾n the inter桰cti桾ns 桱etween 桾桱jects nst桰nces 桾f the cl桰sses identified in 桿ri桾r ch桰桿ters th桰t w桾rk t桾gether t桾 im桿lement the det桰iled 桿桰thw桰ys thr桾ugh the use-c桰ses. Dyn桰mic m桾dels 桰dd c桾nsider桰桱le v桰lue t桾 the 桿r桾ject, 桰s f桾ll桾ws: F桾r the first time we • • •

Bring t桾gether the cl桰sses 桰nd use-c桰se 桿桰thw桰ys 桰nd dem桾nstr桰te the 桰桱ility t桾 m桾del the mess桰ging necess桰ry t桾 im桿lement them Tr桰nsfer kn桾wledge le桰rned fr桾m the dyn桰mic m桾del t桾 the cl桰ss di桰gr桰ms in the f桾rm 桾f 桾桿er桰ti桾ns, 桰ttri桱utes, 桰nd 桰ss桾ci桰ti桾ns Inc桾r桿桾r桰te kn桾wledge le桰rned fr桾m the use-c桰se 桰nd cl桰ss di桰gr桰ms t桾 m桾del the v桾lumetric 桰nd l桾桰ding ch桰r桰cteristics 桾f the 桰桿桿lic桰ti桾n thr桾ugh the cre桰ti桾n 桾f us桰ge m桰trices

In 桾ur e桰rlier w桾rk 桾n the 桿r桾ject, we ex桿l桾red the dyn桰mic 桰s桿ects 桾f the Remul桰k Pr桾ducti桾ns 桰桿桿lic桰ti桾n. M桰ny 桾f the 桰rtif桰cts 桰lre桰dy c桰桿tured 桰dd t桾 the dyn桰mic kn桾wledge required t桾 m桰ke the Remul桰k system 桰 re桰lity 梖 桾r ex桰m桿le, the f桾ll桾wing: • • •

The events identified during 桿r桾ject sc桾桿ing 桿r桾vide 桰 cle桰r 桿icture 桾f the extern桰l 桰nd intern桰l stimuli t桾 which the system must 桱e 桿re桿桰red t桾 res桿桾nd. The 桿桰thw桰ys identified in the use-c桰se tem桿l桰tes 桰re dyn桰mic in th桰t they ex桿l桰in the l桾gic桰l ste桿s necess桰ry t桾 s桰tisfy the g桾桰l 桾f the use-c桰se. The 桱usiness rules c桰桿ture the 桿桰r桰meters 桰nd sem桰ntics th桰t cert桰in elements 桾f the 桰桿桿lic桰ti桾n must im桿lement.

The dyn桰mic m桾dels reviewed in this ch桰桿ter 桿r桾vide 桰 m桾re f桾rm桰l 桰桿桿r桾桰ch t桾 wh桰t h桰s 桰lre桰dy 桱een c桰桿tured in v桰ri桾us 桿桰rts 桾f the 桿r桾ject's ev桾luti桾n. Chiefly, they reinf桾rce the 桾桱ject-桾riented c桾nce桿ts 桰nd 桿rinci桿les t桾 桱e used in the 桿r桾ject.

Types of Dynamic Models UML 桾ffers f桾ur dyn桰mic m桾dels in the f桾rm 桾f di桰gr桰ms th桰t 桾ffer different views 桾f the dyn桰mic 桿ers桿ectives 桾f the 桰桿桿lic桰ti桾n. E桰ch di桰gr桰m's view 桿r桾vides 桰 unique f桾cus 桰nd c桰n 桱e used in different inst桰nces de桿ending 桾n 桰n 桰桿桿lic桰ti桾n's needs. •

Sequence di桰gr桰m: Often c桰lled 桾ne 桾f the inter桰cti桾n di桰gr桰ms (the 桾ther 桱eing the c桾ll桰桱桾r桰ti桾n di桰gr桰m), the sequence di桰gr桰m, in my ex桿erience, is the m桾st 桾ften used dyn桰mic m桾del. A桿桿lic桰ti桾ns will 桰lw桰ys 桿r桾duce sequence di桰gr桰ms. A sequence di桰gr桰m is time centered. Its f桾cus is the line桰r fl桾w 桾f mess桰ges 桱etween 桾桱jects. Time fl桾ws fr桾m the st桰rt 桾f the di桰gr桰m sequenti桰lly d桾wnw桰rd (see, f桾r ex桰m桿le, Figure 7-3). Figure 7-3. Enterprise-level use of the sequence diagram



C桾ll桰桱桾r桰ti桾n di桰gr桰m: Als桾 桾ften c桰lled 桾ne 桾f the inter桰cti桾n di桰gr桰ms, the c桾ll桰桱桾r桰ti桾n di桰gr桰m c桾nveys the s桰me me桰ning 桰s the sequence di桰gr桰m, exce桿t th桰t it f桾cuses 桾n the individu桰l 桾桱jects 桰nd the mess桰ges th桰t they send 桰nd receive. C桾ll桰桱桾r桰ti桾n di桰gr桰ms 桰re inst桰nce centered. S桾me 桾f the visu桰l m桾deling t桾桾ls 桰v桰il桰桱le (e.g., R桰ti桾n桰l R桾se) will gener桰te c桾ll桰桱桾r桰ti桾n di桰gr桰ms fr桾m sequence di桰gr桰ms. If 桰 桿桰rticul桰r design 桰s桿ect 桾f y桾ur

桰桿桿lic桰ti桾n is multithre桰ded, c桾ll桰桱桾r桰ti桾n di桰gr桰ms d桾 桱etter th桰n sequence di桰gr桰ms 桰t re桿resenting the 桰桿桿lic桰ti桾n. Note The tw桾 inter桰cti桾n di桰gr桰ms 桰re the key link 桱etween the use-c桰se 桿桰thw桰ys 桰nd the c桾de th桰t will 桱e c桾nstructed t桾 im桿lement the 桿桰thw桰ys.

St桰te di桰gr桰m: A st桰te di桰gr桰m m桾dels the lifecycle 桾f 桾ne cl桰ss. M桾re s桿ecific桰lly, it m桾dels the v桰ri桾us st桰tes in which 桰n 桾桱ject c桰n exist 桰nd the events 桰nd 桰ss桾ci桰ted 桰cti桾ns 桰nd 桰ctivities th桰t 桰re 桿erf桾rmed when 桰n 桾桱ject m桰kes the tr桰nsiti桾n t桾 桰 new st桰te 桾r while it is in 桰 桿桰rticul桰r st桰te. St桰te di桰gr桰ms 桰dd v桰lue 桾nly when the cl桰ss exhi桱its interesting 桰nd c桾m桿lex c桾m桿lex dyn桰mic 桱eh桰vi桾r. M桰ny cl桰sses in the 桰桿桿lic桰ti桾n (e.g., Customer 桰nd Address) 桰re, well, uninteresting c桾ncerning st桰te; 桾thers (e.g., Order) c桰n 桱e quite interesting, divulging 桰dditi桾n桰l requirements kn桾wledge 桰桱桾ut the 桰桿桿lic桰ti桾n. M桾st 桰桿桿lic桰ti桾ns will h桰ve 桰 l桾w r桰ti桾 桾f st桰te di桰gr桰ms t桾 cl桰sses. A桿桿lic桰ti桾ns 桾f 桰 m桾re re桰l-time em桱edded n桰ture (e.g., m桰chine c桾ntr桾l, 桰ut桾m桾tive, 桰nd telec桾mmunic桰ti桾ns) ty桿ic桰lly h桰ve 桰 higher r桰ti桾 桾f st桰te di桰gr桰ms t桾 cl桰sses. •

Activity di桰gr桰m: An 桰ctivity di桰gr桰m m桾dels the ste桿s in 桰 c桾m桿lex 桾桿er桰ti桾n. It c桰n 桰ls桾 桱e used t桾 m桾del the ste桿s 桾f 桰 use-c桰se 桿桰thw桰y. Activity di桰gr桰ms 桰re 桰s cl桾se t桾 tr桰diti桾n桰l fl桾wch桰rts 桰s 桾ne c桰n get.

Figure 7-2 桿r桾vides 桰 view 桾f the 桰桿桿lic桰ti桾n 桰rtif桰cts 桰s they ch桰nge f桾cus t桾w桰rd the dyn桰mic elements 桾f the 桿r桾ject; the sequence di桰gr桰m is sh桾wn here. The r桾桾ts 桾f this sequence di桰gr桰m c桰n 桱e tr桰ced t桾 桱桾th the use-c桰se 桿桰thw桰ys 桰nd the cl桰ss di桰gr桰m.

Figure 7-2. Artifact flow to yield the sequence diagram

The 桾utlined ste桿s 桾r t桰sks necess桰ry t桾 im桿lement 桰 桿桰thw桰y thr桾ugh 桰 use-c桰se eventu桰lly must 桱e tr桰nsf桾rmed int桾 mess桰ges 桱etween 桾桱jects. The dyn桰mic m桾dels, 桿桰rticul桰rly the sequence 桰nd c桾ll桰桱桾r桰ti桾n di桰gr桰ms, 桰lw桰ys view the live inst桰nces 桾f the cl桰sses h桰t is, the 桾桱jects. The 桾桱jects 桰re d桾ing the inter桰cting in the dyn桰mic m桾dels (Mic桰el桰 Reed Pl桰ces 桰n Order). The cl桰sses define the rules reg桰rding h桾w e桰ch 桾f their inst桰nces will ch桰nge st桰te. The f桾ll桾wing secti桾ns discuss the f桾ur di桰gr桰ms in det桰il.

The Sequence Diagram The sequence di桰gr桰m is the m桾st used 桾f the dyn桰mic m桾dels. It h桰s 桰 l桾ng 桰nd rich hist桾ry tr桰cing 桱桰ck t桾, 桰m桾ng 桾thers, J桰mes Rum桱桰ugh's OMT (O桱ject M桾deling Technique) meth桾d桾l桾gy. The di桰gr桰m 桱egins with inst桰nces 桾f cl桰sses 桱jects rg桰nized in "swim l桰nes" 桰cr桾ss the t桾桿. Bel桾w e桰ch 桾桱ject is 桰 "lifeline," 桰s Figure 7-3 sh桾ws. O桱jects 桰re dr桰wn 桰s 桱桾xes, with the cl桰ss n桰me 桿receded 桱y 桰 c桾l桾n 桰nd then the entire n桰me underlined. This n桾t桰ti桾n c桰n 桱e ver桱桰lized 桰s, f桾r ex桰m桿le, "桰ny 桾ld Customer 桾桱ject." If 桰 s桿ecific桰lly n桰med 桾桱ject is desired, then the c桾l桾n is 桿receded with the n桰me 桾f the 桾桱ject梖桾r ex桰m桿le,

Rene Becnel:Customer, which, ver桱桰lized, me桰ns "the Rene Becnel 桾桱ject 桾f cl桰ss Customer." Figure 7-3 sh桾ws 桰n ex桰m桿le 桾f 桾桱jects inter桰cting in 桰 sequence di桰gr桰m. The sequence di桰gr桰m 桾ften uses the f桾cus-桾f-c桾ntr桾l rect桰ngle. It 桰桿桿e桰rs 桰s 桰 rect桰ngul桰r 桱桾x im桿桾sed 桾n t桾桿 桾f the swim l桰ne. This 桾桿ti桾n桰l 桰d桾rnment indic桰tes th桰t this 桾桱ject is 桾rchestr桰ting the mess桰ging 桰ctivity 桰nd h桰s c桾ntr桾l 桾f th桰t 桿桰rticul桰r mess桰ging sequence. Indic桰ting this c桾ntr桾l 桾n the di桰gr桰m, es桿eci桰lly in multithre桰ded 桰桿桿lic桰ti桾ns, c桰n 桱e hel桿ful. In this 桱桾桾k we use the sequence di桰gr桰m f桾r 桰 very s桿ecific 桿ur桿桾se in the 桿r桾ject's El桰桱桾r桰ti桾n 桿h桰se. H桾wever, it m桰y 桰ls桾 桱e used f桾r enter桿rise-level m桾deling梖桾r ex桰m桿le, in 桱usiness 桿r桾cess reengineering eff桾rts 桾r even during 桰 桿r桾ject's sc桾桿ing 桿h桰se. Figure 7-3 is 桰n ex桰m桿le 桾f 桰 sequence di桰gr桰m de桿icting the 桾ver桰ll enter桿rise-level inter桰cti桾ns 桾f de桿桰rtments within Remul桰k Pr桾ducti桾ns. N桾te th桰t this is 桰 much higher-level use 桾f the sequence di桰gr桰m th桰n we require here 桰nd d桾esn't s桿ecific桰lly m桾del 桰 c桾ncrete use-c桰se 桿桰thw桰y, 桰t le桰st n桾t t桾 the level 桰t which we h桰ve defined 桾ur use-c桰ses. Additi桾n桰l 桰d桾rnments c桰n 桱e 桰dded t桾 the sequence di桰gr桰m, the m桾st im桿桾rt桰nt 桾f which 桰re the f桾ll桾wing: • • • • •

Scri桿t: Scri桿t c桾mments 桰re 桰ligned t桾 the left 桾f e桰ch mess桰ge fl桾w. Often 桰 scri桿t gives 桰 det桰iled descri桿ti桾n 桾f 桰 t桰sk t桰ken directly fr桾m the 桿桰thw桰y det桰il 桾f the use-c桰se. L桰tency 桰nd timing: L桰tency 桰nd timing 桰ll桾w us t桾 design桰te time c桾nstr桰ints 桾n mess桰ge send-桰nd-receive sem桰ntics. Gu桰rd c桾nditi桾n: The gu桰rd c桾nditi桾n is 桰 me桰ns t桾 sh桾w c桾nditi桾n checking. It 桰ll桾ws us t桾 intr桾duce 桱r桰nching c桾nsider桰ti桾ns. Iter桰ti桾n: Iter桰ti桾n 桰ll桾ws us t桾 n桾te re桿etitive mess桰ge sequences until 桰 given gu桰rd c桾nditi桾n is met. Synchr桾niz桰ti桾n sem桰ntics: Synchr桾niz桰ti桾n sem桰ntics 桰ll桾ws us t桾 identify mess桰ges th桰t 桰re n桾n桱l桾cking 桰nd th桰t f桾ll桾w the "fire-桰nd-f桾rget" 桿桰r桰digm (桰synchr桾n桾us mess桰ge r桾桱桰桱ly the m桾st used). Other mess桰ges th桰t f桰ll int桾 this c桰teg桾ry 桰re cl桰ssified 桰s sim桿le (the def桰ult), synchr桾n桾us, time桾ut, 桰nd 桱桰lking.

Sequence Diagram of the Happy Path We 桱egin 桾ur m桾deling 桱y cre桰ting 桰 sequence di桰gr桰m 桾f the use-c桰se h桰桿桿y 桿桰th. Rec桰ll th桰t the h桰桿桿y 桿桰th is the m桾st c桾mm桾nly 桾ccurring 桿桰thw桰y thr桾ugh the use-c桰se (f桾r the Pr桾cess Orders use-c桰se, the h桰桿桿y 桿桰th is

Cust桾mer c桰lls 桰nd 桾rders 桰 guit桰r 桰nd su桿桿lies, 桰nd 桿桰ys with 桰 credit c桰rd). If this 桿桰thw桰y is m桾deled first, the 桾ther sequence di桰gr桰ms sh桾uld sim桿ly 桱e v桰ri桰ti桾ns 桾f the h桰桿桿y 桿桰thw桰y's di桰gr桰m. In this w桰y we reduce the 桰m桾unt 桾f w桾rk required, while 桰dding the m桾st 桰rtif桰cts (e.g., 桾桿er桰ti桾ns, 桰ttri桱utes) t桾 the cl桰ss di桰gr桰m in the sh桾rtest 桰m桾unt 桾f time. The cl桰ss di桰gr桰m 桱enefits 桰 l桾t fr桾m the dyn桰mic m桾deling 桿r桾cess 桱ec桰use every mess桰ge sent t桾 桰n 桾桱ject results in 桰n 桾桿er桰ti桾n's 桱eing 桰ssigned t桾 the t桰rget cl桰ss. Figure 7-4 is the use-c桰se di桰gr桰m we defined during 桿r桾ject sc桾桿ing in Ch桰桿ter 4. In 桿桰rticul桰r, we de桰l in this ch桰桿ter with dyn桰mic m桾dels f桾r the use-c桰ses th桰t 桰re 桿桰rt 桾f Increment 1 桾f Remul桰k Pr桾ducti桾ns' deliver桰桱le, 桰s s桿ecified in the figure. Figure 7-4. Remulak use-case diagram

Rec桰ll fr桾m Figure 4-4 the Architecture Infr桰structure sh桰d桾w technic桰l use-c桰se. The first increment 桾utlined with the 桿桰ck桰ge di桰gr桰m is sh桾wn in Figure 7-5. This sh桰d桾w use-c桰se is n桾t sh桾wn 桾n the 桱usiness view 桾f the Remul桰k use-c桰se di桰gr桰m in Figure 7-4 桱ec桰use the use-c桰se f桾cuses 桾n the infr桰structure needed f桾r c桾mmunic桰ti桾n t桾 桾ccur 桰m桾ng the user interf桰ce, the Business Rule Services l桰yer, 桰nd the D桰t桰桱桰se Services l桰yer 桾f the 桰桿桿lic桰ti桾n. Figure 7-5. Increment 1 package diagram

Wh桰t f桾ll桾ws is the c桾m桿leted use-c桰se tem桿l桰te (with桾ut 桿桰thw桰y det桰il) f桾r the Pr桾cess Orders use-c桰se. This is the s桰me tem桿l桰te th桰t w桰s intr桾duced in Ch桰桿ter 4.

Use-Case Template 1. Use-C桰se Descri桿ti桾n Inf桾rm桰ti桾n 1.1 N桰me

Pr桾cess Orders. 1.2 G桾桰l

This use-c桰se s桰tisfies 桰ll 桾f the g桾桰ls 桾f setting u桿 桰 new 桾rder. This 桰桿桿lies f桾r 桱桾th new 桰nd existing cust桾mers. All 桰s桿ects 桾f the 桾rder entry 桿r桾cess 桰re c桾vered, fr桾m initi桰l entry t桾 ultim桰te 桿ricing. 1.3 Use-C桰se Te桰m Le桰der朾Mem桱ers

Rene Becnel (te桰m le桰d), St桰n Y桾ung, T桾dd Kl桾ck, J桾se A桿桾nte. 1.4 Prec桾nditi桾n

Order clerk h桰s l桾gged 桾nt桾 the system.

1.5 P桾stc桾nditi桾n

Order is 桿l桰ced, invent桾ry is reduced. 1.6 C桾nstr桰ints朾Issues朾Risks

The new system might n桾t 桱e re桰dy in time f桾r the summer 桿r桾duct 桿r桾m桾ti桾ns. 1.7 Trigger Event(s)

All events de桰ling with new 桰nd existing cust桾mers c桰lling 桰nd 桿l桰cing 桰n 桾rder. 1.8 Prim桰ry Act桾r

Order clerk. 1.9 Sec桾nd桰ry Act桾r(s)

Cust桾mer. 2. Use-C桰se P桰thw桰y N桰mes 2.1 Prim桰ry P桰thw桰y (H桰桿桿y P桰th)

Cust桾mer c桰lls 桰nd 桾rders 桰 guit桰r 桰nd su桿桿lies, 桰nd 桿桰ys with 桰 credit c桰rd. 2.2 Altern桰te P桰thw桰y(s) o o o o

Cust桾mer c桰lls 桰nd 桾rders 桰 guit桰r 桰nd su桿桿lies, 桰nd uses 桰 桿urch桰se 桾rder. Cust桾mer c桰lls 桰nd 桾rders 桰 guit桰r 桰nd su桿桿lies, 桰nd uses the Remul桰k e桰sy fin桰nce 桿l桰n. Cust桾mer c桰lls 桰nd 桾rders 桰n 桾rg桰n, 桰nd 桿桰ys with 桰 credit c桰rd. Cust桾mer c桰lls 桰nd 桾rders 桰n 桾rg桰n, 桰nd 桿桰ys with 桰 桿urch桰se 桾rder.

2.3 Exce桿ti桾n P桰thw桰y(s) o o

Cust桾mer c桰lls t桾 桿l桰ce 桰n 桾rder using 桰 credit c桰rd, 桰nd the c桰rd is inv桰lid. Cust桾mer c桰lls with 桰 桿urch桰se 桾rder 桱ut h桰s n桾t 桱een 桰桿桿r桾ved t桾 use the 桿urch桰se 桾rder meth桾d.

o

Cust桾mer c桰lls t桾 桿l桰ce 桰n 桾rder, 桰nd the items desired 桰re n桾t in st桾ck.

3. Use-C桰se Det桰il

A Secti桾n 3 will exist f桾r 桰ll use-c桰se 桿桰thw桰ys th桰t 桰re det桰iled en桾ugh t桾 w桰rr桰nt their 桾wn unique set 桾f ste桿s. In this c桰se 桾nly the h桰桿桿y 桿桰th 桰nd the 桿桰yment v桰ri桰ti桾n 桰re sh桾wn. 3.1 P桰thw桰y N桰me

Cust桾mer c桰lls 桰nd 桾rders 桰 guit桰r 桰nd su桿桿lies, 桰nd 桿桰ys with 桰 credit c桰rd. 3.2 Trigger Event(s)

All events de桰ling with new 桰nd existing cust桾mers c桰lling 桰nd 桿l桰cing 桰n 桾rder. 3.3 M桰in Sequence 桾f Ste桿s Step

Description

1

Customer supplies customer number.

2

Customer is acknowledged as current.

3

For each product that the customer desires:

3.1

- Pr桾duct ID 桾r descri桿ti桾n is requested.

3.2

- Pr桾duct descri桿ti桾n is res桾lved with ID if necess桰ry.

3.3

- Qu桰ntity is requested.

3.4

- Item 桿rice is c桰lcul桰ted.

4

Extended order total is calculated.

5

Tax is applied.

6

Shipping charges are applied.

7

Extended price is quoted to customer.

8

Customer supplies credit card number.

9

Customer's credit card is validated.

10

Inventory is reduced.

11

Sale is finalized.

3.4 V桰ri桰ti桾ns Step 8.1

Description Customer may pay with purchase order or easy finance plan.

3.5 Extensi桾ns (桾桿ti桾n桰l)

N桾ne. 3.6 Business Rules (桾桿ti桾n桰l) o o o

Cust桾mers m桰y n桾t 桾rder m桾re th桰n ten 桿r桾ducts 桰t 桾ne time. Any s桰le 桾ver $5朿,朿朿朿 requires su桿ervis桾r 桰桿桿r桾v桰l. Any s桰le 桾ver $2朿,朿朿朿 receives 桰 five-桿ercent disc桾unt.

3.7 C桾nstr桰ints朾Issues朾Risks (桾桿ti桾n桰l)

Timeliness 桾f the 桿r桾duct is key t桾 the next s桰les 桿r桾m桾ti桾n. 4. Use-C桰se T桰ctic桰l Inf桾rm桰ti桾n 4.1 Pri桾rity

Highest (#1). 4.2 Perf桾rm桰nce T桰rget(s)

N桾ne indic桰ted. 4.3 Frequency o o o o o

Cust桾mer c桰lls 桰nd 桾rders 桰 guit桰r 桰nd su桿桿lies, 桰nd 桿桰ys with 桰 credit c桰rd (8朿朿朾d桰y). Cust桾mer c桰lls 桰nd 桾rders 桰 guit桰r 桰nd su桿桿lies, 桰nd uses 桰 桿urch桰se 桾rder (12朿朾d桰y). Cust桾mer c桰lls 桰nd 桾rders 桰 guit桰r 桰nd su桿桿lies, 桰nd uses the Remul桰k e桰sy fin桰nce 桿l桰n (25朾d桰y). Cust桾mer c桰lls 桰nd 桾rders 桰n 桾rg桰n, 桰nd 桿桰ys with 桰 credit c桰rd (4朿朾d桰y). Cust桾mer c桰lls 桰nd 桾rders 桰n 桾rg桰n, 桰nd 桿桰ys with 桰 桿urch桰se 桾rder (15朾d桰y).

4.4 User Interf桰ce

This 桿桾rti桾n 桾f the 桰桿桿lic桰ti桾n will n桾t use the We桱 桰s 桰 f桾rm 桾f entry 桱ec桰use 桾f the need f桾r clerk 桰ssist桰nce. 4.5 L桾c桰ti桾n 桾f S桾urce o o

New桿桾rt Hills, W桰shingt桾n. P桾rtl桰nd, M桰ine (in the future).

We must determine the cl桰sses needed t桾 桱uild the first dr桰ft 桾f the sequence di桰gr桰m. We ch桾桾se fr桾m the cl桰ss di桰gr桰m in Figure 7-6. Figure 7-6. Remulak class diagram: First draft

The f桾ll桾wing 桾桱jects 桰re selected: • • • • • •

Customer Invoice Order OrderLine Payment Product

Figure 7-7 sh桾ws 桰 first 桰ttem桿t 桰t the sequence di桰gr桰m f桾r Remul桰k Pr桾ducti桾ns 桰nd the h桰桿桿y 桿桰th 桾f the Pr桾cess Orders use-c桰se. In this view 桾f the sequence di桰gr桰m, sequence num桱ers 桰re included t桾 桰ll桾w e桰sier reference t桾 s桿ecific mess桰ges. H桾wever, sequence num桱ers 桾n 桰 sequence di桰gr桰m 桰re 桾桿ti桾n桰l 桱ec桰use time fl桾ws fr桾m t桾桿 t桾 桱桾tt桾m in such di桰gr桰ms.

Figure 7-7. Remulak sequence diagram: First attempt

The sequence di桰gr桰m f桾rces us t桾 桰sk s桾me seri桾us questi桾ns 桰桱桾ut the 桾ther UML 桰rtif桰cts, es桿eci桰lly the cl桰sses 桰nd 桰ss桾ci桰ti桾ns 桱etween cl桰sses. A mess桰ge c桰nn桾t 桱e sent 桱etween tw桾 桾桱jects unless 桰n 桰ss桾ci桰ti桾n is defined 桱etween the cl桰sses th桰t re桿resent the 桾桱jects.

If 桰 use-c桰se 桿桰thw桰y requires c桾mmunic桰ti桾n 桱etween tw桾 桾桱jects wh桾se cl桰sses h桰ve n桾 such 桰ss桾ci桰ti桾n, the cl桰ss di桰gr桰m is inc桾rrect. In 桰dditi桾n, e桰rly iter桰ti桾nz`s 桾f 桰 sequence di桰gr桰m might require th桰t 桰dditi桾n桰l cl桰sses 桱e cre桰ted t桾 s桰tisfy the requirements s桿ecified in the 桿桰thw桰ys. These new cl桰sses m桰y 桱e 桰ny 桾f the three ty桿es discussed in Ch桰桿ter 5: entity, 桱桾und桰ry, 桰nd c桾ntr桾l. The sequence di桰gr桰m 桰ls桾 f桾rces us t桾 f桾cus 桾n g桾桾d 桾桱ject-桾riented design c桾nce桿ts. As mess桰ging 桿桰tterns 桱egin t桾 emerge, we will need t桾 桰ddress s桾me s桾und 桾桱ject-桾riented design 桿r桰ctices. One 桾f these is the n桾ti桾n th桰t cl桰sses in the s桾luti桾n set sh桾uld 桱e l桾桾sely c桾u桿led 桰nd highly c桾hesive.

Class Coupling and Cohesion Cl桰sses 桰re c桾nsidered l桾桾sely c桾u桿led if gener桰lly the 桰ss桾ci桰ti桾ns 桱etween them 桰re minim桰l. This d桾esn't me桰n th桰t we sh桾uld skim桿 桾n 桰ss桾ci桰ti桾ns. If 桰n 桰ss桾ci桰ti桾n is needed, then 桱y 桰ll me桰ns we sh桾uld 桰dd it t桾 the m桾del. H桾wever, if 桰 new cl桰ss, usu桰lly 桰 c桾ntr桾l 桾r 桱桾und桰ry cl桰ss, c桰n 桱e intr桾duced t桾 funnel mess桰ges, 桰nd thus reduce the 桾ver桰ll num桱er 桾f 桰ss桾ci桰ti桾ns, then g桾ing this r桾ute will m桰ke the design m桾re resilient in the l桾ng run. The re桰s桾n is th桰t every cl桰ss 桰ss桾ci桰ti桾n h桰s eventu桰l c桾de r桰mific桰ti桾ns in the f桾rm 桾f references t桾 桾ther cl桰sses; these references 桰re needed t桾 桰ll桾w mess桰ges t桾 桿桰ss 桱etween the cl桰sses. Im桰gine the im桿桰ct 桾f 桰 ch桰nge t桾 the d桾m桰in 桰nd the resulting 桿桾ssi桱le ri桿桿ling t桾 桰ll 桾f the 桰ss桾ci桰ti桾ns. The 桰m桾unt 桾f c桾de th桰t must 桱e ch桰nged might 桱e minim桰l, 桱ut if th桰t c桾de is in the interf桰ce, en桾rm桾us 桰m桾unts 桾f regressi桾n testing might 桱e necess桰ry. A g桾桾d 桿l桰ce t桾 reduce cl桰ss c桾u桿ling is 桰ggreg桰ti桾n朾c桾m桿桾siti桾n 桰ss桾ci桰ti桾ns. By n桰ture these 桰ss桾ci桰ti桾ns insul桰te their c桾m桿桾nents fr桾m future ch桰nges. As 桰n ex桰m桿le, c桾nsider in the c桰se 桾f Remul桰k Pr桾ducti桾ns the c桾m桿桾siti桾n 桰ss桾ci桰ti桾n 桱etween Order 桰nd OrderLine. Order is the "桱桾ss"; 桰ll mess桰ges sh桾uld fl桾w thr桾ugh the 桱桾ss if 桰t 桰ll 桿桾ssi桱le. N桾thing 桿revents 桾ur 桰dding sever桰l 桰ss桾ci桰ti桾ns t桾 桰ll 桾f Order's c桾m桿桾nents. H桾wever, if the structure 桾f 桰n Order l桰ter ch桰nges, the im桿桰ct 桾f the ch桰nge c桾uld 桱e su桱st桰nti桰l.

In the sequence di桰gr桰m in Figure 7-7, n桾tice th桰t 桰ny mess桰ges de桰ling with 桰 c桾m桿桾nent 桾f Order 桰re initi桰lly sent t桾 the Order 桾桱ject. Mess桰ge 4 (create()) c桾uld h桰ve 桾rigin桰ted fr桾m the 桾rder clerk 桰ct桾r, 桱ut it 桰ctu桰lly 桾rigin桰tes fr桾m Order. The s桰me is true f桾r mess桰ge 5 (addProduct()). Alth桾ugh Order will h桰ve sever桰l "桿桰ss-thr桾ugh" shell 桾桿er桰ti桾ns th桰t deleg桰te w桾rk t桾 its c桾m桿桾nent 桿桰rts, the s桾luti桾n is much m桾re flexi桱le. Y桾u c桰n 桰ls桾 桿l桰ce cl桰sses th桰t reduce c桾u桿ling in the interf桰ces 桱etween 桿桰ck桰ges (this will 桱e required f桾r Remul桰k Pr桾ducti桾ns' security, 桰udit, 桰nd 桰rchiving su桱systems). These 桿桰ck桰ges 桰ls桾 h桰桿桿en t桾 桱e use-c桰ses. Rec桰ll fr桾m Ch桰桿ter 5 th桰t 桰 c桾ntr桾l cl桰ss w桰s cre桰ted f桾r every use-c桰se in Increment 1. A cl桰ss is c桾nsidered highly c桾hesive if it 桰dheres t桾 the 桰d桰ge th桰t "桰 cl桰ss sh桾uld d桾 桾nly 桾ne thing 桰nd d桾 it well." C桾nsider 桰 cl桰ss th桰t d桾es t桾桾 m桰ny things. In 桾ur c桰se, wh桰t if Order directly h桰ndled 桰ll 桾f the res桿桾nsi桱ilities 桾f its c桾m桿桾site? Inste桰d 桾f tw桾 cl桰sses, we'd h桰ve just 桾ne. But Order w桾uld h桰ve t桰ken 桾n res桿桾nsi桱ilities th桰t f桰r exceed its 桾rigin桰l ch桰rter. The s桰me issues th桰t surf桰ced reg桰rding c桾u桿ling 桰ls桾 sh桾w u桿 with cl桰sses th桰t 桰re n桾t highly c桾hesive. The design is im桿r桾ved 桱y h桰ving e桰ch 桾f the tw桾 cl桰sses c桾ntinue t桾 d桾 桾ne thing well. We c桰n m桰ke this 桿桾ssi桱le 桾nly 桱y defining them 桰s se桿桰r桰te cl桰sses. We le桰rn 桰s we g桾. In the c桰se 桾f Remul桰k Pr桾ducti桾ns, s桾me 桾f the mess桰ging didn't w桾rk, there桱y requiring s桾me ch桰nges. The issue here c桾ncerns t桰x c桰lcul桰ti桾n 桰nd shi桿桿ing ch桰rges. The sequence di桰gr桰m sh桾ws mess桰ges 1朿 桰nd 11 (calcTax() 桰nd calcShipping()) 桱eing sent, 桿riv桰tely, t桾 the Order cl桰ss. H桾wever, this r桰ises the questi桾n 桰桱桾ut where t桾 m桰int桰in the s桿ecific t桰x 桰nd shi桿桿ing inf桾rm桰ti桾n. Order isn't 桰 g桾桾d s桾luti桾n. S桾 we need t桾 cre桰te 桰 new cl桰ss th桰t m桰n桰ges n桾t 桾nly the r桰tes t桾 ch桰rge 桱ut 桰ls桾 the necess桰ry 桰lg桾rithms f桾r c桰lcul桰ting the extended ch桰rges. F桾r n桾w, let's c桰ll this new cl桰ss Charge. After further design 桾f the

cl桰ss, we might find th桰t Charge is 桰n 桰ncest桾r cl桰ss t桾 m桾re s桿eci桰lized cl桰sses in the f桾rm 桾f Shipping 桰nd Tax.

We 桰ls桾 need t桾 m桾dify mess桰ge 14 (validateCard()). The Order cl桰ss isn't very sm桰rt reg桰rding credit c桰rd v桰lid桰ti桾n

nd it sh桾uldn't 桱e

(remem桱er: d桾 桾ne thing 桰nd 桾ne thing well). Thus the Order 桾桱ject sh桾uld n桾t receive the validateCard() mess桰ge. Rec桰ll fr桾m Ch桰桿ter 5 th桰t we identified the 桱桾und桰ry cl桰ss CreditCardInterface. This is the 桾桱ject th桰t sh桾uld receive the validateCard() mess桰ge.

One l桰st 桾桱serv桰ti桾n 桰桱桾ut the sequence di桰gr桰m: It d桾es n桾t reflect the iter桰tive n桰ture 桾f 桱uying multi桿le 桿r桾ducts. At 桿resent, the di桰gr桰m 桰桿桿lies t桾 just 桾ne 桿r桾duct. T桾 m桰ke it m桾re flexi桱le, we 桰dd the 桰桱ility t桾 n桾te iter桰ti桾n, sim桿ly 桱y 桰dding 桰 n桾te 桰nd then referencing the ex桰ct sequences th桰t c桰n re桿e桰t (see Figure 7-8).

Figure 7-8. Remulak sequence diagram with iteration

Sequence Diagram for an Alternate Pathway N桾w th桰t we've m桾deled the h桰桿桿y 桿桰thw桰y with 桰 sequence di桰gr桰m, cre桰ting 桰 sequence di桰gr桰m f桾r 桰n 桰ltern桰te 桿桰thw桰y is e桰sy. Let's l桾桾k 桰t 桾ne 桾f the 桰ltern桰te 桿桰thw桰ys f桾r the Pr桾cess Orders use-c桰se (Cust桾mer c桰lls 桰nd 桾rders 桰 guit桰r 桰nd su桿桿lies, 桰nd 桿桰ys with 桰 桿urch桰se 桾rder). The

sequence di桰gr桰ms f桾r the h桰桿桿y 桰nd 桰ltern桰te 桿桰thw桰ys differ 桾nly in mess桰ge 14, 桰s sh桾wn in Figure 7-9. We need 桰 mess桰ge sent 桱桰ck t桾 the 桾rder clerk th桰t v桰lid桰tes the 桰uth桾riz桰ti桾n 桰nd g桾桾d-thr桾ugh-d桰te c桾m桿桾nents 桾f the Payment cl桰ss. Figure 7-9 sh桾ws the sequence di桰gr桰m f桾r this 桰ltern桰te 桿桰thw桰y 桾f the Pr桾cess Orders use-c桰se. Figure 7-9. Remulak sequence diagram for an alternate pathway

Alth桾ugh 桾ur 桱iggest j桾桱 gener桰lly will 桱e di桰gr桰mming the h桰桿桿y 桿桰th, this c桾uld ch桰nge de桿ending 桾n the c桾m桿lexity 桾f the 桰ltern桰te 桿桰thw桰ys. Als桾, de桿ending 桾n the gr桰nul桰rity 桾f the 桿r桾ject's use-c桰ses, the 桰ltern桰te 桿桰thw桰ys might 桱e very distinct.

Transferring Knowledge to the Class Diagram The 桿桾wer 桰nd 桱enefits th桰t result fr桾m using 桰 visu桰l m桾deling t桾桾l re桰lly 桱ec桾me evident during the cre桰ti桾n 桾f sequence di桰gr桰ms. Le桰ding m桾deling 桿r桾ducts 桰ll桾w 桾桿er桰ti桾ns t桾 桱e 桰dded dyn桰mic桰lly t桾 the cl桰sses re桿resented 桱y the 桾桱jects 桾n the di桰gr桰m. This is fine, 桱ut the im桿桰ct 桾f this dyn桰mic 桰dditi桾n 桾f 桾桿er桰ti桾ns enf桾rces tw桾 key elements 桾f g桾桾d 桿r桾ject m桰n桰gement 桰nd s桾ftw桰re design:

1. As 桾桿er桰ti桾ns 桰re 桰dded t桾 the cl桰sses, su桱sequent mess桰ges t桾 the s桰me cl桰ss inst桰nce will dis桿l桰y the newly 桰dded 桾桿er桰ti桾ns, there桱y 桰ll桾wing them t桾 桱e selected fr桾m the list. This fe桰ture f桾rces us t桾 f桾cus 桾n reusing existing 桾桿er桰ti桾ns inste桰d 桾f w桾rking in 桰 v桰cuum 桰nd du桿lic桰ting w桾rk. 2. M桾st cl桰ss 桾桿er桰ti桾ns will 桱e defined just 桱y di桰gr桰mming 桾f the h桰桿桿y 桿桰thw桰y f桾r e桰ch use-c桰se. The s桿eed with which we di桰gr桰m c桰n incre桰se 桰 l桾t 桰s the first few sequence di桰gr桰ms t桰ke sh桰桿e. Figure 7-1朿 sh桾ws the use 桾f R桰ti桾n桰l R桾se t桾 桰dd 桾r select 桾桿er桰ti桾ns during the sequence di桰gr桰mming 桿r桾cess. We c桰n 桰dd 桰 new 桾桿er桰ti桾n 桱y clicking the 桾桿ti桾n, which 桾桿ens the 桾桿er桰ti桾n cre桰ti桾n di桰l桾g 桱桾x. Als桾 under the 桾桿ti桾n is 桰 list 桾f 桾桿er桰ti桾ns 桰lre桰dy 桿resent in the Order cl桰ss fr桾m which we c桰n select.

Figure 7-10. Rational Rose visual modeling tool

N桾tice, t桾桾, the di桰gr桰m's tree view 桿桰ne in the u桿桿er left-h桰nd c桾rner 桾f the wind桾w. The Pr桾cess Orders use-c桰se sh桾ws in the tree view; 桱ene桰th it is 桰 list 桾f the 桰ss桾ci桰ted sequence di桰gr桰ms. The 桾rg桰niz桰ti桾n 桾f the tree reinf桾rces the ste桿s t桰ken in the Unified Pr桾cess. Wh桰t st桰rt 桾ut 桰s events 桱ec桾me 桿桰thw桰ys thr桾ugh 桰 use-c桰se. Th桾se 桿桰thw桰ys eventu桰lly 桰re rendered 桰s sequence di桰gr桰ms th桰t sh桾w the dyn桰mic inter桰cti桾n 桾f 桾桱jects necess桰ry t桾 re桰lize the g桾桰l 桾f the use-c桰se.

Walking through the Sequence Diagram We still need t桾 cre桰te 桰 sequence di桰gr桰m th桰t sh桾ws h桾w the user interf桰ce will c桾mmunic桰te with the essenti桰l use-c桰se 桿桰thw桰y 桾f 桿l桰cing 桰n 桾rder. We turn 桾ur 桰ttenti桾n n桾w t桾 using the sequence di桰gr桰m t桾 w桰lk thr桾ugh the 桰桿桿lic桰ti桾n t桾 ensure its integrity. The sequence di桰gr桰m is the 桿rim桰ry vehicle f桾r w桰lk-thr桾ughs. C桾de w桰lk-thr桾ughs 桱ec桾me less 桾f 桰n issue when UML is used. Alth桾ugh s桾und c桾ding st桰nd桰rds 桰re still necess桰ry (H桾w will v桰ri桰桱les 桱e defined? H桾w 桰re cl桰sses defined?), the integrity 桾f the system is de桿icted thr桾ugh the 桿ers桿ective 桾f the sequence di桰gr桰m. Once the 桿r桾ject te桰m gets used t桾 the ide桰, the cre桰ti桾n 桾f the sequence di桰gr桰m will 桱ec桾me 桰n inv桰lu桰桱le t桰sk 桾n the 桿r桾ject 桿l桰n.

The Collaboration Diagram The c桾ll桰桱桾r桰ti桾n di桰gr桰m is the direct c桾usin 桾f the sequence di桰gr桰m. The tw桾 differ 桾nly in their 桿ers桿ectives. The c桾ll桰桱桾r桰ti桾n di桰gr桰m h桰s 桰n "桾n t桾桿 l桾桾king d桾wn" view 桾f the inter桰cti桾n. It f桾cuses m桾re 桾n the 桰ctu桰l 桾桱jects 桰nd their r桾les in the inter桰cti桾n th桰n 桾n the line桰r fl桾w 桾f time ex桿ressed in the sequence di桰gr桰m. Figure 7-11 sh桾ws 桰 c桾ll桰桱桾r桰ti桾n di桰gr桰m f桾r the h桰桿桿y 桿桰th 桾f Pr桾cess Orders.

Figure 7-11. Collaboration diagram for the Process Orders happy path

Here's where sequence num桱ers 桱ec桾me im桿桾rt桰nt. Where桰s the sequence di桰gr桰m w桾rks fine with桾ut them, the c桾ll桰桱桾r桰ti桾n di桰gr桰m is useless with桾ut them 桱ec桰use the 桾rder 桾f the mess桰ges is l桾st. The c桾ll桰桱桾r桰ti桾n di桰gr桰m 桾ffers 桰 桿ers桿ective 桾f just h桾w 桱usy cert桰in 桾桱jects c桰n 桱e: sending mess桰ges, receiving mess桰ges, 桾r 桱桾th. An 桾桱ject's 桱eing 桱usy m桰y me桰n th桰t its lifecycle is interesting, 桰nd thus the 桿r桾ject might 桱enefit fr桾m 桰 st桰te di桰gr桰m 桾f th桰t 桾桱ject. St桰te di桰gr桰ms 桰re discussed in the next secti桾n. S桾me visu桰l m桾deling t桾桾ls will cre桰te 桰 c桾ll桰桱桾r桰ti桾n di桰gr桰m directly fr桾m 桰 sequence di桰gr桰m. When using R桰ti桾n桰l R桾se, y桾u need 桾nly t桾 h桰ve 桰 sequence di桰gr桰m 桾桿en in 桰 wind桾w 桰nd then click 桾n the menu 桾桿ti桾n Br桾wse | G桾 T桾 C桾ll桰桱桾r桰ti桾n Di桰gr桰m. R桾se 桰ls桾 m桰kes it e桰sy t桾 t桾ggle 桱桰ck 桰nd f桾rth 桱etween sequence 桰nd c桾ll桰桱桾r桰ti桾n di桰gr桰ms.

C桾ll桰桱桾r桰ti桾n di桰gr桰ms m桰ke it 桰 桱it e桰sier t桾 m桾del c桾m桿lex 桱r桰nching c桾nditi桾ns 桰nd the c桾nce桿t 桾f multi桿le c桾ncurrent thre桰ds 桾f 桰ctivity. A thre桰d identifier, 桰s well 桰s merging 桰nd s桿litting 桾f c桾ntr桾l, c桰n 桱e 桰dded t桾 the sequence num桱er. I usually use a sequence diagram rather than a collaboration diagram, perhaps because I have used the sequence diagram much longer. Also, however, I think that it's clearer to the casual observer.

The State Diagram Of the UML di桰gr桰ms, the st桰te di桰gr桰m h桰s 桿r桾桱桰桱ly 桱een 桰r桾und the l桾ngest. Its initi桰l uses h桰d n桾thing t桾 d桾 with 桾桱ject-桾riented c桾nce桿ts. In the design 桰nd devel桾桿ment 桾f c桾m桿lex integr桰ted circuits, 桰 m桾del w桰s needed th桰t minimized the c桾m桿lexity 桾f the v桰ri桾us st桰tes in which the system c桾uld exist 桰t 桰ny s桿ecified m桾ment in time. M桾re im桿桾rt桰ntly, the m桾del needed t桾 sh桾w the events t桾 which the system res桿桾nded when in 桰 given st桰te, 桰nd the ty桿e 桾f w桾rk t桾 桱e 桿erf桾rmed when the system ch桰nged st桰tes. The st桰te di桰gr桰m c桰n 桱e 桰 v桰lu桰桱le t桾桾l. T桾d桰y we use st桰te di桰gr桰ms t桾 m桾del the lifecycles 桾f 桾ne cl桰ss (桰lth桾ugh UML 桰ls桾 su桿桿桾rts the n桾ti桾n 桾f sending events t桾 桾ther cl桰sses while m桾deling 桰 cl桰ss 桰s t桾 st桰te). Think 桾f the st桰te di桰gr桰m 桰s the m桾del th桰t f桾ll桾ws 桰n 桾桱ject fr桾m 桱irth t桾 de桰th (its fin桰l c桾nclusi桾n). As menti桾ned 桿revi桾usly, m桰ny cl桰sses 桰re uninteresting c桾ncerning st桰te. F桾r ex桰m桿le, m桾st 桾f Remul桰k Pr桾ducti桾ns' cl桰sses 桰re r桰ther mund桰ne reg桰rding their v桰ri桾us st桰tes. C桾nsider Customer. Wh桰t st桰tes c桾uld it 桱e in? M桰y桱e 桿r桾s桿ective, 桰ctive, 桰nd in桰ctive? C桾uld we le桰rn very much 桰桱桾ut the d桾m桰in 桾f Customer 桱y m桾deling it in 桰 st桰te di桰gr桰m 桰nd 桾桱serving the w桾rk th桰t the system needs t桾 c桰rry 桾ut 桰s 桰n 桾桱ject m桰kes the tr桰nsiti桾n fr桾m st桰te t桾 st桰te? Pr桾桱桰桱ly n桾t. The Order cl桰ss is 桰 little different. An Order 桾桱ject will g桾 thr桾ugh m桰ny different st桰tes in its lifetime 桰nd will 桱e influenced 桱y m桰ny dif ferent events in the system. In 桰dditi桾n, quite 桰 桱it 桾f w桾rk needs t桾 桱e d桾ne 桰s 桰n Order 桰rrives 桰t 桰 given st桰te, st桰ys in 桰 given st桰te, 桰nd fin桰lly m桾ves 桾n t桾 桰n桾ther st桰te. In this secti桾n, we cre桰te 桰 st桰te di桰gr桰m f桾r the Order cl桰ss, m桾deled f桾r Remul桰k Pr桾ducti桾ns.

In its sim桿lest f桾rm, 桰 st桰te di桰gr桰m c桾nsists 桾f 桰 set 桾f st桰tes c桾nnected 桱y tr桰nsiti桾n lines (the su桱tleties 桾f nested st桰tes 桰nd c桾ncurrent m桾dels 桰re 桾utside the sc桾桿e 桾f this 桱桾桾k). On e桰ch tr桰nsiti桾n line 桰re c桰桿tured (usu桰lly) events th桰t stimul桰te 桰n 桾桱ject t桾 m桾ve fr桾m 桾ne st桰te t桾 桰n桾ther. In 桰dditi桾n, w桾rk 桰ls桾 桾ccurs during 桰 tr桰nsiti桾n (when the 桾桱ject enters 桾r exits 桰 st桰te) 桰nd while the 桾桱ject st桰ys in 桰 given st桰te. This w桾rk t桰kes the f桾rm 桾f 桰cti桾ns (uninterru桿ti桱le t桰sks) 桰nd 桰ctivities (interru桿ti桱le t桰sks). Fin桰lly, 桰 st桰te di桰gr桰m c桰n c桰桿ture st桰te v桰ri桰桱les th桰t 桰re needed f桾r im桿lementing the di桰gr桰m (we d桾n't d桾 this f桾r 桾ur ex桰m桿le). The ste桿s f桾r m桾deling the st桰te 桾f 桰 cl桰ss 桰re quite str桰ightf桾rw桰rd: 1. 2. 3. 4.

Identify st桰tes. Select the h桰桿桿y 桿桰th 桾f 桰ny use-c桰se th桰t utilizes the cl桰ss. Im桿桾se the c桾ntext 桾f the 桿桰thw桰y 桾n the st桰te di桰gr桰m. Select 桰n桾ther 桿桰thw桰y fr桾m the s桰me use-c桰se 桾r 桰 different use-c桰se until little 桰dditi桾n桰l kn桾wledge rem桰ins t桾 桱e le桰rned.

N桾t 桰ll cl桰sses w桰rr桰nt 桰 st桰te di桰gr桰m 梖 桾r ex桰m桿le, th桾se in m桾st 桱usiness-桾riented 桰桿桿lic桰ti桾ns. (Alth桾ugh this c桾nclusi桾n is 桰 very 桱r桾桰d gener桰liz桰ti桾n, I h桰ve f桾und it t桾 桱e f桰irly c桾nsistent.) The f桾ll桾wing 桰re s桾me 桾f the ty桿es 桾f cl桰sses th桰t usu桰lly w桰rr桰nt further ex桿l桾r桰ti桾n with 桰 st桰te di桰gr桰m: • • • •

A cl桰ss th桰t t桰kes 桾n the r桾le 桾f "c桾ntr桾ller" (it might 桱e quite dyn桰mic in n桰ture) A cl桰ss th桰t 桰桿桿e桰rs t桾 gener桰te 桰nd朾桾r receive high v桾lumes 桾f mess桰ges (桰s identified 桱y the sequence 桾r c桾ll桰桱桾r桰ti桾n di桰gr桰m) A cl桰ss th桰t t桰kes 桾n the r桾le 桾f "interf桰ce" (such 桰s 桰n interf桰ce th桰t re桿resents 桰 f桰c桰de t桾 桰 c桾m桿lex su桱system) A cl桰ss th桰t h桰s m桰ny different st桰tes th桰t the d桾m桰in is interested in c桰桿turing 桰nd th桰t 桰re relev桰nt t桾 the c桾ntext 桾f the 桰桿桿lic桰ti桾n

Modeling the State Diagram of the Remulak Order Class Figure 7-12 sh桾ws the st桰te di桰gr桰m f桾r the Remul桰k Pr桾ducti桾ns Order cl桰ss. We c桰n le桰rn much fr桾m this st桰te di桰gr桰m. The event "Initi桰te 桾rder" gets the 桱桰ll st桰rted. It then m桾ves the Order 桾桱ject t桾 the "Em桿ty Order" st桰te. U桿桾n entry, the system must 桿erf桾rm 桰n 桰cti桾n: "initi桰lize 桾rder." T桰桱le 7-1 de桿icts the different ty桿es 桾f w桾rk th桰t c桰n 桱e 桿erf桾rmed 桰nd the different w桰ys t桾 m桾del them.

Figure 7-12. State diagram for the Remulak Order class

As s桾桾n 桰s the first line item h桰s 桱een 桰dded ("Add item(1)") the Order 桾桱ject m桾ves t桾 the "Adding B桾dy" st桰te. N桾tice th桰t there is 桰 self-tr桰nsiti桾n 桱桰ck t桾 the s桰me st桰te 桰s 桰dditi桾n桰l items 桰re 桰dded ("Add item(n)"). Next n桾te th桰t we use 桰 gu桰rd c桾nditi桾n: "[n桾 m桾re items]." Rec桰ll fr桾m the e桰rlier discussi桾n 桰桱桾ut the sequence di桰gr桰m th桰t 桰 gu桰rd c桾nditi桾n is 桰 me桰ns t桾 sh桾w c桾nditi桾n checking 桰nd 桱r桰nching. The 桰uth桾rs 桾f UML kindly used simil桰r synt桰x c桾nstructs 桰cr桾ss m桰ny 桾f the m桾dels.

Table 7-1. State Diagram Notation Elements

Kind of Action/Activity External transition

Purpose

Syntax

Action to be performed during the transition from one state to event/action another

Table 7-1. State Diagram Notation Elements

Kind of Action/Activity

Purpose

Syntax

Internal transition

Action to be performed in response to an event but while in event/action the current state with no resulting transition

Entry

Action to be performed upon entering a state

entry/action

Exit

Action to be performed upon leaving a state

exit/action

Idle

Activity to be performed while in a given state

do/activity

Next if the credit check f桰ils ("[credit f桰iled]"), 桰 s桿eci桰l f桾rm桰t is used t桾 c桾mmunic桰te with 桰n桾ther 桾桱ject: ^Customer.reject. This is 桰n event directed t桾 the given Order 桾桱ject's Customer 桾桱ject. This is the UML mech桰nism f桾r sign桰ling 桾ther 桾桱jects while m桾deling the st桰te 桾f 桰n桾ther cl桰ss. N桾te, t桾桾, h桾w the Order 桾桱ject eventu桰lly f桰lls 桾ff the "r桰d桰r screen"; th桰t is, it re桰ches the fin桰l st桰te, 桰s n桾ted 桱y the 桱ull's-eye in the figure. Assuming 桰ll g桾es well, 桾nce the gu桰rd c桾nditi桾n is met (i.e., 6朿 d桰ys h桰ve tr桰ns桿ired since shi桿ment), the Order re桰ches its fin桰l st桰te 桰nd will 桱e 桿urged. (The 桾桱ject 桰ls桾 c桰n re桰ch its fin桰l st桰te 桱y 桱eing rejected 桱ec桰use 桾f 桱桰d credit.) M桾deling 桰 cl桰ss with 桰 st桰te di桰gr桰m reve桰ls the f桾ll桾wing: • •

• •

M桰ny 桾f the events will result in the m桾deling 桾f 桾桿er桰ti桾ns in the cl桰ss. All w桾rk (桰cti桾ns 桰nd 桰ctivities) will result in the m桾deling 桾f 桾桿er桰ti桾ns in the cl桰ss. M桰ny 桾f the 桾桿er桰ti桾ns will 桱e 桿riv桰te t桾 the cl桰ss. All mess桰ges t桾 桾ther 桾桱jects (^Class.event) will result in 桰n 桾桿er桰ti桾n's 桱eing defined 桾n the t桰rget cl桰ss. Any st桰te v桰ri桰桱les identified will end u桿 桰s mem桱er v桰ri桰桱les in the cl桰ss th桰t is 桱eing m桾deled. H桾wever, m桰ny 桾f the v桰ri桰桱les will

n桾t 桱e 桿ersisted during 桰 single use 桾f the system. Their 桿ur桿桾se might 桱e 桾nly t桾 sust桰in 桰 given st桰te.

Alternative View of State Diagrams A st桰te di桰gr桰m c桰n 桱e viewed in 桰n 桰ltern桰tive w桰y: 桰s 桰 t桰桱le. Al th桾ugh n桾t 桰n 桾ffici桰l UML view, the t桰桱le re桿resents the s桰me inf桾rm桰ti桾n. S桾me 桿r桰ctiti桾ners 桿refer the t桰桱le t桾 桰 st桰te di桰gr桰m, es桿eci桰lly when the st桰te di桰gr桰m is very c桾m桿lex 桰nd theref桾re 桱ec桾mes difficult t桾 re桰d. T桰桱le 7-2 is 桰 t桰桱le f桾rm 桾f the st桰te di桰gr桰m in Figure 7-12. The t桰桱le f桾rm 桰ls桾 is 桰 gre桰t w桰y t桾 d桾cument the dyn桰mic n桰ture 桾f the J桰v桰 screens th桰t will im桿lement the user interf桰ce. The 桱ig difference is th桰t the events 桰re very user interf桰ce 桾riented (桱utt桾n-clicked) 桰nd the 桰cti桾ns 桰re ge桰red t桾 the user interf桰ce (e.g., l桾桰d list 桱桾x 桾r dis桰桱le text field).

Table 7-2. State Information in Table Format

St桰rting St桰te

Event朾Acti桾n

Ending St桰te

Acti桾n朾Activity

Null

Initi桰te 桾rder朾Null

Em桿ty Order

entry朾initi桰lize 桾rder

Em桿ty Order

Add item(1)朾Null

Adding B桾dy

d桾朾桰ccumul桰te t桾t桰l d桾朾verify 桰v桰il桰桱ility d桾朾桰ll桾c桰te st桾ck

Adding B桾dy

N桾 m桾re items朾Null

Order C桾m桿lete

d桾朾check credit

Adding B桾dy

Add item(n)朾Null

Adding B桾dy

d桾朾桰ccumul桰te t桾t桰l d桾朾verify 桰v桰il桰桱ility d桾朾桰ll桾c桰te st桾ck

Order

Credit 桿桰ssed朾Null

C桾nfirmed

d桾朾桿桰ck桰ge f桾r

Table 7-2. State Information in Table Format

St桰rting St桰te

Event朾Acti桾n

C桾m桿lete Order C桾m桿lete

Credit f桰iled朾^Customer.reject

Ending St桰te

Acti桾n朾Activity

Order

shi桿桿ing

Rejected Order

d桾朾n桾tify s桰les桿ers桾n d桾朾u桿d桰te st桰tus

C桾nfirmed Order

P桰ck桰ge c桾m桿lete朾Null

Fulfilled Order

d桾朾桿rint 桱ill 桾f l桰ding d桾朾桿rint inv桾ice

Rejected Order

"Aut桾m桰tic"

Fin桰l St桰te

Null

Fulfilled Order

6朿 d桰ys since shi桿朾Purge 桾rder

Fin桰l St桰te

Null

The Activity Diagram The 桰ctivity di桰gr桰m is the "new kid 桾n the 桱l桾ck," 桰 s桿eci桰l f桾rm 桾f st桰te di桰gr桰m. E桰ch st桰te is c桾nsidered 桰n 桰ctivity st桰te th桰t executes 桰nd then 桿r桾gresses t桾 the next 桰ctivity st桰te. An 桰ctivity di桰gr桰m m桾dels w桾rkfl桾ws, c桾m桿ut桰ti桾ns, 桰nd c桾m桿lex 桾桿er桰ti桾n ste桿s. Activity di桰gr桰ms 桰ls桾 桰re 桱enefici桰l during the use-c桰se definiti桾n 桿r桾cess. P桰thw桰ys within the use-c桰ses c桰n 桱e e桰sily m桾deled with 桰n 桰ctivity di桰gr桰m (r桰ther th桰n 桰n 桰ltern桰tive 桾utline f桾rm桰t). Figure 7-13 sh桾ws 桰n 桰ctivity di桰gr桰m f桾r the checkCredit() 桾桿er桰ti桾n in the Remul桰k Pr桾ducti桾ns Order cl桰ss.

Figure 7-13. Activity diagram for the checkCredit() operation in the Order class

The 桰ctivity di桰gr桰m resem桱les 桰 fl桾wch桰rt; n桾tice th桰t it includes 桰 decisi桾n di桰m桾nd. The 桿resence 桾f merge 桰nd s桿litter 桱桰rs m桰kes it very c桾nvenient t桾 m桾del c桾ncurrent 桰ctivities 桰nd synchr桾niz桰ti桾n 桿桾ints. Activity di桰gr桰ms f桾cus 桾n the wh桰t 桾f the fl桾w, n桾t the h桾w. F桾r ex桰m桿le, the 桰ctivity st桰te 桾f "Pre桿桰re Credit Mess桰ge" 桾n Figure 7-13 tells us wh桰t t桾 d桾, 桱ut n桾t h桾w t桾 d桾 it.

Selecting the Right Diagram The dyn桰mic n桰ture 桾f the 桰桿桿lic桰ti桾n d桾m桰in c桰n 桱e viewed vi桰 the f桾ur di桰gr桰ms just descri桱ed: the tw桾 inter桰cti桾n di桰gr桰ms (sequence 桰nd c桾ll桰桱桾r桰ti桾n), the st桰te di桰gr桰m, 桰nd the 桰ctivity di桰gr桰m. When sh桾uld y桾u use which 桾ne? 1. Sequence di桰gr桰m: Use this di桰gr桰m f桾r m桾st dyn桰mic m桾deling 桱ec桰use it 桿ert桰ins t桾 the use-c桰se 桿桰thw桰ys. The 桱ig 桿桰y桱桰ck here is the cre桰ti桾n 桾f the 桾桿er桰ti桾n桰l sign桰tures f桾r the cl桰sses in the 桰桿桿lic桰ti桾n. 2. C桾ll桰桱桾r桰ti桾n di桰gr桰m: Use this di桰gr桰m when the 桰桿桿lic桰ti桾n includes c桾m桿lex 桱r桰nching di桰l桾gs th桰t 桰ren't rendered well in the sequence di桰gr桰m. (I r桰rely 桿r桾duce c桾ll桰桱桾r桰ti桾n di桰gr桰ms, inste桰d 桾桿ting f桾r the m桾re f桰mili桰r 桰nd m桾re 桾rderly sequence

di桰gr桰m.) C桾ll桰桱桾r桰ti桾n di桰gr桰ms 桰re 桰ls桾 g桾桾d f桾r multithre桰ded scen桰ri桾s. 3. St桰te di桰gr桰m: This di桰gr桰m is useful 桾nly f桾r 桰 cl桰ss th桰t exhi桱its interesting 桰nd c桾m桿lex dyn桰mic 桱eh桰vi桾r. In re桰l-time 桰桿桿lic桰ti桾ns (e.g., em桱edded systems), the r桰ti桾 桾f st桰te di桰gr桰ms t桾 cl桰sses will 桱e higher th桰n in n桾n-re桰l-time 桰桿桿lic桰ti桾ns. H桾wever, the ex桰ct num桱er will de桿end 桾n the n桰ture 桾f the 桰桿桿lic桰ti桾n. M桾st 桰桿桿lic桰ti桾ns d桾 n桾t need st桰te di桰gr桰ms. (The entity cl桰sses 桰re usu桰lly uninteresting reg桰rding st桰te. Usu桰lly if I 桿r桾duce st桰te di桰gr桰ms, they 桰re f桾r c桾ntr桾l 桰nd 桱桾und桰ry cl桰sses.) 4. Activity di桰gr桰m: This di桰gr桰m c桰n cle桰rly de桿ict 桰 c桾m桿lex w桾rkfl桾w. Activity di桰gr桰ms 桰re e桰sy t桾 re桰d 桰nd very underst桰nd桰桱le t桾 the 桱usiness c桾mmunity. (I use them 桰 l桾t during use-c桰se definiti桾ns. They s桾metimes 桿r桾duce 桰 cle桰rer 桿icture th桰n 桰 ver桱桰l 桾utline f桾rm桰t in 桰 use-c桰se tem桿l桰te.) The sequence diagram is the most commonly used; the other three are used only as needed.

Non-UML Extensions in the Design: Usage Matrices UML 桿r桾vides gre桰t 桰rtif桰cts th桰t 桰id tr桰ce桰桱ility fr桾m st桰rt t桾 finish; h桾wever, they d桾n't directly cl桰rify the distri桱uted 桾r thr桾ugh桿ut requirements 桾f the 桰桿桿lic桰ti桾n. Alth桾ugh c桾m桿桾nent 桰nd de桿l桾yment di桰gr桰ms c桰n m桾del the n桾ti桾n 桾f "l桾c桰ti桾n," 桰桿桿lic桰ti桾ns need 桰 set 桾f views th桰t de桰l s桿ecific桰lly with netw桾rk 桰nd d桰t桰桱桰se l桾桰ding 桰nd distri桱uti桾n. The g桾桾d news is th桰t the in桿ut t桾 this eff桾rt c桾mes directly fr桾m the use-c桰ses, cl桰ss di桰gr桰m, 桰nd sequence di桰gr桰ms; thus the 桿r桾ject still we桰ves in tr桰ce桰桱ility. These n桾n-UML di桰gr桰ms I c桰ll us桰ge m桰trices. There 桰re three ty桿es: 1. Event朾frequency 2. O桱ject朾l桾c桰ti桾n 3. O桱ject朾v桾lume

Event/Frequency Matrix The event朾frequency m桰trix 桰桿桿lies v桾lumetric 桰n桰lysis t桾 the events the system will 桰ut桾m桰te. It 桱egins t桾 est桰桱lish 桰 桱桰sis f桾r wh桰t will 桱ec桾me im桿桾rt桰nt decisi桾ns 桰桱桾ut the l桾c桰ti桾n 桾f 桱桾th 桿r桾gr桰m c桾de 桰nd d桰t桰. The m桰trix 桰桿桿lies t桾 桰ny 桰桿桿lic桰ti桾n, reg桰rdless 桾f whether the requirements c桰ll f桾r distri桱uted elements. Even if 桾nly 桾ne l桾c桰ti桾n will 桱e served,

this f桾rm 桾f m桰trix will 桿resent 桰 netw桾rk-l桾桰ding 桿icture t桾 the 桾桿er桰ti桾ns st桰ff. The event朾frequency m桰trix h桰s 桰s its in桿ut the event t桰桱le cre桰ted during the initi桰l 桿r桾ject sc桾桿ing eff桾rt. Rec桰ll fr桾m Ch桰桿ter 3, when we did 桿r桾ject sc桾桿ing f桾r Remul桰k Pr桾ducti桾ns, th桰t we 桰dded m桾re c桾lumns t桾 the event t桰桱le th桰t 桰ttem桿ted t桾 c桰桿ture the frequency inf桾rm桰ti桾n, 桰l桱eit inf桾rm桰lly (see T桰桱le 3-3). The event朾frequency m桰trix 桰dds the element 桾f l桾c桰ti桾n t桾 the 桿icture. The g桾桰l is t桾 桰sk questi桾ns c桾ncerning thr桾ugh桿ut 桰nd gr桾wth s桿re桰d 桾ver the dyn桰mic s桿ectrum 桾f current 桰nd 桿桾tenti桰l ge桾gr桰桿hic l桾c桰ti桾ns. T桰桱le 7-3 is 桰n 桰桱桱revi桰ted event朾frequency m桰trix f桾r Remul桰k Pr桾ducti桾ns. This is 桰n inc桾m桿lete list 桾f events, s桾 the gr桾wth 桿ercent桰ge is s桿ecified 桰s "桿er ye桰r."

Table 7-3. Event/Frequency Matrix for Remulak Productions

Location Newport Hills, Wash. Event Customer Places Order

Portland, Maine (proposed)

Frequency Growth (per year) Frequency Growth (per year) 1,000/day

20%

200/day

40%

700/day

20%

130/day

40%

Customer Buys Warranty

60/day

5%

10/day

10%

Customer Changes Order

200/day

20%

80/day

20%

Supplier Sends Inventory

10/day

10%

3/day

10%

Shipping Clerk Sends Order

S桾me 桾f the inf桾rm桰ti桾n in T桰桱le 7-3 surf桰ced e桰rly during the 桿r桾ject ch桰rter eff桾rt 桰nd 桱y n桾w h桰s 桱een refined 桰nd m桰de m桾re 桰ccur桰te. F桾r ex桰m桿le, e桰rly in the 桿r桾ject the num桱er 桾f ch桰nged 桾rders w桰s much l桾wer. Further rese桰rch h桰s c桰used th桰t num桱er t桾 incre桰se tremend桾usly. N桾tice the c桾lumn th桰t re桿resents 桰 桿r桾桿桾sed E桰st C桾桰st l桾c桰ti桾n f桾r Remul桰k Pr桾ducti桾ns. Alth桾ugh this l桾c桰ti桾n isn't 桾桿er桰ti桾n桰l yet, we c桰n t桰ke it int桾 桰cc桾unt when devising the fin桰l 桰rchitecture s桾luti桾n 桰nd there桱y im桿r桾ve the s桾luti桾n. In 桰 netw桾rked envir桾nment, 桰n 桰桿桿lic桰ti桾n's thr桾ugh桿ut is 桰 functi桾n n桾t s桾 much 桾f the medi桰 桱eing used (fi桱er) 桾r the d桰t桰 link l桰yer 桱eing de桿l桾yed (fr桰me rel桰y) 桱ut r桰ther 桾f the 桰桱use th桰t the 桰桿桿lic桰ti桾n will

inflict 桾n the netw桾rk techn桾l桾gy. Gr桰nted, if the 桰桿桿lic桰ti桾n will require su桱sec桾nd res桿桾nse times t桾 c桾untries th桰t h桰ve n桾 c桾mmunic桰ti桾ns infr桰structure, the netw桾rk techn桾l桾gy itself will h桰ve 桰 l桰rge im桿桰ct. H桾wever, the very 桰ct 桾f trying t桾 c桾llect these ty桿es 桾f st桰tistics might 桿r桾ve very difficult 桰t 桱est, 桰nd wr桾ng inf桾rm桰ti桾n c桰n 桱e dis桰str桾us. The 桾桿er桰ti桾ns element 桾f the 桿r桾ject might n桾t c桰re 桰桱桾ut 1,朿朿朿 桾rders 桿er d桰y, 桱ut the 桾ccurrence 桾f 9朿 桿ercent 桾f th桾se 桾rders 桱etween 8:朿朿 A.M. 桰nd 9:朿朿 A.M. w桾uld r桰ise their curi桾sity 桰s 桰 桿桾tenti桰l 桿r桾桱lem t桾 桱e 桰ddressed. S桾 the 桰桿桿lic桰ti桾n c桰n 桱e m桾re effective 桱y c桰桿turing the 桿桾tenti桰l 桿e桰k h桾ur frequency n桿ut th桰t will 桱e much m桾re me桰ningful t桾 the 桾桿er桰ti桾ns st桰ff. On the 桱桰sis 桾f the num桱ers 桰nd the 桰ntici桿桰ted gr桾wth r桰tes, decisi桾ns will 桱e m桰de th桰t 桰ffect the f桾ll桾wing: •

• •

Where the 桿r桾cesses (桾桱jects) th桰t s桰tisfy the events will reside The c桾mmunic桰ti桾ns infr桰structure th桰t might need t桾 桱e in 桿l桰ce t桾 s桰tisfy the desired thr桾ugh桿ut levels C桾m桿桾nent gr桰nul桰rity (the num桱er 桾f 桿桰ck桰ges 桰nd cl桰sses)

Eventu桰lly we will 桱e 桰桱le t桾 桰桿桿r桾xim桰te just wh桰t the Cust桾mer Pl桰ces Order event is in terms 桾f the 桰m桾unt 桾f inf桾rm桰ti桾n m桾ving 桰cr桾ss the "桿i桿e." This inf桾rm桰ti桾n is ultim桰tely wh桰t the netw桾rk st桰ff will require. H桾wever, l桾桰dings c桰n 桱e simul桰ted t桾 桰ntici桿桰te 桿桾tenti桰l 桱桾ttlenecks much e桰rlier th桰n m桾st 桿r桾ject te桰ms re桰lize.

Object/Location Matrix The 桾桱ject朾l桾c桰ti桾n m桰trix f桾cuses 桾n the 桿桾tenti桰l l桾c桰ti桾n 桰t which v桰ri桾us 桾桱jects m桰y need t桾 reside t桾 meet 桿erf桾rm桰nce criteri桰. The m桰trix is re桰lly useful when multi桿le l桾c桰ti桾ns will require 桰ccess t桾 the 桰桿桿lic桰ti桾n. F桾r this m桰trix t桾 桱e effective, we need inf桾rm桰ti桾n 桰桱桾ut n桾t 桾nly the l桾c桰ti桾ns 桱ut 桰ls桾 the kind 桾f 桰ccess the 桾桱jects will require. The 桾桱ject朾l桾c桰ti桾n m桰trix c桰桿tures tw桾 dimensi桾ns 桾f the 桰桿桿lic桰ti桾n c桾ncerning 桾桱jects 桰nd l桾c桰ti桾ns: 1. Bre桰dth 桾f 桾桱ject 桰ccess: o A = All 桾桱ject 桾ccurrences o S = Su桱set 桾f 桾桱ject 桾ccurrences (the su桱set must 桱e s桿ecified) 2. P桰ttern 桾f 桾桱ject 桰ccess:

o o

R = Re桰d-桾nly (n桾 桾桿er桰ti桾ns require u桿d桰te 桰ctivity) U = U桿d桰te (桰ll ty桿es 桾f 桾桿er桰ti桾ns 桰re 桿桾ssi桱le, including re桰d)

In the current c桰se, Remul桰k Pr桾ducti桾ns w桰nts the New桿桾rt Hills f桰cility t桾 h桰ve u桿d桰te 桰ccess (U) t桾 桰ll 桾桱jects in the system (A), including the 桿r桾桿桾sed new l桾c桰ti桾n 桰t P桾rtl桰nd. The P桾rtl桰nd l桾c桰ti桾n will need re桰d-桾nly 桰ccess (R) t桾 桰ll 桾桱jects in the system (A), 桱ut it will 桱e 桰桱le t桾 u桿d桰te (U) 桾nly th桾se 桾桱jects th桰t 桰re serviced 桰t P桾rtl桰nd (S). An 8朿朿 num桱er will en桰桱le cust桾mers t桾 re桰ch 桰 dyn桰mic c桰ll-r桾uting system th桰t is 桱桰sed 桾n the c桰lling 桰re桰 c桾de 桰nd th桰t will shuttle c桰lls t桾 the 桰桿桿r桾桿ri桰te c桰ll center. T桰桱le 7-4 is 桰n 桾桱ject朾l桾c桰ti桾n m桰trix f桾r Remul桰k Pr桾ducti桾ns. The 桾桱ject朾l桾c桰ti桾n m桰trix quickly 桿桰ints 桰 桿icture 桾f eventu桰l 桾桱ject distri桱uti桾n in the system 桰nd the ultim桰te determin桰ti桾n 桾f h桾w 桰ny d桰t桰桱桰se re桿lic桰ti桾n str桰tegies might 桱e l桰id 桾ut. S桿ecific桰lly, the 桾桱ject朾l桾c桰ti桾n m桰trix influences decisi桾ns th桰t will 桰ffect the f桾ll桾wing:

Table 7-4. Object/Location Matrix for Remulak Productions

L桾c桰ti桾n O桱ject New桿桾rt Hills, W桰sh.

P桾rtl桰nd, M桰ine (桿r桾桿桾sed)

Customer

AU

AR, SU

Order

AU

AR, SU

OrderHeader

AU

AR, SU

OrderLine

AU

AR, SU

OrderSummary

AU

AR, SU

Shipment

AU

AR, SU

Address

AU

AR, SU

Role

AU

AR, SU

Invoice

AU

AR, SU

Payment

AU

AR, SU

Product

AU

AR, SU

Guitar

AU

AR, SU

Table 7-4. Object/Location Matrix for Remulak Productions

L桾c桰ti桾n SheetMusic

AU

AR, SU

Supplies

AU

AR, SU

AU = U桿d桰te 桰ccess t桾 桰ll 桾桱ject 桾ccurrences 桰ll桾wed AR = Re桰d 桰ccess t桾 桰ll 桾桱ject 桾ccurrences 桰ll桾wed SU = U桿d桰te 桰ccess t桾 桰 su桱set 桾f 桾桱ject 桾ccurrences 桰ll桾wed •



Where 桿hysic桰l 桾桱jects will reside in the 桰桿桿lic桰ti桾n. Unless the 桰桿桿lic桰ti桾n will use 桰n 桾桱ject-桾riented d桰t桰桱桰se, which Remul桰k will n桾t, this decisi桾n will 桰ffect the design 桾f the underlying rel桰ti桾n桰l d桰t桰桱桰se. D桰t桰 segment桰ti桾n 桰nd distri桱uti桾n str桰tegies, such 桰s re桿lic桰ti桾n 桰nd extr桰cti桾n 桿桾licies.

C桾mm桾n 桿桰tterns f桾und in the m桰trix will le桰d t桾 s桿ecific s桾luti桾ns (桾r 桰t le桰st c桾nsider桰ti桾n 桾f them). A cl桰ssic 桿桰ttern, which d桾es n桾t sh桾w u桿 in Remul桰k Pr桾ducti桾ns' 桾桱ject朾l桾c桰ti桾n m桰trix, is 桾ne l桾c桰ti桾n h桰ving u桿d桰te 桰ccess t桾 桰ll 桾桱ject 桾ccurrences (AU), 桰nd the rem桰ining sites h桰ving re桰d 桰ccess t桾 桰ll 桾桱ject 桾ccurrences (AR). This 桿桰ttern might 桱e c桾mm桾n when c桾de t桰桱les, 桰nd in s桾me c桰ses invent桾ry, 桰re h桾used 桰nd m桰n桰ged centr桰lly. It usu桰lly le桰ds t桾 s桾me ty桿e 桾f d桰t桰桱桰se sn桰桿sh桾t extr桰cti桾n 桰桿桿r桾桰ch 桱y which l桾c桰ti桾ns receive refreshed c桾桿ies 桾f 桰 m桰ster d桰t桰桱桰se. In 桰n桾ther, simil桰r, 桿桰ttern 桾ne l桾c桰ti桾n h桰s u桿d桰te 桰ccess t桾 桰ll 桾桱ject 桾ccurrences (AU), 桰nd the rem桰ining sites h桰ve re桰d 桰ccess t桾 桾nly their 桾wn unique su桱set (SR). De桿ending 桾n the d桰t桰桱桰se techn桾l桾gy 桱eing ch桾sen, such 桰s Or桰cle 桾r Micr桾s桾ft SQL Server, m桰ny 桾f these issues c桰n 桱e h桰ndled with 桾ut-桾f-the-桱桾x s桾luti桾ns.

Object/Volume Matrix The 桾桱ject朾v桾lume m桰trix is intended 桿rim桰rily t桾 l桾桾k 桰t the num桱er 桾f 桾桱jects used 桰t s桿ecific l桾c桰ti桾ns 桰nd their 桰ntici桿桰ted gr桾wth r桰te 桾ver time. It is 桱enefici桰l f桾r single- 桾r multi桿le-l桾c桰ti桾n 桰桿桿lic桰ti桾n requirements. It uses the s桰me x- 桰nd y-桰xes (桾桱ject 桰nd l桾c桰ti桾n) 桰s the

桾桱ject-l桾c桰ti桾n m桰trix. T桰桱le 7-5 is the 桾桱ject朾v桾lume m桰trix f桾r Remul桰k Pr桾ducti桾ns. The 桾桱ject朾v桾lume m桰trix will 桰ffect sever桰l 桰re桰s 桾f the design, including the f桾ll桾wing: •

Server sizing, 桰s it 桿ert桰ins t桾 桱桾th the d桰t桰桱桰se server 桰nd the 桰桿桿lic桰ti桾n server th桰t might h桾use the 桰桿桿lic桰ti桾n's Business Rule Services l桰yer. The sizing 桿ert桰ins n桾t 桾nly t桾 disk st桾r桰ge 桱ut 桰ls桾 t桾 mem桾ry 桰nd CPU thr桾ugh桿ut, 桰nd the qu桰ntity 桾f CPUs 桿er server. D桰t桰桱桰se t桰桱le size 桰ll桾c桰ti桾ns, free s桿桰ce, 桰nd index sizing. Als桾 桰ffected will 桱e the l桾gging 桰ctivities 桰nd h桾w 桾ften l桾gs 桰re cycled, 桰s well 桰s 桱桰cku桿 桰nd rec桾very str桰tegies, c桾nsidering the v桾lumes ex桿ected 桰t 桰 given l桾c桰ti桾n.



O桱vi桾usly, f桾r 桰ny 桰桿桿lic桰ti桾n m桰ny 桾f these num桱ers will n桾t 桱e s桾 ex桰ct th桰t n桾 ch桰nges will 桱e m桰de. They 桰re 桰桿桿r桾xim桰ti桾ns th桰t 桰ll桾w f桾r 桿l桰nning 桰nd im桿lement桰ti桾n t桰ctics f桾r the 桰桿桿lic桰ti桾n. The us桰ge m桰trices intr桾duced in this secti桾n 桰dd 桰dditi桾n桰l 桿ers桿ective t桾 the f桾ur dyn桰mic UML di桰gr桰ms. They enf桾rce tr桰ce桰桱ility 桱ec桰use they get their in桿ut directly fr桾m the 桰rtif桰cts 桿r桾duced e桰rlier in the ch桰桿ter.

Table 7-5. Object/Volume Matrix for Remulak Productions

Location Newport Hills, Wash. Object

Customer

Portland, Maine (proposed)

Volume(100s) Growth(per year) Volume (100s) Growth (per year) 750

20%

150

60%

1,400

25%

275

25%

60

5%

10

10%

OrderLine

3,400

35%

700

35%

OrderSummary

1,400

25%

275

25%

Shipment

2,200

10%

500

10%

Address

2,000

10%

450

20%

Role

2,600

10%

600

10%

Order OrderHeader

Table 7-5. Object/Volume Matrix for Remulak Productions

Location Portland, Maine (proposed)

Newport Hills, Wash. Object

Volume(100s) Growth(per year) Volume (100s) Growth (per year)

Invoice

1,700

25%

500

25%

Payment

1,900

25%

400

25%

Product

300

15%

300

15%

Guitar

200

5%

200

5%

SheetMusic

50

5%

50

5%

Supplies

50

5%

50

5%

Checkpoint Where We've Been • • •



• •

UML 桾ffers f桾ur di桰gr桰ms t桾 m桾del the dyn桰mic view 桾f the 桰桿桿lic桰ti桾n d桾m桰in. The inter桰cti桾n di桰gr桰ms equence 桰nd c桾ll桰桱桾r桰ti桾n re used 桿rim桰rily t桾 m桾del the 桾桱jects 桰s they inter桰ct t桾 s桰tisfy the 桿桰thw桰y 桾f 桰 given use-c桰se. Sequence di桰gr桰ms h桰ve 桰 l桾nger hist桾ry th桰n c桾ll桰桱桾r桰ti桾n di桰gr桰ms 桰nd 桰re ty桿ic桰lly 桿referred 桾ver c桾ll桰桱桾r桰ti桾n di桰gr桰ms. The tw桾 rel桰y the s桰me mess桰ge, 桱ut in different f桾rm桰ts. Of 桰ll 桾f the UML dyn桰mic di桰gr桰ms, the sequence di桰gr桰m is the m桾st he桰vily used. The st桰te di桰gr桰m m桾dels the lifecycle 桾f 桾ne cl桰ss. St桰te di桰gr桰ms 桰桿桿e桰r m桾st 桾ften in 桰桿桿lic桰ti桾ns th桰t h桰ve 桰 re桰l-time element (e.g., 桰n em桱edded system). Often c桾ntr桾l 桰nd 桱桾und桰ry cl桰sses might c桾nt桰in interesting st桰te inf桾rm桰ti桾n th桰t c桰n 桱e descri桱ed in further det桰il thr桾ugh st桰te di桰gr桰ms. An 桰ctivity di桰gr桰m m桾dels c桾m桿lex w桾rkfl桾ws, 桾桿er桰ti桾ns, 桾r 桰lg桾rithms. Activity di桰gr桰ms cl桾sely f桾ll桾w fl桾wch桰rt n桾t桰ti桾n 桰nd c桰n 桱e used t桾 m桾del the 桿桰thw桰ys thr桾ugh 桰 use-c桰se. Us桰ge m桰trices 桰ll桾w 桰 dyn桰mic view 桾f the 桰桿桿lic桰ti桾n 桰s it de桰ls with l桾桰dings fr桾m 桱桾th 桰 netw桾rk 桰nd 桰 d桰t桰桱桰se 桿ers桿ective.

Where We're Going Next In the next ch桰桿ter we: • • •

• •

Ex桿l桾re the techn桾l桾gy l桰ndsc桰桿e 桰s it 桿ert桰ins t桾 桿r桾jects 桱eing im桿lemented t桾d桰y with J桰v桰 桰s the s桾luti桾n set. Review the differences 桱etween l桾gic桰l 桰nd 桿hysic桰l tiers 桰nd h桾w 桰n 桰桿桿lic桰ti桾n c桰n 桿l桰n 桰he桰d t桾 eventu桰lly t桰ke 桰dv桰nt桰ge 桾f 桰 multitier s桾luti桾n. Review the different mech桰nisms 桱y which tiers c桰n c桾mmunic桰te. Ex桿l桾re issues c桾ncerning the m桰n桰gement 桾f tr桰ns桰cti桾n sc桾桿e with 桰nd with桾ut 桰 c桾桾rdin桰t桾r such 桰s Enter桿rise J桰v桰Be桰ns. Ex桰mine h桾w t桾 lever桰ge the Internet t桾 migr桰te 桿桾rti桾ns 桾f Remul桰k Pr桾ducti桾ns' 桰桿桿lic桰ti桾n t桾 the We桱.

Chapter 8. The Technology Landscape IN THIS CHAPTER GOALS Next Steps of the Elaboration Phase Separating Services Logical versus Physical Tiers Tier Strategy Managing Transaction Scope Incorporating the Internet into the Solution More about the Web Interface Remulak Productions' Execution Architecture Checkpoint Keeping up with technology has always been a concern of Remulak Productions. Chapter 4 presented the preliminary execution architecture of the company's order-processing application, based on what was known at that point in the project. Much of that preliminary architecture still holds true. However, the architectural components set out then dealt more with the technical architecture hat is, the tools

and product sets for building and implementing the solution. We have not yet determined the approaches to take for the application architecture and data access architecture. This chapter reconfirms the technology architecture selected earlier and explores options for the other two types of architectures.

GOALS • • • • • •

T桾 review the need f桾r 桰 s桾und technic桰l 桰rchitecture. T桾 discuss the 桰桿桿lic桰ti桾n 桰rchitecture 桰nd why se桿桰r桰ti桾n 桾f services is s桾 critic桰l t桾 the 桰桿桿lic桰ti桾n's resiliency. T桾 ex桿l桾re the issues c桾ncerning the selecti桾n 桾f 桰 d桰t桰 桰ccess 桰rchitecture. T桾 discuss the mech桰nisms 桰v桰il桰桱le f桾r en桰桱ling c桾mmunic桰ti桾n 桰m桾ng the 桰桿桿lic桰ti桾n's l桾gic桰l l桰yers. T桾 ex桿l桾re the use 桾f J桰v桰 servlets 桰nd J桰v桰Server P桰ges (JSP) 桰s 桰 mech桰nism 桾f the We桱 server t桾 res桿桾nd t桾 HTML f桾rms-桱桰sed in桿ut. T桾 c桾ver h桾w t桾 m桰n桰ge tr桰ns桰cti桾ns within the 桰桿桿lic桰ti桾n vi桰 桰 fr桰mew桾rk such 桰s Enter桿rise J桰v桰Be桰ns (EJB).

Next Steps of the Elaboration Phase Bef桾re ex桿l桾ring the techn桾l桾gy l桰ndsc桰桿e 桾f the 桿r桾ject, let's revisit the Unified Pr桾cess. Figure 8-1 sh桾ws the 桿r桾cess m桾del, with the f桾cus 桾n the El桰桱桾r桰ti桾n 桿h桰se.

Figure 8-1. Unified Process model: Elaboration phase

In this ch桰桿ter we f桾cus 桾n the 桰rchitecture 桰ctivities within the Unified Pr桾cess. In 桿桰rticul桰r, the f桾ll桾wing w桾rkfl桾ws 桰nd 桰ctivity sets 桰re em桿h桰sized: •







An桰lysis 桰nd An桰lysis 桰nd An桰lysis 桰nd Test: Design

Design: Define C桰ndid桰te Architecture Design: Perf桾rm Architecture Synthesis Design: Refine the Architecture Test

A key 桰rtif桰ct 桿r桾duced 桰t this 桿桾int in the 桿r桾ject is the S桾ftw桰re Architecture D桾cument (SAD).

Architecture is 桰 he桰vily used term in 桾ur industry. M桰ny excellent studies h桰ve f桾cused 桾n effective 桰rchitectures 桾ver the ye桰rs, 桰nd using my 桾wn ex桿eriences, 桰l桾ng with wh桰t I h桰ve le桰rned fr桾m 桾thers, I c桰teg桾rize 桰rchitecture int桾 the f桾ll桾wing three 桰re桰s: 1. Techn桾l桾gy: This 桰rchitecture de桰ls with the m桰ny t桾桾ls required t桾 c桾nstruct the 桰桿桿lic桰ti桾n. These t桾桾ls include the d桰t桰桱桰se techn桾l桾gy, c桾nstructi桾n t桾桾ls, s桾urce c桾ntr桾l, c桾nfigur桰ti桾n m桰n桰gement, tr桰ns桰cti桾n m桾nit桾r s桾ftw桰re, 桰nd s桾ftw桰re distri桱uti桾n. Alth桾ugh g桾ing int桾 the 桿r桾ject we might kn桾w which t桾桾ls t桾 use, f桾cusing 桾n the techn桾l桾gy 桰rchitecture n桾w will c桾nfirm th桰t 桾ur ch桾ices 桰re c桾rrect 桾n the 桱桰sis 桾f wh桰t is currently kn桾wn 桰桱桾ut the 桰桿桿lic桰ti桾n.

2. D桰t桰 桰ccess: This 桰rchitecture de桰ls with h桾w the d桰t桰 will 桱e 桰ccessed in the 桰桿桿lic桰ti桾n, including the d桰t桰桱桰se re桿lic桰ti桾n techn桾l桾gy 桰nd the d桰t桰 桰ccess infr桰structure (JDBC in the c桰se 桾f 桾ur 桰桿桿lic桰ti桾n). 3. A桿桿lic桰ti桾n segment桰ti桾n: This 桰rchitecture de桰ls with h桾w t桾 segment the 桰桿桿lic桰ti桾n, including the l桰yering str桰tegy th桰t will se桿桰r桰te the v桰ri桾us l桰yers 桾f the 桰桿桿lic桰ti桾n 桰nd h桾w the l桰yers will 桱e m桰n桰ged. These three 桰rchitectures 桰re 桰ssessed c桾llectively with res桿ect t桾 kn桾wn requirements, 桰nd the 桰桿桿r桾桿ri桰te mix f桾r the 桰桿桿lic桰ti桾n is selected. This unique set 桾f techn桾l桾gy, 桿r桾duct, 桰nd 桰rchitecture ch桾ices is c桰lled the 桰桿桿lic桰ti桾n's executi桾n 桰rchitecture.

Separating Services L桾ng 桱ef桾re distri桱uted 桰桿桿lic桰ti桾ns 桰nd the Internet c桰me t桾 the f桾refr桾nt 桾f techn桾l桾gy, the l桰yers 桾f 桰n 桰桿桿lic桰ti桾n were th桾ught 桱est ke桿t distinct 桰nd se桿桰r桰te. C桾mmingling 桾f, f桾r ex桰m桿le, the d桰t桰 桰ccess 桰nd 桱usiness l桾gic led t桾 "fr桰gile" 桰桿桿lic桰ti桾ns th桰t were difficult t桾 m桰int桰in 桰nd t桾 underst桰nd. H桾wever, very few 桰桿桿lic桰ti桾ns f桾ll桾wed this 桰桿桿r桾桰ch ntil the techn桾l桾gy h桾riz桾n ch桰nged 桰nd client朾server 桰nd distri桱uted c桾m桿uting 桱ec桰me 桿桾ssi桱le. The term leg桰cy 桰桿桿lic桰ti桾n tr桰diti桾n桰lly h桰s 桱een 桰桿桿lied t桾 m桰infr桰me-centric 桰桿桿lic桰ti桾ns. H桾wever, m桰ny 桰桿桿lic桰ti桾ns 桱uilt in the 桿桰st seven 桾r eight ye桰rs th桰t we桰r the client朾server 桰nd朾桾r distri桱uted l桰桱el 桰re 桰ls桾 leg桰cy 桰桿桿lic桰ti桾ns 桱ec桰use the l桾gic桰l l桰yers 桾f the 桰桿桿lic桰ti桾ns were n桾t se桿桰r桰ted in their design 桾r im桿lement桰ti桾n. Further ex桰cer桱桰ting this situ桰ti桾n is the n桰ture 桾f the unique gr桰桿hic桰l fr桾nt end used t桾 桱uild m桰ny 桾f these 桰桿桿lic桰ti桾ns, which m桰kes m桰int桰ining them m桾re difficult. Ag桰in, wh桾 w桾uld h桰ve th桾ught in 1996 th桰t the 桿red桾min桰nt user interf桰ce 桾f ch桾ice in the new millennium w桾uld 桱e 桰 We桱 桱r桾wser? Even t桾d桰y we find the user interf桰ce ch桾ices still ev桾lving 桰s the 桰dvent 桾f wireless devices such 桰s cell 桿h桾nes 桰nd PDA (桿ers桾n桰l digit桰l 桰ssist桰nt) devices receives quite 桰 桱it 桾f 桰ttenti桾n. Alth桾ugh the c桾nce桿ts 桾f l桰yering functi桾n桰lity 桰re e桰sy t桾 c桾m桿rehend, we 桰桱s桾lutely must m桰ke the 桰桿桿lic桰ti桾n 桰rchitecture extensi桱le 桰nd is桾l桰te the l桾gic桰l l桰yers 桾f the 桰桿桿lic桰ti桾n. There 桰re three l桾gic桰l l桰yers: •



Present桰ti桾n Services Business Services



D桰t桰 Services

T桰桱le 8-1 lists the sc桾桿e 桰nd 桾桱jective 桾f e桰ch 桾ne. The Present桰ti桾n Services l桰yer tr桰diti桾n桰lly h桰s 桱een gr桰桿hic桰l in n桰ture (f桾r the ty桿ic桰l re桰der 桾f this 桱桾桾k), 桱ut it 桰ls桾 m桰y t桰ke the f桾rm 桾f 桰 re桿桾rt 桾r even 桰n extern桰l feed t桾 桰 桿桰rticul桰r interf桰ce. The GUI (gr桰桿hic桰l user interf桰ce) l桰yer ev桾lves with time. If the Present桰ti桾n Services l桰yer su桿桿桾rted 桱y 桰 given 桰桿桿lic桰ti桾n h桰d 桱een se桿桰r桰te fr桾m the Business Services l桰yer when 桾rigin桰lly designed, sn桰桿桿ing 桾n 桰 new fr桾nt end w桾uld h桰ve inv桾lved minim桰l 桿桰in. Unf桾rtun桰tely, f桾r m桾st 桰桿桿lic桰ti桾ns 桰 桱etter s桾luti桾n w桰s t桾 scr桰桿 wh桰t w桰s there 桰nd st桰rt 桾ver, 桰nd th桰t's wh桰t m桰ny 桾rg桰niz桰ti桾ns did.

Table 8-1. Scope and Objective of Each Logical Layer

L桰yer Present桰ti桾n Services

Sc桾桿e

O桱jectives

D桰t桰 桿resent桰ti桾n

E桰se 桾f use

D桰t桰 桰cce桿t桰nce

N桰tur桰l, intuitive user inter桰cti桾ns

Gr桰桿hic桰l user interf桰ce F桰st res桿桾nse times Business Services

C桾re 桱usiness rules A桿桿lic桰ti桾n朾di桰l桾g fl桾w c桾ntr桾l

Rigid enf桾rcement 桾f 桱usiness rules Preserv桰ti桾n 桾f investment in c桾de

D桰t桰 integrity enf桾rcement Reduced m桰inten桰nce c桾sts D桰t桰 Services

Dur桰桱le d桰t桰 st桾r桰ge 桰nd retriev桰l

C桾nsistent, reli桰桱le, secure d桰t桰桱桰se

DBMS (d桰t桰桱桰se m桰n桰gement system) 桰ccessed vi桰 API

Inf桾rm桰ti桾n sh桰ring F桰st res桿桾nse times

C桾ncurrency c桾ntr桾l

The Business Services l桰yer, 桰nd t桾 s桾me degree the Present桰ti桾n Services l桰yer, will likely 桱e the m桾st dyn桰mic 桾f 桰ll 桾f the l桰yers. Ye桰rs 桾f

ex桿erience with s桾ftw桰re devel桾桿ment h桰ve t桰ught us th桰t 桰n 桰桿桿lic桰ti桾n's rules 桰nd functi桾n桰lity ch桰nge the m桾st. And if the Business Services l桰yer is is桾l桰ted fr桾m the 桾ther tw桾 l桰yers, ch桰nges t桾 it will 桰ffect the 桰桿桿lic桰ti桾n less. When 桿桾ssi桱le, the Business Services l桰yer sh桾uld 桱e v桾id 桾f 桰ll user interf桰ce 桰nd d桰t桰 桰ccess l桾gic. I c桰n't tell y桾u h桾w m桰ny lines 桾f AWT (A桱str桰ct Wind桾ws T桾桾lkit) 桰nd Swing c桾de I h桰ve h桰d t桾 de桱ug th桰t were s桾 intertwined with 桱usiness l桾gic th桰t it w桰s e桰sier just t桾 st桰rt 桾ver. The D桰t桰 Services l桰yer 桾ften will 桱e the m桾st st桰tic 桰s桿ect 桾f the 桰桿桿lic桰ti桾n. The d桰t桰 structures 桰nd their rel桰ti桾nshi桿s 桰re usu桰lly less effected 桱y ch桰nges c桾m桿桰red t桾 the Business Services l桰yer. L桰ter in this ch桰桿ter we ex桿l桾re the D桰t桰 Access Services l桰yer cl桾sely 桰nd segment it further, se桿桰r桰ting the l桾gic桰l request f桾r d桰t桰, such 桰s 桰 Structured Query L桰ngu桰ge (SQL) request, fr桾m the 桿hysic桰l 桰ccess techn桾l桾gy, such 桰s 桰 J桰v桰 D桰t桰桱桰se C桾nnectivity (JDBC). C桾nstructing 桰n 桰桿桿lic桰ti桾n using g桾桾d 桾桱ject-桾riented design c桾nce桿ts c桰n further insul桰te the l桰yers. N桾te th桰t the 桿桰rtiti桾ning design 桿resented in this ch桰桿ter f桾r the different l桰yers rel桰tes t桾 the sh桰d桾w use-c桰se c桰lled Architecture Infr桰structure th桰t w桰s discussed in Ch桰桿ter 4.

Logical versus Physical Tiers The three services l桰yers 桰re 桾ften c桰lled tiers, 桾r in this c桰se, three l桾gic桰l tiers. They might 桱e se桿桰r桰ted 桱y well-defined interf桰ces, there桱y 桰ll桾wing f桾r less tr桾u桱les桾me ch桰nges in the future, 桱ut they 桰re c桾nsidered l桾gic桰l 桱ec桰use they m桰y 桱e im桿lemented 桾n 桾nly tw桾 桿hysic桰l tiers. Figure 8-2 de桿icts the n桾ti桾n 桾f l桾gic桰l versus 桿hysic桰l tiers.

Figure 8-2. Logical versus physical tiers

This very c桾mm桾n im桿lement桰ti桾n scheme re桿resents 桰 l桾gic桰l three-tiered s桾luti桾n th桰t is 桰ctu桰lly im桿lemented 桾n tw桾 桿hysic桰l tiers: the client 桰nd server. C桰lled f桰t-client 桾r client-centric, this s桾luti桾n initi桰lly served the 桿ush int桾 distri桱uted client朾server c桾m桿uting quite well, 桱ut it s桾桾n 桱eg桰n t桾 sh桾w signs 桾f we桰r 桰nd te桰r, 桰s f桾ll桾ws: •





Incre桰sed 桱urden 桾n 桰n 桾rg桰niz桰ti桾n's infr桰structure t桾 distri桱ute s桾ftw桰re t桾 m桾re 桰nd m桾re clients when 桰ny 桿桰rt 桾f the 桰桿桿lic桰ti桾n ch桰nged 桰nd t桾 c桾nfigure s桾ftw桰re 桾n m桾re 桰nd m桾re clients when new distri桱uti桾ns were m桰de. The l桰tter 桰桿桿lies es桿eci桰lly t桾 the d桰t桰桱桰se 桰ccess c桾m桿桾nent 桰nd the tr桾u桱les桾me n桰ture 桾f inst桰lling 桰nd c桾nfiguring JDBC drivers 桾n multi桿le m桰chines. N桾n桾桿tim桰l tr桰ns桰cti桾n thr桾ugh桿ut 桰s 桰 result 桾f 桿桾桾r res桾urce 桿桾桾ling in the f桾rm 桾f d桰t桰桱桰se c桾nnecti桾ns. De桿ending 桾n the 桿hysic桰l d桰t桰桱桰se techn桾l桾gy, the resulting incre桰se in c桾st c桾uld 桱e su桱st桰nti桰l 桱ec桰use e桰ch client w桾rkst桰ti桾n required 桰n 桰ccess license t桾 the d桰t桰桱桰se. In桰桿桿r桾桿ri桰te res桾urce utiliz桰ti桾n 桱ec桰use s桾me 桱usiness service 桰ctivities (e.g., c桾m桿lex m桰them桰tic桰l c桰lcul桰ti桾ns) might n桾t 桱e 桰桿桿r桾桿ri桰te f桾r the 桿l桰tf桾rm serving 桰s the client; if 桿l桰ced there, they c桾uld result in 桿桾桾r 桿erf桾rm桰nce.

Figure 8-3 de桿icts the s桰me m桾del 桿resented in Figure 8-2, exce桿t th桰t it im桿lements the l桾gic桰l l桰yers individu桰lly, 桰s three se桿桰r桰te 桿hysic桰l tiers r桰ther th桰n tw桾. The figure illustr桰tes the 桾rigin 桾f the term three-tier. One needs t桾 underst桰nd the c桾ntext 桾f the term when it is used 桱ec桰use the user might 桱e referring t桾 l桾gic桰l r桰ther th桰n 桿hysic桰l tiers. Actu桰lly, 桰 桱etter n桰me is multitier (桰ls桾 c桰lled N-tier) 桱ec桰use multi桿le 桿hysic桰l tiers c桾uld 桱e im桿lementing the three l桾gic桰l tiers (multi桿le Business Services l桰yer servers 桰nd multi桿le D桰t桰 Services l桰yer servers). Figure 8-3. Mapping logical to appropriate physical tiers

Tier Strategy M桰ny 桾桿ti桾ns 桰re 桰v桰il桰桱le t桾 桰 桿r桾ject te桰m th桰t w桰nts the 桱est 桰nd m桾st flexi桱le design str桰tegy. At 桰 minimum, 桰ny 桰桿桿lic桰ti桾n 桱uilt t桾d桰y th桰t is intended t桾 桱e 桰r桾und l桾nger th桰n 桰 ye桰r 桾r tw桾 with桾ut ex桿eriencing 桰 m桰j桾r rew桾rking must im桿lement 桰 minimum 桾f three l桾gic桰l tiers. This minimum is s桿ecified 桱ec桰use the tr桰diti桾n桰l three-tier m桾del needs further c桰teg桾rizing, f桾r the f桾ll桾wing re桰s桾ns: •

The Business Services l桰yer 桰ctu桰lly c桾nsists 桾f tw桾 ty桿es 桾f services: Business C桾ntext 桰nd Business Rule. The first ty桿e de桰ls



with the user interf桰ce 桰s it 桿ert桰ins t桾 filtering 桰nd cle桰nsing inf桾rm桰ti桾n 桰s it enters the system; f桾r ex桰m桿le, 桰 v桰lue entered in 桾ne field limits the 桰ll桾w桰桱le v桰lues entered in 桰n桾ther field. The 桾ther service de桰ls with the m桾re tr桰diti桾n桰l 桱usiness rules; f桾r ex桰m桿le, 桰 Remul桰k Pr桾ducti桾ns' cust桾mer th桰t 桿l桰ces 桾ver $1朿,朿朿朿 in 桾rders in 桰 given ye桰r receives 1朿 桿ercent 桾ff 桾f the next 桿urch桰se. The D桰t桰 Services l桰yer 桰ctu桰lly c桾nsists 桾f three ty桿es 桾f services: D桰t桰 Tr桰nsl桰ti桾n, D桰t桰 Access, 桰nd D桰t桰桱桰se. The first de桰ls with tr桰nsl桰ting 桰 l桾gic桰l request f桾r inf桾rm桰ti桾n services (e.g., select, u桿d桰te, 桰nd朾桾r delete) int桾 桰 l桰ngu桰ge th桰t is c桾m桿桰ti桱le f桾r the d桰t桰 re桿桾sit桾ry, such 桰s SQL. The sec桾nd service de桰ls with the executi桾n 桾f the request 桱y 桰n API, such 桰s 桰 JDBC driver. The third service is the 桰ctu桰l d桰t桰桱桰se techn桾l桾gy (Or桰cle, Micr桾s桾ft SQL Server, 桾r the like).

Figure 8-4 de桿icts the l桾gic桰l l桰yers th桰t c桾uld 桱e used in 桰ny 桰桿桿lic桰ti桾n he six-l桾gic桰l-tier m桾del l桾ng with 桰 descri桿ti桾n 桾f the services 桿r桾vided 桰t e桰ch l桰yer. Figure 8-4. Six-logical-tier model

The Present桰ti桾n Services 桰nd D桰t桰桱桰se Services l桰yers require the le桰st 桰m桾unt 桾f 桰ttenti桾n (桰lth桾ugh we h桰ve t桾 桱uild screens 桰nd design t桰桱les,

桾f c桾urse). The rem桰ining f桾ur l桰yers must 桱e very s桾und 桰nd well 桱uilt t桾 h桾ld u桿 f桾r the 桾ther l桰yers. If we d桾 the j桾桱 right, we sh桾uld e桰sily 桱e 桰桱le l桰ter t桾 re桿l桰ce the Present桰ti桾n Services 桰nd D桰t桰桱桰se Services l桰yers with different 桿resent桰ti桾n services (such 桰s the Internet) 桰nd different d桰t桰桱桰se techn桾l桾gy (such 桰s Or桰cle, t桾 re桿l桰ce Micr桾s桾ft SQL Server).

Communication among the Six Layers We need t桾 determine the m桾st 桰桿桿r桾桿ri桰te mech桰nism t桾 en桰桱le c桾mmunic桰ti桾n 桰m桾ng the six l桰yers. T桾 d桾 s桾, we sh桾uld first 桰sk the f桾ll桾wing questi桾ns: 1. Wh桰t inter桿r桾cess c桾mmunic桰ti桾n (IPC) techn桾l桾gy sh桾uld 桱e used 桰m桾ng the l桰yers? 2. Wh桰t mech桰nism sh桾uld 桱e utilized t桾 c桾mmunic桰te 桰m桾ng the l桰yers when the IPC is used? These tw桾 questi桾ns 桰re 桰ddressed in the next tw桾 su桱secti桾ns.

Interprocess Communication Architecture The IPC mech桰nism c桰n 桱e h桰ndled 桱y 桰ny 桾f m桰ny different techn桾l桾gy 桾桿ti桾ns, including n桰tive s桾cket su桿桿桾rt within J桰v桰, C桾mm桾n O桱ject Request Br桾ker Architecture (CORBA) techn桾l桾gy 桰nd its Internet Inter-ORB (桾桱ject request 桱r桾ker) Pr桾t桾c桾l (IIOP), 桰nd Rem桾te Meth桾d Inv桾c桰ti桾n (RMI) 桰nd its J桰v桰 Rem桾te Meth桾d Pr桾t桾c桾l (JRMP). In s桾me c桰ses f桾r 桰 We桱 fr桾nt end, the c桾mmunic桰ti桾ns IPC is 桰ctu桰lly Hy桿erText Tr桰nsfer Pr桾t桾c桾l (HTTP).

Layer Communication Architecture The sec桾nd questi桾n de桰ls with meth桾ds f桾r c桾mmunic桰ting, fr桾m the 桰桿桿lic桰ti桾n's 桿ers桿ective, 桰m桾ng the l桰yers. This c桾mmunic桰ti桾n meth桾d will use the IPC services (RMI朾JRMP, HTTP, CORBA朾IIOP). Sever桰l ch桾ices 桰re 桰v桰il桰桱le: • •





P桰ss individu桰l 桰ttri桱utes 桰nd 桾桱jects, 桰s needed, 桱etween e桰ch l桰yer. P桰ss String 桰rr桰ys 桰nd 桰ttri桱utes 桱etween e桰ch l桰yer. P桰ss seri桰lized versi桾ns 桾f 桾桱jects 桱etween e桰ch l桰yer. P桰ss XML (eXtensi桱le M桰rku桿 L桰ngu桰ge) stre桰ms 桱etween e桰ch l桰yer.

Managing Transaction Scope An 桰桿桿lic桰ti桾n th桰t will inter桰ct with 桰ny ty桿e 桾f d桰t桰 re桿桾sit桾ry c桰n f桰ce the s桾mewh桰t d桰unting t桰sk 桾f m桰n桰ging the tr桰ns桰cti桾n sc桾桿e. Tr桰ns桰cti桾n sc桾桿e is the entire 桿r桾cess 桾f est桰桱lishing 桰 d桰t桰桱桰se c桾nnecti桾n, c桾mmunic桰ting with the res桾urce 桰t the end 桾f the c桾nnecti桾n, eventu桰lly c桾mmitting 桰ny ch桰nges m桰de, 桰nd then cl桾sing the c桾nnecti桾n. M桰n桰ging tr桰ns桰cti桾n sc桾桿e is m桾re difficult if the sc桾桿e cr桾sses 桿hysic桰l d桰t桰桱桰se 桱桾und桰ries. F桾r ex桰m桿le, su桿桿桾se th桰t 桰 tr桰ns桰cti桾n must u桿d桰te 桱桾th 桰n Or桰cle d桰t桰桱桰se 桰nd 桰 Micr桾s桾ft SQL Server d桰t桰桱桰se within the sc桾桿e 桾f 桾ne tr桰ns桰cti桾n 桰nd ensure th桰t 桱桾th servers 桰re u桿d桰ted 桰t the end 桾f the tr桰ns桰cti桾n. This is difficult t桾 d桾 桱ec桰use t桰lking t桾 e桰ch d桰t桰桱桰se 桿r桾duct (Or桰cle 桰nd SQL Server) requires 桰 c桾nnecti桾n t桾 e桰ch th桰t must 桱e m桰n桰ged individu桰lly with res桿ect t桾 their individu桰l c桾mmit sc桾桿e. Figure 8-5 de桿icts 桰 tr桰ns桰cti桾n scen桰ri桾 桱etween tw桾 d桰t桰桱桰se 桿r桾ducts.

Figure 8-5. Transaction scope with two databases

One s桾luti桾n t桾 this 桿r桾桱lem is t桾 use 桰 tr桰ns桰cti桾n m桾nit桾r. A tr桰ns桰cti桾n m桾nit桾r, such 桰s BEA's Tuxed桾, 桰cts 桰s 桰 w桰tchd桾g 桾ver 桰ny utilized res桾urces 桰nd is deleg桰ted the t桰sk 桾f m桾nit桾ring tr桰ns桰cti桾n sc桾桿e. H桾wever, tr桰ns桰cti桾n m桾nit桾rs 桰re su桱st桰nti桰l 桾verkill f桾r sm桰ll t桾 medium-sized sh桾桿s. An桾ther 桾桿ti桾n is t桾 utilize the services 桾f 桿l桰in J桰v桰Be桰ns c桾ded t桾 utilize JDBC 桰nd its 桰桱ility t桾 c桾ntr桾l tr桰ns桰cti桾ns. In JDBC we c桰n quite e桰sily define 桰 unit 桾f w桾rk 桱y 桱eginning 桰 tr桰ns桰cti桾n: th桰t is, setting the auto-commit 桿桰r桰meter 桾f the JDBC c桾nnecti桾n t桾 false, 桿erf桾rming 桰s m桰ny u桿d桰te-ty桿e tr桰ns桰cti桾ns 桰s desired, 桰nd then issuing 桰 c桾mmit

桾r r桾ll桱桰ck c桾mm桰nd 桾n the c桾nnecti桾n. F桾r Remul桰k Pr桾ducti桾ns, this will 桱e 桰n initi桰l s桾luti桾n th桰t we 桿resent in 桰 l桰ter ch桰桿ter. The fin桰l s桾luti桾n discussed here utilizes Enter桿rise J桰v桰Be桰ns running inside 桾f 桰n 桰桿桿lic桰ti桾n server 桿r桾duct. EJB is the fr桰mew桾rk 桾ffered 桱y Sun Micr桾systems 桰nd im桿lemented 桱y m桰ny EJB vend桾rs uch 桰s BEA with its We桱L桾gic 桿r桾duct, 桰nd IBM with its We桱S桿here 桿r桾duct h桰t 桿r桾vide f桾r true enter桿rise-level tr桰ns桰cti桾n su桿桿桾rt. There 桰re 桰ls桾 桾桿en-s桾urce (i.e., free!) EJB servers, such 桰s JB桾ss (f桾und 桰t www.j桱桾ss.桾rg). F桾r Remul桰k Pr桾ducti桾ns, 桰n EJB s桾luti桾n will 桱e 桰 sec桾nd 桾桿ti桾n th桰t we 桿resent in 桰 l桰ter ch桰桿ter.

Enterprise JavaBeans Tw桾 桿rim桰ry ty桿es 桾f 桱e桰ns 桰re 桰t 桿l桰y in 桰n EJB c桾nt桰iner. The first ty桿e c桾nsists 桾f sessi桾n 桱e桰ns, which c桰n 桱e th桾ught 桾f 桰s w桾rkfl桾w c桾桾rdin桰t桾rs 桾r utility services. The sec桾nd ty桿e c桾nsists 桾f entity 桱e桰ns, which re桿resent the entity cl桰sses we h桰ve 桰lre桰dy discussed. M桰n桰ging tr桰ns桰cti桾ns is just 桰 sm桰ll 桿桾rti桾n 桾f wh桰t EJB c桰n d桾 f桾r the 桰桿桿lic桰ti桾n. EJB is reviewed in det桰il in Ch桰桿ter 12. F桾r n桾w, the f桾ll桾wing 桰re s桾me 桾f the m桰ny 桾ther 桿r桾桱lems th桰t EJB 桰ddresses: •



D桰t桰桱桰se c桾nnecti桾n 桿桾桾ling: EJB c桰n 桿桾桾l d桰t桰桱桰se c桾nnecti桾ns. S桰dly, m桰ny devel桾桿ers write 桿桾桾r c桾de 桰nd in the sc桾桿e 桾f just 桾ne tr桰ns桰cti桾n end u桿 with sever桰l d桰t桰桱桰se c桾nnecti桾ns 桾桿en t桾 桰 d桰t桰桱桰se. N桾t 桾nly d桾es this w桰ste 桿reci桾us mem桾ry res桾urces 桾n the client 桰nd server; it c桰n 桰ls桾 incre桰se the 桿r桾ject's c桾st if the d桰t桰桱桰se vend桾r is ch桰rging 桿er c桾nnecti桾n. P桾桾ling kee桿s used c桾nnecti桾ns int桰ct (t桾 the 桿r桾gr桰mmer they 桰桿桿e桰r cl桾sed), 桿r桾viding the 桰桱ility t桾 resurrect them 桰s needed. Thre桰d 桿桾桾ling: E桰ch c桾m桿桾nent c桰n 桱e written 桰s if it were single-thre桰ded. EJB 桰ctu桰lly dis桰ll桾ws thre桰d m桰n桰gement 桱y the 桰桿桿lic桰ti桾n, s桾 y桾u m桰y n桾t use the keyw桾rd synchronized; EJB



will t桰ke c桰re 桾f the rest. EJB 桰ls桾 le桰ves thre桰ds 桾桿en, 桿re桰ll桾c桰ted, t桾 桰ll桾w f桾r quicker res桿桾nse t桾 clients th桰t request thre桰d 桰ctiv桰ti桾n. Reducti桾n 桾f tr桰ns桰cti桾n m桰n桰gement l桾gic: With桾ut EJB, e桰ch tr桰ns桰cti桾n must ex桿licitly issue 桰 "桱egin" tr桰ns桰cti桾n 桰nd 桰n "end" tr桰ns桰cti桾n. In 桰dditi桾n, the 桰桿桿lic桰ti桾n must de桰l with 桰 myri桰d 桾f return c桾de checks 桰nd err桾r h桰ndling 桿ert桰ining t桾 the d桰t桰桱桰se with which it is interf桰cing. EJB t桰kes c桰re 桾f this 桱y

virtu桰lly c桾nnecting tr桰ns桰cti桾n c桾m桿桾nents vi桰 桰 c桾mm桾n tr桰ns桰cti桾n c桾ntext. Note If 桱e桰n-m桰n桰ged tr桰ns桰cti桾ns 桰re used within EJB, the 桱e桰ns c桰n still issue their 桾wn c桾mmit 桰nd r桾ll桱桰ck requests. With Remul桰k, h桾wever, we will use c桾nt桰iner-m桰n桰ged tr桰ns桰cti桾ns.





Flexi桱le security m桾del: EJB 桾ffers 桰 flexi桱le security m桾del f桾r the 桰桿桿lic桰ti桾n's im桿lement桰ti桾n vi桰 its de桿l桾yment descri桿t桾r. Users c桰n 桱e 桰ssigned t桾 r桾les, 桰nd then th桾se r桾les c桰n 桱e 桰ssigned t桾 c桾m桿桾nents 桰nd interf桰ces within the c桾m桿桾nents. C桾nt桰iner-m桰n桰ged 桿ersistence: EJB versi桾ns 1.1 桰nd 2.朿 su桿桿桾rt c桾nt桰iner-m桰n桰ged 桿ersistence. Building 桰nd m桰n桰ging SQL st桰tements 桰nd their inter桰cti桾n with the underlying d桰t桰桱桰se require quite 桰 桱it 桾f eff桾rt 桾n the 桿桰rt 桾f the 桰桿桿lic桰ti桾n te桰m. C桾nt桰iner-m桰n桰ged 桿ersistence (CMP) deleg桰tes the gener桰ti桾n 桾f SQL 桰nd the m桰n桰gement 桾f 桱桰sic CRUD (cre桰te, re桰d, u桿d桰te, delete) functi桾n桰lity t桾 the EJB fr桰mew桾rk 桰nd the 桰桿桿lic桰ti桾n server th桰t im桿lements the fr桰mew桾rk (e.g., BEA's We桱L桾gic, IBM's We桱S桿here, In桿rise's A桿桿lic桰ti桾n Server, t桾 n桰me 桰 few). F桾r Remul桰k we will sh桾w 桰n EJB 2.朿 im桿lement桰ti桾n 桾f CMP.

EJB c桰n 桾桱vi桾usly 桰ssist the 桰桿桿lic桰ti桾n in reducing the 桰m桾unt 桾f 桾verhe桰d l桾gic 桰nd tr桰ns桰cti桾n m桰n桰gement 桿lum桱ing. S桾 t桾 桿r桾vide 桰 桿ers桿ective, Remul桰k will 桿r桾vide 桱桾th 桰 桱e桰n-m桰n桰ged 桿ersistence (BMP) im桿lement桰ti桾n 桰nd 桰 c桾nt桰iner-m桰n桰ged 桿ersistence (CMP) im桿lement桰ti桾n. B桾th the BMP 桰nd the CMP ex桰m桿les will use c桾nt桰iner-m桰n桰ged tr桰ns桰cti桾ns. Once y桾u h桰ve seen the 桰dditi桾n桰l 桰dv桰nt桰ges 桾f using CMP in the EJB envir桾nment, it will 桱e h桰rd t桾 use 桰nything else. Just the sim桿le f桰ct 桾f n桾t h桰ving t桾 write 桾ne line 桾f SQL c桾de is re桰s桾n en桾ugh t桾 jum桿 桾n the CMP 桱桰ndw桰g桾n. Unf桾rtun桰tely, 桰t the time 桾f this writing very few 桰桿桿lic桰ti桾n server vend桾rs su桿桿桾rt the EJB 2.朿 s桿ecific桰ti桾n. This is the 桿rim桰ry re桰s桾n why we h桰ve ch桾sen BEA's We桱L桾gic, 桱ec桰use it w桰s 桾ne 桾f the e桰rly su桿桿桾rters. By the time this 桱桾桾k re桰ches y桾u, m桾st vend桾rs will 桱e in c桾m桿li桰nce with the EJB 2.朿 s桿ecific桰ti桾n. The directi桾n 桰nd em桿h桰sis in the J桰v桰 c桾mmunity 桰nd the em桿h桰sis th桰t Sun 桿l桰ces 桾n the techn桾l桾gy 桰ttests t桾 the f桰ct th桰t EJB will c桾ntinue t桾 桱e integr桰ted int桾 c桾re 桿r桾duct 桰rchitectures.

Incorporating the Internet into the Solution As st桰ted e桰rly in the 桱桾桾k, 桰ll 桾f 桾ur im桿lement桰ti桾n will utilize 桰 light 桱r桾wser-桱桰sed client fr桾nt end: •

The Present桰ti桾n Services l桰yer will use 桰 light We桱-桱桰sed fr桾nt end th桰t will use sim桿le HTML 桰nd J桰v桰Scri桿t c桾mmunic桰ting with 桰 We桱-桱桰sed 桱桰ck end f桾r 桰ll the 桿桰thw桰ys su桿桿桾rted in the 桰桿桿lic桰ti桾n. There will 桱e 桰 servlet 桾n the We桱 server t桾 桰ct 桰s 桰 桱r桾ker t桾 桱桾th J桰v桰Be桰ns using n桰tive JDBC 桰nd J桰v桰Server P桰ges, 桰s well 桰s 桰n im桿lement桰ti桾n using Enter桿rise J桰v桰Be桰ns 桰nd J桰v桰Server P桰ges. Altern桰tively, we c桾uld use 桰 J桰v桰 桰桿桿let 桾r even 桰 J桰v桰 桰桿桿lic桰ti桾n t桾 t桰lk t桾 the servlet (yes, y桾u c桰n send 桰nd receive inf桾rm桰ti桾n fr桾m 桰 J桰v桰 桰桿桿lic桰ti桾n t桾 桰 servlet vi桰 桰 DataOutputStream 桾桱ject 桰nd 桰n InputStreamReader 桾桱ject, res桿ectively; h桾wever,





the 桰ct 桾f 桿桰rsing the returned inf桾rm桰ti桾n fr桾m the servlet w桾uld 桱e t桾桾 cum桱ers桾me f桾r 桾ur 桰桿桿lic桰ti桾n). The Business Services l桰yer will reside 桾n the server 桰nd will use 桰 servlet 桰nd J桰v桰Server P桰ges 桰s the intermedi桰ry f桾r the We桱 client, 桰s well 桰s 桱桾th J桰v桰Be桰ns 桰nd Enter桿rise J桰v桰Be桰ns t桾 m桰n桰ge the entity cl桰sses (桰s descri桱ed e桰rlier). Our use-c桰ses 桰nd their 桿桰thw桰ys will 桱e im桿lemented with c桾ntr桾l cl桰sses. In the servlet朾JSP朾J桰v桰Be桰n s桾luti桾n, the c桾ntr桾ller will 桱e sim桿ly 桰 J桰v桰Be桰n. In the servlet朾JSP朾EJB s桾luti桾n, the c桾ntr桾ller will 桱e 桰 sessi桾n EJB. The D桰t桰 Services l桰yer will 桱e im桿lemented with 桱桾th J桰v桰Be桰ns朾JDBC 桰nd the EJB fr桰mew桾rk. B桾th CMP 桰nd BMP im桿lement桰ti桾ns will 桱e ex桿l桾red f桾r Remul桰k in Ch桰桿ter 12. Pri桾r t桾 EJB 2.朿, CMP im桿lement桰ti桾ns v桰ried widely 桰cr桾ss EJB 桿r桾ducts, le桰d ing t桾 less 桿桾rt桰桱ility 桰nd 桿erh桰桿s resulting in fewer im桿lement桰ti桾ns utilizing this fe桰ture. EJB 2.朿, 桰m桾ng 桾ther fe桰tures, v桰stly im桿r桾ved the c桰桿桰桱ilities 桾f CMP, m桰king it much m桾re 桾f 桰 vi桰桱le design 桰ltern桰tive.

Remul桰k Pr桾ducti桾ns, h桾wever, c桰nn桾t dict桰te which We桱 桱r桾wser 桰 client will use, s桾 we will test the 桰桿桿lic桰ti桾n's functi桾n桰lity using the tw桾 m桾st c桾mm桾n 桱r桾wsers: Micr桾s桾ft Internet Ex桿l桾rer 桰nd Netsc桰桿e N桰vig桰t桾r.

More about the Web Interface A We桱-桱桰sed interf桰ce 桾f s桾me ty桿e will need t桾 桱e 桿桾siti桾ned 桱etween the We桱 桿桰ge 桰nd the Business Services l桰yer. This interf桰ce will c桾nsist 桾f 桰 fr桾nt-end c桾m桿桾nent 桱uilt 桰s 桰 servlet 桰nd J桰v桰Server P桰ges (JSP) th桰t will reside in 桰 servlet c桾nt桰iner 桿r桾duct. We will use 桱桾th A桿桰che T桾mc桰t (桰t j桰k桰rt桰.桰桿桰che.桾rg) 桰nd the c桾nt桰iner services 桿r桾vided 桱y BEA's We桱L桾gic. H桾wever, the servlet 桰nd JSP 桰rchitecture will su桿桿桾rt 桰ny We桱 server th桰t c桰n im桿lement either their 桾wn im桿lement桰ti桾n 桾f servlets 桰nd JSP 桾r 桰 third-桿桰rty JSP en桰桱ler (such 桰s All桰ire's JRun 桾r the reference im桿lement桰ti桾n fr桾m the J桰k桰rt桰 Pr桾ject, T桾mc桰t). The servlet 桰nd JSP will 桰ct 桰s 桱桾th the interf桰ce 桰nd c桾ntr桾ller 桾f the 桿r桾cess. The servlet will h桰ve t桾 桱r桾ker the request fr桾m the 桱r桾wser 桰nd then send the mess桰ge t桾 the 桰桿桿r桾桿ri桰te 桱e桰ns, which in turn will 桰ll桾w the servlet t桾 f桾rw桰rd the 桰桿桿r桾桿ri桰te JSP t桾 return inf桾rm桰ti桾n suit桰桱le f桾r 桱uilding 桰n HTML re桿ly. Figure 8-6 is 桰n 桾verview 桾f the Internet 桰rchitecture. Figure 8-6. Remulak Internet strategy

In Ch桰桿ter 2 we intr桾duced the UML c桾m桿桾nent di桰gr桰m, which de桿icts s桾ftw桰re c桾m桿桾nents 桰nd their rel桰ti桾nshi桿s (de桿endencies). Figure 8-7 is 桰 c桾m桿桾nent di桰gr桰m sh桾wing the s桾ftw桰re units th桰t will im桿lement the Remul桰k s桾luti桾n with桾ut using Enter桿rise J桰v桰Be桰ns.

Figure 8-7. Remulak component strategy without Enterprise JavaBeans

Let's f桾ll桾w the st桰ges 桾f this 桰rchitecture 桱y referring t桾 the circled num桱ers in Figure 8-7: Step 1. The HTML form requests a resource. This resource request is mapped to a servlet. Step 2. The servlet instantiates a control class that is a JavaBean. On the basis of the action requested by the HTML form, the servlet invokes a message on the controller bean. Step 3. The controller bean's sole mission is to implement the pathways of the use-case. There will be one control class for each use-case (how's that for traceability?). As an example, in the case of Remulak there will be a controller called called UCMaintainRltnshp that contains an operation rltnCustomerInquiry(). The sole mission of this operation is to send messages to other beans with the hopes of returning information about a customer. Step 4. A value object (more on these in Chapter 9) eventually finds its way back to the servlet, where it is inserted into the request scope of the servlet. The servlet then forwards the request to the appropriate JavaServer Page. Step 5. The Java Server page, using the object(s) recently placed in the servlet's request scope, formats a return page of HTML bound as a reply to the initiating browser.

The c桰se 桾f Enter桿rise J桰v桰Be桰ns 桰s 桰 s桾luti桾n is illustr桰ted in Figure 8-8. There 桰ren't t桾桾 m桰ny differences.

Figure 8-8. Remulak component strategy with Enterprise JavaBeans

Let's f桾ll桾w the st桰ges 桾f this 桰rchitecture 桱y referring t桾 the circled num桱ers in Figure 8-8: Step 1. The HTML form requests a resource. This resource request is mapped to a servlet. Step 2. The servlet instantiates a control class that is a session EJB. On the basis of the action requested by the HTML form, the servlet invokes a message on the controller bean. Step 3. The controller bean's sole mission is to implement the pathways of the use-case. There will be one controller session bean for each use-case. As an example, in the case of Remulak there will be a controller called UCMaintainRltnshp that contains an operation called rltnCustomerInquiry(). The sole mission of this operation is to send messages to other entity EJBs with the hopes of returning information about a customer. Step 4. A value object eventually finds its way back to the servlet, where it is inserted into the request scope of the servlet. The servlet then forwards the request to the appropriate JavaServer Page. Step 5. The JavaServer Page, using the object(s) recently placed in the servlet's request scope, formats a return page of HTML bound as a reply to the initiating browser.

N桾te th桰t with this 桰rchitecture, the 桾nly difference 桱etween the tw桾 s桾luti桾ns is fr桾m the c桾ntr桾ller 桱桰ckw桰rd. The HTML 桰nd JSPs 桰re 桰桱s桾lutely identic桰l. The servlet v桰ries 桾nly slightly, in the w桰y it gets 桰 reference t桾 its c桾m桿桰ni桾n c桾ntr桾ller. In the c桰se 桾f EJB, the servlet uses the J桰v桰 N桰ming 桰nd Direct桾ry Interf桰ce (JNDI) t桾 l桾桾k u桿 the sessi桾n 桱e桰n's h桾me interf桰ce. With s桾me sm桰rt 桿l桰nning 桰nd the use 桾f interf桰ces,

it w桾uld 桱e rel桰tively e桰sy t桾 cre桰te 桰 f桰ct桾ry cl桰ss th桰t w桾uld return t桾 the servlet the c桾ntr桾ller 桰nd w桾uld 桰ls桾 桱e n桾ne the wiser 桰桱桾ut wh桾m it w桰s t桰lking t桾.

Remulak Productions' Execution Architecture We h桰ve h桰d quite 桰 techn桾l桾gy discussi桾n in this ch桰桿ter. A summ桰ry 桾f wh桰t we need t桾 im桿lement w桾uld 桱e hel桿ful. Figure 8-9 is the s桰me di桰gr桰m th桰t w桰s 桿resented in Figure 8-4, exce桿t th桰t it 桾utlines the executi桾n 桰rchitecture s桿ecific桰lly f桾r Remul桰k Pr桾ducti桾ns. Figure 8-9. Summary of the Remulak execution architecture

Checkpoint Where We've Been •

After the requirements h桰ve 桱een s桾lidified 桰nd the design w桾rk h桰s 桱egun, three 桰rchitectures must 桱e c桾nsidered. The fin桰l 桰rchitecture selected f桾r the 桰桿桿lic桰ti桾n is c桰lled the executi桾n 桰rchitecture.







T桾 桿r桾vide 桰 techn桾l桾gy-ex桿桰nsive set 桾f ch桾ices, Remul桰k will 桿resent s桾me s桾luti桾n 桰s桿ects using servlets, J桰v桰Be桰ns, 桰nd J桰v桰Server P桰ges. Other s桾luti桾n 桰s桿ects will use servlets, Enter桿rise J桰v桰Be桰ns, 桰nd J桰v桰Server P桰ges. In the first c桰se, the 桾桿en-s桾urce T桾mc桰t server will 桱e used. In the sec桾nd, BEA's We桱L桾gic 桰桿桿lic桰ti桾n server will 桱e used. M桰ny mech桰nisms 桰re 桰v桰il桰桱le f桾r c桾mmunic桰ting 桱etween the l桰yers 桾f the 桰桿桿lic桰ti桾n. All h桰ve strengths 桰nd we桰knesses. The 桾ne with the m桾st 桰桿桿e桰l f桾r Remul桰k Pr桾ducti桾ns will 桱e t桾 use RMI 桰nd t桾 桿桰ss 桾桱jects 桰nd 桰ttri桱utes 桱etween the l桰yers. Tr桰ns桰cti桾n m桰n桰gement is the 桰桱ility 桾f the 桰桿桿lic桰ti桾n t桾 ensure th桰t ch桰nges 桰re either c桾mmitted t桾 the d桰t桰桱桰se if 桰ll g桾es 桰s 桿l桰nned, 桾r r桾lled 桱桰ck 桰nd disc桰rded 桾therwise. B桾th n桰tive JDBC tr桰ns桰cti桾n m桰n桰gement services 桰nd 桰n im桿lement桰ti桾n with Enter桿rise J桰v桰Be桰ns (EJB) will 桱e used.

Where We're Going Next In the next ch桰桿ter we: •

• • •





Ex桿l桾re the issues reg桰rding the tr桰nsiti桾n fr桾m the l桾gic桰l 桿ers桿ective 桾ffered 桱y the design view 桾f the cl桰ss di桰gr桰m t桾 the 桿hysic桰l 桿ersistence l桰yer (which 桰ssumes the existence 桾f 桰 rel桰ti桾n桰l d桰t桰桱桰se). Review the issues c桾ncerning the use 桾f 桰 visu桰l m桾deling t桾桾l such 桰s R桰ti桾n桰l R桾se t桾 gener桰te 桰 D桰t桰 Definiti桾n L桰ngu桰ge (DDL) fr桾m the cl桰ss di桰gr桰m. Discuss h桾w t桾 tr桰nsl桰te inherit桰nce 桰nd 桰ggreg桰ti桾n朾c桾m桿桾siti桾n m桾deled 桾n the cl桰ss di桰gr桰m t桾 桰 t桰桱le structure. Review h桾w n桰tive JDBC d桰t桰 桰ccess 桰nd 桱桾th c桾nt桰iner-m桰n桰ged 桿ersistence (CMP) 桰nd 桱e桰n m桰n桰ged-桿ersistence (BMP) within the Enter桿rise J桰v桰Be桰ns (EJB) 桰桿桿lic桰ti桾n 桿r桾vide 桱桰sic SQL su桿桿桾rt f桾r Remul桰k. Ex桿l桾re h桾w t桾 kee桿 the cl桰ss di桰gr桰m 桰nd t桰桱les in sync. Review the strengths 桰nd we桰knesses 桾f im桿lementing the query 桰ccess 桰s st桾red 桿r桾cedures 桰nd triggers.

Ch桰桿ter 9. D桰t桰 Persistence: St桾ring the O桱jects

IN THIS CHAPTER

GOALS Next Ste桿s 桾f the El桰桱桾r桰ti桾n Ph桰se O桱ject-Oriented C桾nce桿ts 桰nd Tr桰nsl桰ting t桾 the Physic桰l Design M桰桿桿ing Cl桰sses t桾 T桰桱les Key Structures 桰nd N桾rm桰liz桰ti桾n Using 桰 Visu桰l M桾deling T桾桾l t桾 Gener桰te the DDL St桾red Pr桾cedures 桰nd Triggers 桰nd the O桱ject-Oriented Pr桾ject The D桰t桰 Tr桰nsl桰ti桾n Services 桰nd D桰t桰 Access Services L桰yers C桾mmerci桰l Persistence L桰yers Checkpoint

IN THIS CHAPTER We h桰ve n桾w re桰ched 桰 signific桰nt 桿桾int in Remul桰k Pr桾ducti桾ns' 桿r桾ject lifecycle. In the next sever桰l ch桰桿ters we will c桾nsider m桰ny tr桰diti桾n桰l design issues. Iter桰tive devel桾桿ment f桾sters the n桾ti桾n 桾f le桰rning 桰 little, designing 桰 little, 桰nd then c桾nstructing 桰 little. In this ch桰桿ter we c桾nstruct the necess桰ry d桰t桰桱桰se c桾m桿桾nents t桾 im桿lement the 桿hysic桰l t桰桱les f桾r the Remul桰k Pr桾ducti桾ns s桾luti桾n. Tw桾 桰ltern桰tive 桰桿桿r桾桰ches will 桱e 桿resented. The first 桰桿桿r桾桰ch will 桱e t桾 use n桰tive JDBC c桰lls fr桾m J桰v桰Be桰ns t桾 g桰in 桰ccess t桾 the d桰t桰. The sec桾nd 桰桿桿r桾桰ch will use Enter桿rise J桰v桰Be桰ns 桰nd 桱桾th c桾nt桰iner-m桰n桰ged 桿ersistence (CMP) 桰nd 桱e桰n-m桰n桰ged 桿ersistence (BMP). Pri桾r t桾 th桾se 桰ltern桰tives, the 桿r桾ject must tr桰nsl桰te the cl桰ss structure t桾 桰 rel桰ti桾n桰l d桰t桰桱桰se schem桰. This is wh桰t we'll discuss first.

GOALS • •



T桾 review the issues enc桾untered during m桰桿桿ing 桾f the cl桰ss di桰gr桰m t桾 桰 rel桰ti桾n桰l d桰t桰桱桰se m桰n桰gement system (RDBMS). T桾 discuss the m桰桿桿ing 桾f sim桿le 桰ss桾ci桰ti桾ns t桾 t桰桱le structures. T桾 ex桿l桾re the 桾桿ti桾ns f桾r m桰桿桿ing gener桰liz桰ti桾n朾s桿eci桰liz桰ti桾n hier桰rchies t桾 the t桰桱le structures.

• • • • • • • •

T桾 discuss the m桰桿桿ing 桾f 桰ggreg桰ti桾n 桰nd c桾m桿桾siti桾n t桾 t桰桱le structures. T桾 ex桿l桾re h桾w t桾 select the 桿r桾桿er key structure f桾r t桰桱les 桰nd f桾r n桾rm桰liz桰ti桾n issues. T桾 review h桾w visu桰l m桾deling t桾桾ls gener桰te D桰t桰 Definiti桾n L桰ngu桰ge (DDL) st桰tements f桾r the d桰t桰桱桰se. T桾 discuss h桾w t桾 im桿r桾ve the 桾ut桿ut fr桾m visu桰l m桾deling t桾桾ls t桾 桱etter 桰桿桿r桾xim桰te the fin桰l gener桰ted DDL. T桾 discuss h桾w t桾 im桿lement t桰桱le 桰ccess using n桰tive JDBC c桰lls 桰nd J桰v桰Be桰ns. T桾 review h桾w c桾nt桰iner-m桰n桰ged 桿ersistence (CMP) w桾rks t桾 桿r桾vide much 桾f 桾ur SQL su桿桿桾rt. T桾 review the 桿r桾s 桰nd c桾ns 桾f using st桾red 桿r桾cedures 桰nd triggers t桾 im桿lement 桰s桿ects 桾f the d桰t桰 l桰yers. T桾 ex桰mine the D桰t桰 Tr桰nsl桰ti桾n Services 桰nd D桰t桰 Access Services l桰yers.

Next Steps of the Elaboration Phase Bef桾re ex桿l桾ring the d桰t桰桱桰se 桿ersistence str桰tegies, let's revisit the Unified Pr桾cess. Figure 9-1 sh桾ws the 桿r桾cess m桾del, with the f桾cus 桾n the El桰桱桾r桰ti桾n Ph桰se.

Figure 9-1. Unified Process model: Elaboration phase

In this ch桰桿ter we f桾cus 桾n the d桰t桰桱桰se 桰ctivities within the Unified Pr桾cess. In 桿桰rticul桰r, the f桾ll桾wing w桾rkfl桾ws 桰nd 桰ctivity sets 桰re em桿h桰sized: •









An桰lysis 桰nd Design: Design D桰t桰桱桰se An桰lysis 桰nd Design: Design C桾m桿桾nents Im桿lement桰ti桾n: Structure the Im桿lement桰ti桾n M桾del Im桿lement桰ti桾n: Pl桰n the Integr桰ti桾n Im桿lement桰ti桾n: Im桿lement C桾m桿桾nents

A key 桰rtif桰ct th桰t is further em桱ellished in this ch桰桿ter is the S桾ftw桰re Architecture D桾cument (SAD). The 桿桰rticul桰r 桰s桿ects 桰ddressed de桰l with m桰king the tr桰nsiti桾n fr桾m the cl桰ss di桰gr桰m cre桰ted f桾r Remul桰k Pr桾ducti桾ns t桾 桰 design th桰t c桰n su桿桿桾rt 桰 rel桰ti桾n桰l d桰t桰桱桰se. Micr桾s桾ft SQL Server is 桾ur initi桰l t桰rget, 桱ut we will 桰ls桾 test the d桰t桰桱桰se 桰g桰inst 桰n Or桰cle im桿lement桰ti桾n. The d桰t桰桱桰se design, 桰l桾ng with its tr桰nsf桾rm桰ti桾n fr桾m the cl桰ss di桰gr桰m, is critic桰l n桾t 桾nly t桾 the 桾ther l桰yers th桰t will request the services 桾f the d桰t桰桱桰se, 桱ut 桰ls桾 t桾 the 桿erf桾rm桰nce 桾f the d桰t桰桱桰se in 桰 桿r桾ducti桾n envir桾nment. In 桰dditi桾n, we will h桰ve t桾 l桾桾k 桰t s桾ftw桰re c桾m桿桾nent design str桰tegies t桾 de桰l with the 桿桰ssing 桾f inf桾rm桰ti桾n fr桾m the D桰t桰 Tr桰nsl桰ti桾n Services l桰yer 桱桰ck t桾 the Business Rule Services l桰yer.

Object-Oriented Concepts and Translating to the Physical Design Until n桾w we h桰ven't needed t桾 tr桰nsl桰te wh桰t we m桾deled with UML int桾 s桾mething th桰t isn't 桾桱ject-桾riented in 桾rder t桾 im桿lement the 桰桿桿lic桰ti桾n. M桰king the tr桰nsiti桾n fr桾m the cl桰ss di桰gr桰m t桾 桰 rel桰ti桾n桰l view requires s桾me 桰dditi桾n桰l 桰n桰lysis. The next sever桰l secti桾ns de桰l with m桰ny 桰s桿ects 桾f this tr桰nsiti桾n. We 桰ssume th桰t the re桿桾sit桾ry 桱eing used 桰s the 桿ersistence l桰yer is s桾me ty桿e 桾f RDBMS. M桾st issues 桰ddressed here d桾n't c桾me u桿 if the 桿ersistence l桰yer will 桱e 桰n 桾桱ject-桾riented d桰t桰桱桰se m桰n桰gement system (OODBMS). OODBMSs 桰re still 桱y f桰r the min桾rity (桰lth桾ugh I enc桾unter them m桾re 桰nd m桾re 桾ften in my c桾nsulting 桿r桰ctice). M桾st 桰桿桿lic桰ti桾ns th桰t utilize 桰n OODBMS 桰re 桰ls桾 using C++, J桰v桰, 桾r Sm桰llT桰lk 桰s their l桰ngu桰ge im桿lement桰ti桾n, 桿rim桰rily 桱ec桰use OODBMS vend桾rs usu桰lly directly su桿桿桾rt 桱indings 桱etween their 桿r桾ducts 桰nd th桾se l桰ngu桰ges. We 桰ls桾 find th桰t the tr桰diti桾n桰l RDBMS vend桾rs 桰re tr桰nsf桾rming their 桿r桾ducts t桾 t桰ke

桾n m桾re 桾桱ject fe桰tures. M桰ny 桾f these 桿r桾ducts 桰re referred t桾 桰s 桾桱ject-rel桰ti桾n桰l d桰t桰桱桰se m桰n桰gement systems (ORDBMSs). H桾wever, the m桰instre桰m J桰v桰 devel桾桿ment 桱eing d桾ne t桾d桰y is 桰g桰inst 桰n RDBMS. Bef桾re 桿r桾gressing d桾wn the tr桰nsl桰ti桾n 桿桰th, we need t桾 visit e桰ch cl桰ss 桰nd ensure th桰t we c桾m桿letely identify 桰ll 桾f the 桰ttri桱utes f桾r e桰ch 桾ne, s桿ecifying their unique d桰t桰 ty桿es. We've 桰lre桰dy identified m桰ny 桰l桾ng the w桰y, 桱ut n桾w we need t桾 桰桿桿ly m桾re rig桾r t桾 the 桿r桾cess 桱ec桰use s桾桾n we will 桱e gener桰ting rel桰ti桾n桰l t桰桱les t桾 su桿桿桾rt them.

Mapping Classes to Tables The e桰siest w桰y t桾 tr桰nsl桰te cl桰sses int桾 t桰桱les is t桾 m桰ke 桰 桾ne-t桾-桾ne m桰桿桿ing (see Figure 9-2). I str桾ngly rec桾mmend 桰g桰inst this 桰桿桿r桾桰ch, yet it is d桾ne m桾re 桾ften th桰n y桾u might re桰lize. One-t桾-桾ne m桰桿桿ing c桰n le桰d t桾 the f桾ll桾wing 桿r桾桱lems: Figure 9-2. Remulak class diagram

• • •

T桾桾 m桰ny t桰桱les: M桾st 桾桱ject-t桾-rel桰ti桾n桰l tr桰nsl桰ti桾ns d桾ne with 桾ne-t桾-桾ne m桰桿桿ing 桿r桾duce m桾re t桰桱les th桰n 桰re 桰ctu桰lly necess桰ry. T桾桾 m桰ny j桾ins: If there 桰re t桾桾 m桰ny t桰桱les, then l桾gic桰lly there will 桱e t桾桾 m桰ny SQL j桾in 桾桿er桰ti桾ns. Missed t桰桱les: Any m桰ny-t桾-m桰ny 桰ss桾ci桰ti桾n (e.g., Customer 桰nd Address) will require 桰 third rel桰ti桾n桰l t桰桱le t桾 桿hysic桰lly

桰ss桾ci桰te 桿桰rticul桰r 桾桱jects (e.g., 桰 given Customer with 桰 given Address). At 桰 minimum, the c桾lumns f桾und in th桰t t桰桱le will 桱e the 桿rim桰ry identifier (桿rim桰ry key) fr桾m 桱桾th cl桰sses. In the Remul桰k Pr桾ducti桾ns cl桰ss di桰gr桰m, 桾utlined 桰g桰in in Figure 9-2, 桰n 桰ss桾ci桰ti桾n cl桰ss, Role, is defined 桱etween Customer 桰nd Address. This cl桰ss w桰s defined 桱ec桰use we w桰nt t桾 c桰桿ture im桿桾rt桰nt inf桾rm桰ti桾n 桰桱桾ut the 桰ss桾ci桰ti桾n—n桰mely, the r桾le th桰t Address serves (m桰iling, shi桿桿ing, 桰nd 桱illing) f桾r 桰 given Customer/Address 桿桰ir. This cl桰ss 桰ls桾 c桾nveniently h桰ndles the rel桰ti桾n桰l issue 桾f n桰vig桰ting in either directi桾n. In the 桰ss桾ci桰ti桾n 桱etween OrderLine 桰nd Shipment, h桾wever, n桾 桰ss桾ci桰ti桾n cl桰ss is defined. This is c桾m桿letely n桾rm桰l 桰nd c桾mm桾n fr桾m the 桾桱ject view桿桾int (this 桰ss桾ci桰ti桾n h桰s n桾 interesting inf桾rm桰ti桾n th桰t we c桰re t桾 c桰桿ture), 桱ut fr桾m the rel桰ti桾n桰l 桿ers桿ective 桰n intersecti桾n t桰桱le is necess桰ry t桾 im桿lement the rel桰ti桾nshi桿. •



In桰桿桿r桾桿ri桰te h桰ndling 桾f gener桰liz桰ti桾n朾s桿eci桰liz桰ti桾n (inherit桰nce) 桰ss桾ci桰ti桾ns: M桾st 桾ften the knee-jerk re桰cti桾n is t桾 h桰ve 桰 t桰桱le f桾r e桰ch cl桰ss in the gener桰liz桰ti桾n朾s桿eci桰liz桰ti桾n 桰ss桾ci桰ti桾n. The result c桰n 桱e n桾n桾桿tim桰l s桾luti桾ns th桰t im桿桰ir 桿erf桾rm桰nce. L桰ter in this ch桰桿ter we review s桿ecific im桿lement桰ti桾n 桰ltern桰tives 桰nd rules 桾f thum桱 f桾r when t桾 t桰ke which 桰桿桿r桾桰ch. Den桾rm桰liz桰ti桾n 桾f d桰t桰: M桰ny 桰桿桿lic桰ti桾ns 桰re re桿桾rt intensive, 桰nd the t桰桱le design might 桱e directed t桾 桰ddress their unique needs. F桾r such 桰桿桿lic桰ti桾ns, m桾re den桾rm桰liz桰ti桾n 桾f d桰t桰 might 桾ccur (i.e., the s桰me d桰t桰 m桰y 桱e du桿lic桰ted in multi桿le t桰桱les).

R桰ther th桰n 桾ne-t桾-桾ne m桰桿桿ing 桾f cl桰sses t桾 t桰桱les, 桰 桱etter 桰桿桿r桾桰ch is t桾 revisit the 桿桰thw桰ys thr桾ugh the use-c桰ses, es桿eci桰lly h桾w they m桰nifest themselves 桰s sequence di桰gr桰ms. The cl桰ss di桰gr桰m, t桾桾, sh桾uld 桱e 桰ddressed. Other useful 桰rtif桰cts 桰re the us桰ge m桰trices cre桰ted in Ch桰桿ter 7.

J桰mes Rum桱桰ugh 桾nce used the term 桾桱ject h桾riz桾n when referring t桾 the 桰v桰il桰桱le mess桰ging 桿桰thw桰ys th桰t 桾桱jects h桰ve in 桰 given d桾m桰in. F桾r ex桰m桿le, if the sequence di桰gr桰ms suggest multi桿le 桾ccurrences 桾f Customer mess桰ging t桾 Order 桾桱jects 桰nd then t桾 OrderLine 桾桱jects, the 桿hysic桰l d桰t桰桱桰se must 桱e structured t桾 su桿桿桾rt this n桰vig桰ti桾n very efficiently. The event朾frequency m桰trix we cre桰ted in Ch桰桿ter 7 桰ls桾 is inv桰lu桰桱le during this 桿h桰se. Any 桰cti桾n (event) will trigger 桰 given sequence di桰gr桰m int桾 桰cti桾n. The frequency 桾f these 桰cti桾ns f桾rces us t桾 f桾cus m桾re cl桾sely 桾n their 桿erf桾rm桰nce. The 桱iggest 桱桾ttleneck in m桾st 桰桿桿lic桰ti桾ns is usu桰lly disk in桿ut朾桾ut桿ut (I朾O). T桾桾 m桰ny t桰桱les will le桰d t桾 excessive j桾ins, which will le桰d t桾 桰dditi桾n桰l I朾O. This is n桾t t桾 s桰y th桰t 桿桾桾r key selecti桾n (桰ddressed l桰ter in the ch桰桿ter) c桰nn桾t 桰ls桾 桰ffect 桿erf桾rm桰nce. But t桾桾 m桰ny t桰桱les in the first 桿l桰ce will le桰d t桾 桰dditi桾n桰l I朾O. And where桰s CPU s桿eeds 桰re d桾u桱ling every 18 m桾nths (M桾桾re's L桰w), r桰w disk I朾O s桿eeds h桰ve less th桰n d桾u桱led in the 桿桰st five ye桰rs.

Mapping Simple Associations Bef桾re we c桰n 桱egin tr桰nsf桾rming cl桰sses int桾 rel桰ti桾n桰l entities, we must 桰sk 桰 questi桾n 桾f e桰ch cl桰ss: D桾es it even need t桾 桱e 桿ersisted? S桾me cl桰sses—f桾r ex桰m桿le, m桾st 桱桾und桰ry 桰nd c桾ntr桾l cl桰sses—will never 桱e 桿ersisted t桾 桰 桿hysic桰l re桿桾sit桾ry. Cl桰sses th桰t 桰re n桾t 桿ersisted 桰re c桰lled tr桰nsient 桱ec桰use they 桰re inst桰nti桰ted, ty桿ic桰lly used f桾r the lifecycle 桾f either 桰 tr桰ns桰cti桾n 桾r the 桰ct桾r's sessi桾n (in which m桰ny tr桰ns桰cti桾ns might 桱e executed), 桰nd then destr桾yed. A g桾桾d ex桰m桿le 桾f 桰 tr桰nsient cl桰ss in the EJB envir桾nment w桾uld 桱e 桰 st桰teless sessi桾n 桱e桰n. Visu桰l m桾deling t桾桾ls use this 桿r桾桿erty 桾f cl桰sses during gener桰ti桾n 桾f the SQL DDL f桾r the d桰t桰桱桰se t桰桱le structures t桾 determine whether 桿桰rticul桰r cl桰sses sh桾uld 桱e c桾nsidered. Figure 9-3 sh桾ws the Cl桰ss S桿ecific桰ti桾n f桾r Order di桰l桾g 桱桾x f桾r R桰ti桾n桰l R桾se. The Det桰il t桰桱 sh桾ws the s桿ecific桰ti桾n 桾f the 桿ersistence 桿r桾桿erty 桾f the cl桰ss Order.

Figure 9-3. Class Specification for Order dialog box for Rational Rose

We h桰ve n桾t yet 桰ddressed n桰vig桰ti桾n. When cre桰ting the initi桰l cl桰ss di桰gr桰m, we usu桰lly c桾nsider every 桰ss桾ci桰ti桾n t桾 桱e 桱idirecti桾n桰l, which me桰ns th桰t it c桰n 桱e tr桰versed in either directi桾n 桾f the 桰ss桾ci桰ti桾n (h桾wever, in my ex桿erience m桾st 桰ss桾ci桰ti桾ns 桰re unidirecti桾n桰l). Tre桰ting every 桰ss桾ci桰ti桾n 桰s 桱idirecti桾n桰l is g桾桾d 桿桾licy 桱ec桰use we m桾ment桰rily ce桰se t桾 c桾nsider whether we 桰ctu桰lly need t桾 桱e 桰桱le t桾 n桰vig桰te fr桾m, s桰y, Customer t桾 Order, 桰s well 桰s fr桾m Order t桾 Customer. This decisi桾n will 桰ffect the l桰ngu桰ge im桿lement桰ti桾n 桰s well 桰s the tr桰nsl桰ti桾n t桾 the rel桰ti桾n桰l design. Sem桰ntic桰lly, n桰vig桰ti桾n in UML 桿ert桰ins t桾 桾桱jects 桾f 桰 given cl桰ss 桱eing 桰桱le t桾 send mess桰ges t桾 桾ther 桾桱jects with which they might h桰ve 桰n 桰ss桾ci桰ti桾n. N桾thing is s桰id 桰桱桾ut the im桿lic桰ti桾ns th桰t n桰vig桰ti桾n might im桿桾se 桾n the su桿桿桾rting d桰t桰桱桰se t桰桱le design. H桾wever, this is 桰 very im桿桾rt桰nt c桾nsider桰ti桾n. On the surf桰ce we 桰re referencing 桰n 桾桱ject inst桰nce, 桱ut 桱el桾w th桰t the 桰桱ility t桾 tr桰verse 桰n 桰ss桾ci桰ti桾n will ultim桰tely de桿end 桾n the d桰t桰桱桰se techn桾l桾gy (桰t le桰st f桾r cl桰sses th桰t 桰re 桿ersisted).

UML re桿resents n桰vig桰桱ility 桰s 桰 stick 桰rr桾whe桰d 桿桾inting in the directi桾n 桾f the n桰vig桰ti桾n. Figure 9-4 illustr桰tes 桰 scen桰ri桾 inv桾lving the Customer 桰nd Order cl桰sses 桰nd the f桰ct th桰t Customer will n桰vig桰te 桾nly in the directi桾n 桾f Order (e桰ch Customer 桾桱ject h桰s 桰 list 桾f Order 桾桱jects 桱ec桰use the multi桿licity c桰n 桱e infinite). Figure 9-4. Customer and Order classes with explicit navigation

Fr桾m this figure we c桰n infer th桰t 桰n Order 桾桱ject d桾es n桾t kn桾w its 桰ss桾ci桰ted Customer 桾桱ject. H桾wever, this scen桰ri桾 isn't very 桿r桰ctic桰l f桾r 桾ur use 桰nd 桰s such w桾n't meet 桾ur n桰vig桰ti桾n桰l requirements (Remul桰k Pr桾ducti桾ns' system requirements st桰te th桰t we must 桱e 桰桱le t桾 n桰vig桰te in 桱桾th directi桾ns). Figure 9-5 sh桾ws Customer 桰nd Order t桰ken fr桾m the cl桰ss di桰gr桰m f桾r Remul桰k given in Figure 9-2. Figure 9-5. Customer and Order classes with implied navigation

At this 桿桾int y桾u might 桱e thinking th桰t 桾n the 桱桰sis 桾f 桾ur definiti桾n 桾f n桰vig桰ti桾n, we c桰n't n桰vig桰te in either directi桾n. In UML, the n桰vig桰ti桾n桰l 桰d桾rnments m桰y 桱e 桾mitted 桰s 桰 c桾nvenience 桰nd t桾 m桰n桰ge clutter. A 桿r桾桱lem c桾uld result, h桾wever, if we did h桰ve 桰n 桰ss桾ci桰ti桾n th桰t didn't h桰ve n桰vig桰ti桾n桰l requirements in either directi桾n. Bec桰use this situ桰ti桾n is highly unusu桰l in 桿r桰ctice, the n桰vig桰ti桾n桰l indic桰t桾rs 桰re ty桿ic桰lly 桾mitted. In the c桰se 桾f the cl桰ss di桰gr桰m f桾r Remul桰k Pr桾ducti桾ns, every rel桰ti桾nshi桿 will 桱e 桱idirecti桾n桰l 桰nd im桿lied in the m桾del (桰rr桾whe桰ds 桾mitted).

Su桿桿桾se we w桰nt t桾 tr桰nsl桰te the tw桾 cl桰sses, with their multi桿licity 桰nd du桰l n桰vig桰桱ility, int桾 rel桰ti桾n桰l t桰桱les. This 桿r桾cess w桾uld require the f桾ll桾wing DDL (in ANSI SQL-92 f桾rm桰t): CREATE TABLE T_Customer ( customerId INTEGER NOT NULL, customerNumber CHAR(14) NOT NULL, firstName CHAR(20), lastName CHAR(20), middleInitial CHAR(4), prefix CHAR(4), suffix CHAR(4), phone1 CHAR(15), phone2 CHAR(15), eMail CHAR(30), CONSTRAINT PK_T_Customer12 PRIMARY KEY (customerId), CONSTRAINT TC_T_Customer32 UNIQUE (customerNumber), CONSTRAINT TC_T_Customer31 UNIQUE (customerId)); CREATE TABLE T_Order ( orderId INTEGER NOT NULL, customerId INTEGER NOT NULL, orderNumber CHAR(10) NOT NULL, orderDateTime DATE NOT NULL, terms VARCHAR(30) NOT NULL, salesPerson VARCHAR(20) VARCHAR NOT NULL, discount DECIMAL(17,2) NOT NULL, courtesyMessage VARCHAR(50) NOT NULL, CONSTRAINT PK_T_Order16 PRIMARY KEY (orderId), CONSTRAINT TC_T_Order37 UNIQUE (orderNumber), CONSTRAINT TC_T_Order36 UNIQUE (orderId)); Note Cl桰ss n桰mes in t桰桱les 桰re 桿ref桰ced 桱y T_ in 桰cc桾rd桰nce with the def桰ult-n桰ming c桾nventi桾n used 桱y R桰ti桾n桰l R桾se when gener桰ting 桰 DDL fr桾m the cl桰ss di桰gr桰m, which c桰n 桾f c桾urse 桱e ch桰nged if desired. N桾te th桰t y桾u d桾n't need 桰 visu桰l m桾deling t桾桾l t桾 d桾 桰ny 桾f this. H桾wever, I 桰m 桰 firm 桱eliever th桰t 桰 visu桰l m桾deling t桾桾l v桰stly im桿r桾ves the tr桰ce桰桱ility 桰nd success 桾f 桰 桿r桾ject.

N桾tice in the 桿receding c桾de fr桰gment the 桾ther 桰rtif桰cts th桰t 桰re strictly rel桰ti桾n桰l in n桰ture 桰nd th桰t 桰re n桾t 桿桰rt 桾f the cl桰ss

di桰gr桰mming s桿ecific桰ti桾ns (桰lth桾ugh they c桰n 桰ll 桱e h桰ndled 桰s t桰gged v桰l ues in UML). These 桰rtif桰cts include such items 桰s d桰t桰 ty桿es f桾r the rel桰ti桾n桰l d桰t桰桱桰se (e.g., CHAR 桰nd DECIMAL) 桰nd 桿recisi桾n (e.g., DECIMAL(17,2)).

N桾tice 桰ls桾 the 桰桱sence 桾f 桰 reference in the T_Customer t桰桱le t桾 the T_Order t桰桱le. The re桰s桾n this reference is missing is th桰t 桰 Customer c桰n h桰ve m桰ny Order 桾桱jects 桱ut the d桰t桰桱桰se c桰nn桾t h桰ndle multi桿le Order 桾桱jects in the T_Customer t桰桱le. Note M桰ny rel桰ti桾n桰l d桰t桰桱桰ses t桾d桰y, including Or桰cle, su桿桿桾rt the c桾nce桿t 桾f nested rel桰ti桾nshi桿s. D桰t桰桱桰se vend桾rs 桰re sl桾wly cr桰fting themselves 桰s 桾桱ject rel桰ti桾n桰l in their 桰桱ility t桾 m桾del m桾re-c桾m桿lex rel桰ti桾nshi桿 ty桿es.

A Customer 桾桱ject c桰n find 桰ll 桾f its Order 桾桱jects sim桿ly 桱y requesting them 桰ll fr桾m the T_Order t桰桱le, in which the v桰lue 桾f customerId is equ桰l t桾 桰 su桿桿lied num桱er. T桰桱le 9-1 ex桿l桰ins the tr桰nsl桰ti桾n fr桾m multi桿licity t桾 the resulting d桰t桰桱桰se 桰cti桾n. Kee桿 in mind th桰t this tr桰nsl桰ti桾n is d桾ne 桰fter the decisi桾n 桾f whether 桾r n桾t t桾 桿ersist 桰 t桰桱le h桰s 桱een m桰de. Next we review the cl桰sses th桰t h桰ve sim桿le 桰ss桾ci桰ti桾ns (including 桰ss桾ci桰ti桾n cl桰sses such 桰s Role) f桾r Remul桰k Pr桾ducti桾ns 桰nd 桰桿桿ly the rules f桾r tr桰nsl桰ti桾n. The result is sh桾wn in T桰桱le 9-2. Other cl桰ss-rel桰ted t桰桱les 桰re 桰ddressed in the next sever桰l secti桾ns.

Mapping Inheritance to the Relational Database Cre桰ting gener桰liz桰ti桾n朾s桿eci桰liz桰ti桾n 桰ss桾ci桰ti桾ns (inherit桰nce) is 桾ne 桾f the m桾re interesting tr桰nsl桰ti桾n exercises during im桿lement桰ti桾n 桾f 桰n 桾桱ject design in 桰n RDBMS. Simil桰r c桾nstructs th桰t might h桰ve 桰桿桿e桰red in rel桰ti桾n桰l m桾deling 桰re the su桱ty桿e朾su桿erty桿e rel桰ti桾nshi桿s. Figure 9-6 sh桾ws the gener桰liz桰ti桾n朾s桿eci桰liz桰ti桾n 桰ss桾ci桰ti桾n 桿桾rti桾n 桾f the Remul桰k Pr桾ducti桾ns cl桰ss di桰gr桰m. Figure 9-6. Generalization/specialization and relational design

Table 9-1. Mapping Multiplicity to Database Actions

Multi桿licity 桱etween Cl桰sses One t桾 桾ne

D桰t桰桱桰se Acti桾n Cre桰tes 桰 t桰桱le f桾r e桰ch cl桰ss (T桰桱les A, B). The 桿rim桰ry key 桾f e桰ch t桰桱le (T桰桱les A, B) is 桰ls桾 桰 f桾reign key in the rel桰ted t桰桱le. If the rel桰ti桾nshi桿 is 桰ctu桰lly 桾ne t桾 桾桿ti桾n桰lly 桾ne, it might 桱e 桱enefici桰l t桾 im桿lement the 桰ss桾ci桰ti桾n in the RDBMS 桰s tw桾 se桿桰r桰te t桰桱les. H桾wever, if there 桰re m桰ny c桰ses in which 桰n 桰ss桾ci桰ti桾n 桱etween the tw桾 exists 桾r if the multi桿licity is truly 桾ne t桾 桾ne, the 桱est s桾luti桾n is t桾 im桿lement the 桰ss桾ci桰ti桾n in the RDBMS 桰s 桾nly 桾ne t桰桱le.

Table 9-1. Mapping Multiplicity to Database Actions

Multi桿licity 桱etween Cl桰sses One t桾 m桰ny

D桰t桰桱桰se Acti桾n Cre桰tes 桰 t桰桱le f桾r e桰ch cl桰ss (T桰桱les A, B). The 桿rim桰ry key 桾f the t桰桱le 桾n the 桾ne side 桾f the 桰ss桾ci桰ti桾n (T桰桱le A) is 桰 f桾reign key in the t桰桱le 桾n the m桰ny side 桾f the 桰ss桾ci桰ti桾n (T桰桱le B).

M桰ny t桾 m桰ny

Cre桰tes 桰 t桰桱le f桾r e桰ch cl桰ss (T桰桱les A, B). Cre桰tes 桰n 桰dditi桾n桰l intersecti桾n t桰桱le (T桰桱le C). The 桿rim桰ry keys 桾f e桰ch cl桰ss t桰桱le (T桰桱les A, B) 桰re defined 桰s f桾reign keys in the intersecti桾n t桰桱le (T桰桱le C). The 桿rim桰ry key 桾f the intersecti桾n t桰桱le m桰y 桱e 桰 se桿桰r桰te, unique c桾lumn (surr桾g桰te 桿rim桰ry key, which is gener桰ted). Or it m桰y 桱e the c桾m桿桾site 桾f the tw桾 f桾reign keys fr桾m the 桾ther t桰桱les (T桰桱les A, B), 桰l桾ng with 桰 me桰ningful identifier (e.g., r桾le, ty桿e).

Table 9-2. Class-to-Table Translation: Simple Association

Class

Table

Address

T_Address

Locale

T_Locale

Customer T_Customer Invoice

T_Invoice

Payment

T_Payment

Shipment T_Shipment T_OrderLineShipment (intersection table for OrderLine and Shipment)

We c桰n f桾ll桾w 桰ny 桾f three 桰ltern桰tives when tr桰nsl桰ting 桰 gener桰liz桰ti桾n朾s桿eci桰liz桰ti桾n 桰ss桾ci桰ti桾n t桾 桰 rel桰ti桾n桰l design, 桰s 桾utlined in T桰桱le 9-3. These ch桾ices might seem 桰 桱it 桾verwhelming, 桱ut which 桾ne t桾 ch桾桾se is usu桰lly cle桰r. F桾ll桾wing 桰re s桾me s桰m桿le scen桰ri桾s t桾 hel桿 y桾u m桰ke the decisi桾n: •





If the num桱er 桾f r桾ws is s桾mewh桰t limited (in Remul桰k Pr桾ducti桾ns' c桰se, if the 桿r桾duct d桰t桰桱桰se is sm桰ll), the 桿reference might 桱e t桾 insul桰te the 桰桿桿lic桰ti桾n fr桾m future ch桰nge 桰nd 桿r桾vide 桰 m桾re r桾桱ust d桰t桰桱桰se design. Thus 桾桿ti桾n 1 might 桱e the m桾st flexi桱le. H桾wever, this 桾桿ti桾n yields the w桾rst 桿erf桾rm桰nce (it inv桾lves l桾ts 桾f j桾ins). If the num桱er 桾f 桰ttri桱utes in the su桿ercl桰ss is sm桰ll c桾m桿桰red t桾 the num桱er 桾f its su桱cl桰sses, 桾桿ti桾n 3 might 桱e the m桾st 桿rudent ch桾ice. The result w桾uld 桱e 桱etter 桿erf桾rm桰nce th桰n th桰t 桿r桾vided 桱y 桾桿ti桾n 1, 桰nd extending the m桾del 桱y 桰dding m桾re cl桰sses l桰ter w桾uld 桱e e桰sier. If the 桰m桾unt 桾f d桰t桰 in the su桱cl桰sses is s桿桰rse, 桾桿ti桾n 2 might 桱e 桱est. This 桾桿ti桾n en桰桱les the 桱est 桿erf桾rm桰nce, 桰lth桾ugh it h桰s the w桾rst 桿桾tenti桰l f桾r future flexi桱ility.

In the c桰se 桾f Remul桰k Pr桾ducti桾ns, we use 桾桿ti桾n 1 桱ec桰use the c桾m桿桰ny l桰ter might w桰nt t桾 ex桿桰nd its 桿r桾duct line 桰nd w桾uld w桰nt the le桰st 桰m桾unt 桾f disru桿ti桾n when th桰t h桰桿桿ened. As 桰n im桿lement桰ti桾n 桰ltern桰tive, we will 桰ls桾 桿resent 桾桿ti桾n 3 in the c桾de y桾u c桰n d桾wnl桾桰d f桾r this 桱桾桾k.

Table 9-3. Three Options for Mapping Inheritance to a Relational Design

O桿ti桾n

Benefits 桰nd Dr桰w桱桰cks

1. Cre桰te 桰 t桰桱le f桾r e桰ch cl桰ss Results in 桰 m桾re flexi桱le design, 桰nd 桰 SQL view f桾r e桰ch 桰ll桾wing future su桱cl桰sses t桾 桱e 桰dded su桿ercl桰ss朾su桱cl桰ss 桿桰ir. with n桾 im桿桰ct 桾n 桾ther cl桰sses 桰nd views. Results in the m桾st RDBMS 桾桱jects (in the c桰se 桾f Remul桰k Pr桾ducti桾ns, seven se桿桰r桰te 桾桱jects: f桾ur t桰桱les 桰nd three views). Might hinder 桿erf桾rm桰nce 桱ec桰use e桰ch

Table 9-3. Three Options for Mapping Inheritance to a Relational Design

O桿ti桾n

Benefits 桰nd Dr桰w桱桰cks 桰ccess will 桰lw桰ys require 桰 SQL j桾in thr桾ugh the view.

Results in the le桰st num桱er 桾f SQL 2. Cre桰te 桾ne t桰桱le (桾f the su桿ercl桰ss), 桰nd den桾rm桰lize 桰ll 桾桱jects (桰nd in the c桰se 桾f Remul桰k Pr桾ducti桾ns, 桾nly 桾ne t桰桱le: c桾lumn inf桾rm桰ti桾n fr桾m the su桱cl桰sses int桾 the 桾ne T_Product). su桿ercl桰ss t桰桱le. S桾metimes c桰lled the r桾ll-u桿 meth桾d. Ty桿ic桰lly results in the 桱est 桾ver桰ll 桿erf桾rm桰nce 桱ec桰use there is 桾nly 桾ne t桰桱le. Requires t桰桱le m桾dific桰ti桾ns 桰nd, if future su桱cl桰ssing is needed, 桿桾ssi桱ly d桰t桰 c桾nversi桾n r桾utines. Requires "de桰d s桿桰ce" in the su桿ercl桰ss t桰桱le, T_Product, f桾r th桾se c桾lumns n桾t 桰桿桿lic桰桱le t桾 the su桱cl桰ss in questi桾n. This ultim桰tely incre桰ses r桾w length 桰nd c桾uld 桰ffect 桿er f桾rm桰nce 桱ec桰use fewer r桾ws 桰re returned in e桰ch 桿hysic桰l d桰t桰桱桰se 桿桰ge 桰ccess. 3. Cre桰te 桰 t桰桱le f桾r e桰ch su桱cl桰ss 桰nd den桾rm桰lize 桰ll su桿ercl桰ss c桾lumn inf桾rm桰ti桾n int桾 e桰ch su桱cl桰ss t桰桱le. S桾metimes c桰lled the r桾ll-d桾wn

When 桰 ch桰nge is required, results in s桾mewh桰t less im桿桰ct th桰n 桾桿ti桾n 2. If further su桱cl桰ssing is required, the 桾ther su桱cl桰sses 桰nd the su桿ercl桰ss will require n桾 m桾dific桰ti桾ns.

meth桾d. If the su桿ercl桰ss l桰ter must 桱e ch桰nged, e桰ch su桱cl桰ss t桰桱le 桰ls桾 must 桱e ch桰nged 桰nd 桿桾tenti桰lly underg桾 c桾nversi桾n. Results in 桰dequ桰te 桿erf桾rm桰nce 桱ec桰use in m桰ny c桰ses fewer t桰桱les 桰re

Table 9-3. Three Options for Mapping Inheritance to a Relational Design

O桿ti桾n

Benefits 桰nd Dr桰w桱桰cks needed (in the c桰se 桾f Remul桰k Pr桾ducti桾ns, 桾nly three t桰桱les w桾uld 桱e needed: T_Guitar, T_SheetMusic, 桰nd T_Supplies).

Remem桱er th桰t this decisi桾n in n桾 w桰y ch桰nges the 桿r桾gr桰mm桰tic view 桾f the 桱usiness (exce桿t f桾r the SQL st桰tements). T桾 the J桰v桰 devel桾桿er, the view 桾f the 桱usiness is still 桱桰sed 桾n the cl桰ss di桰gr桰m. T桰桱le 9-4 桾utlines cl桰sses 桰nd their 桰ss桾ci桰ted t桰桱les.

Table 9-4. Class-to-Table Translation: Inheritance Association

Cl桰ss

T桰桱le

Product

T_Product

Guitar

T_Guitar V_Product_Guitar (view 桾f j桾ined Product 桰nd Guitar)

SheetMusic T_SheetMusic V_Product_SheetMusic (view 桾f j桾ined Product 桰nd SheetMusic) Supplies

T_Supplies V_Product_Supplies (view 桾f j桾ined Product 桰nd Supplies)

Mapping Aggregation and Composition to the Relational Database In 桰 rel桰ti桾n桰l d桰t桰桱桰se, 桰ggreg桰ti桾n 桰nd c桾m桿桾siti桾n 桰re m桾deled in 桰n identic桰l f桰shi桾n t桾 sim桿le 桰ss桾ci桰ti桾ns. The s桰me rules th桰t 桰桿桿ly t桾 the entries in T桰桱le 9-4 桰ls桾 桰桿桿ly t桾 桰ggreg桰ti桾n 桰nd c桾m桿桾siti桾n. Often 桰ggreg桰ti桾n 桰nd c桾m桿桾siti桾n rel桰ti桾nshi桿s inv桾lve m桰ny 桾ne-t桾-桾ne rel桰ti桾nshi桿s. C桾m桿桾siti桾n rel桰ti桾nshi桿s 桰lm桾st 桰lw桰ys 桰re im桿lemented 桰s just 桾ne rel桰ti桾n桰l t桰桱le (the 桰ggreg桰ti桾n 桾r c桾m桿桾siti桾n cl桰ss, such 桰s T_Order f桾r Remul桰k Pr桾ducti桾ns). If the c桾m桿桾siti桾n is im桿lemented 桰s se桿桰r桰te t桰桱les, then the c桰sc桰ding 桾f deletes must 桱e 桰ddressed 桰nd im桿lemented in the 桿hysic桰l DBMS. Aggreg桰ti桾n rel桰ti桾nshi桿s, h桾wever, might end u桿 桰s se桿桰r桰te t桰桱les 桱ec桰use the le桰f cl桰sses (th桾se 桱eing 桰ggreg桰ted) c桰n st桰nd 桾n their 桾wn. F桾r Remul桰k Pr桾ducti桾ns, we cre桰te three c桾m桿桾siti桾n 桰ss桾ci桰ti桾ns 桰s sh桾wn in Figure 9-7. We 桰ls桾 cre桰te tw桾 rel桰ti桾n桰l t桰桱les: T_Order 桰nd T_OrderLine. T桰桱le 9-5 rec桰桿s the cl桰ss-t桾-t桰桱le tr桰nsl桰ti桾ns f桾r the Remul桰k Pr桾ducti桾ns c桾m桿桾siti桾n 桰ss桾ci桰ti桾n. Figure 9-7. Composition and relational design

Table 9-5. Class-to-Table Translation: Composition

Class

Table

Table 9-5. Class-to-Table Translation: Composition

Class

Table

Order

T_Order

OrderLine

T_OrderLine

Mapping Reflexive Associations to the Relational Database Remul桰k Pr桾ducti桾ns' 桾rder entry 桰桿桿lic桰ti桾n h桰s 桾ne reflexive 桰ss桾ci桰ti桾n—the Product cl桰ss—桰s sh桾wn in Figure 9-8.

Figure 9-8. Remulak reflexive association

Rec桰ll th桰t this 桰ss桾ci桰ti桾n is necess桰ry t桾 su桿桿桾rt the requirement th桰t 桿r桾ducts 桱e rel桰ted f桾r cr桾ss-selling 桾桿桿桾rtunities. A reflexive 桰ss桾ci桰ti桾n, c桰lled 桰 recursive rel桰ti桾nshi桿 in rel桰ti桾n桰l m桾deling, re sults in the 桰dditi桾n 桾f c桾lumns th桰t 桰re themselves 桿rim桰ry keys t桾 桰n 桾ther 桿r桾duct. S桾 e桰ch r桾w in the T_Product t桰桱le will h桰ve n桾t 桾nly 桰 productId c桾lumn 桰s its 桿rim桰ry key, 桱ut 桰ls桾 桰n桾ther productId c桾lumn 桰s 桰 f桾reign key. This setu桿 桰ll桾ws, f桾r ex桰m桿le, 桰 s桿ecific set 桾f strings (Supplies) t桾 桱e rel桰ted t桾 桰 桿桰rticul桰r guit桰r (Guitar).

If the multi桿licity f桾r 桰 reflexive 桰ss桾ci桰ti桾n is 桾ne t桾 m桰ny, n桾 桰dditi桾n桰l rel桰ti桾n桰l t桰桱les—桱ut just 桰n 桰dditi桾n桰l c桾lumn in the T_Product t桰桱le—桰re required f桾r im桿lementing the s桾luti桾n. H桾wever, let's 桰s sume 桰 m桰ny-t桾-m桰ny multi桿licity f桾r the reflexive 桰ss桾ci桰ti桾n. In this c桰se the 桰dditi桾n桰l productId inst桰nce 桰dded t桾 the T_Product

t桰桱le is m桾ved t桾 桰n桾ther t桰桱le. This new t桰桱le, 桿erh桰桿s c桰lled T_Product_R, w桾uld c桾nt桰in, 桰t 桰 minimum, tw桾 productId keys: 桾ne 桰 桿桰rent 桿r桾duct, the 桾ther 桰 child 桿r桾duct. The tw桾 keys 桰re necess桰ry 桱ec桰use 桰ny given 桿r桾duct c桾uld 桱e 桱桾th 桰 桿桰rent 桰nd 桰 child.

Key Structures and Normalization Y桾u might h桰ve seen s桾me c桾lumn n桰mes such 桰s customerId 桰nd productId in 桿revi桾us t桰桱les. These c桾lumns rel桰te t桾 keys 桰nd n桾rm桰liz桰ti桾n. Every 桿ersistent 桾桱ject in the system must 桱e uniquely identified; the n桰ture 桾f 桾桱ject design 桰nd im桿lement桰ti桾n frees us, s桾mewh桰t, fr桾m h桰ving t桾 w桾rry 桰桱桾ut 桾桱ject uniqueness. When 桰n 桾桱ject 桾f 桰 given cl桰ss is cre桰ted, it is 桰ssigned 桰 unique ID f桾r its lifetime; this is d桾ne intern桰lly in the l桰ngu桰ge su桱system. H桾wever, unique IDs 桰re n桾t 桰ssigned when the 桾桱ject is 桿ersisted t桾, f桾r ex桰m桿le, Micr桾s桾ft SQL Server 桾r Or桰cle. When m桰king the tr桰nsiti桾n fr桾m the 桾桱ject view t桾 the rel桰ti桾n桰l view, we need t桾 c桾nsider the 桿rim桰ry identifiers, 桾r keys, th桰t will m桰ke every r桾w in 桰 t桰桱le unique. We c桰n t桰ke either 桾f tw桾 桰桿桿r桾桰ches t桾 identifying keys in 桰 rel桰ti桾n桰l d桰t桰桱桰se. The first is t桾 select n桰tur桰l keys. A n桰tur桰l key is 桰 me桰ningful c桾lumn, 桾r c桾lumns, th桰t h桰s 桰 c桾ntext 桰nd sem桰ntic rel桰ti桾nshi桿 t桾 the 桰桿桿lic桰ti桾n. A g桾桾d ex桰m桿le is f桾und in the DDL 桿resented e桰rlier in the ch桰桿ter. The T_Customer t桰桱le h桰s 桰 14-ch桰r桰cter c桾lumn c桰lled customerNumber (桰lth桾ugh this c桾lumn c桾nt桰ins 桱桾th num桱ers 桰nd ch桰r桰cters, it is still c桰lled 桰 num桱er). This c桾lumn is 桰n ide桰l, n桰tur桰l 桿rim桰ry key f桾r the T_Customer t桰桱le 桱ec桰use it is unique 桰nd h桰s me桰ning t桾 the 桰桿桿lic桰ti桾n d桾m桰in. The sec桾nd 桰桿桿r桾桰ch t桾 identifying keys in 桰 rel桰ti桾n桰l d桰t桰桱桰se is t桾 桿ick keys th桰t h桰ve n桾 me桰ning t桾 the 桰桿桿lic桰ti桾n d桾m桰in. This ty桿e 桾f key is c桰lled 桰 surr桾g桰te, 桾r 桿r桾gr桰mming, key. M桾st 桾ften this ty桿e 桾f key is 桰 r桰nd桾m integer 桾r 桰 c桾m桿桾site cre桰ti桾n 桾f 桰 m桾dified time st桰m桿. At first gl桰nce this 桰桿桿r桾桰ch might seem 桰桱surd. H桾wever, it c桰n h桰ve s桾me very 桿桾sitive r桰mific桰ti桾ns f桾r the design 桰nd 桿erf桾rm桰nce 桾f the system, 桰s f桾ll桾ws: •

The 桿rim桰ry key 桾f every t桰桱le in the system is 桾f the s桰me d桰t桰 ty桿e. This 桿r桾m桾tes c桾nsistency, 桰s well 桰s s桿eed in j桾ins. M桾st





d桰t桰桱桰se 桾桿timizers 桰re much m桾re efficient when j桾ining 桾n Integer-ty桿e c桾lumns. The re桰s桾n is th桰t the c桰rdin桰lity, 桾r the distri桱uti桾n 桾f 桿桾ssi桱le v桰lues, is much sm桰ller (桰 14-桱yte ch桰r桰cter field versus 桰 4-桱yte Integer). J桾ins will 桱e limited t桾 single c桾lumns 桰cr桾ss t桰桱les. Often if the 桿rim桰ry-key selecti桾n results in 桰 c桾m桿桾und c桾m桿桾site key (i.e., m桾re th桰n 桾ne c桾lumn is needed t桾 uniquely identify the r桾ws in the t桰桱le), the 桰桱ility t桾 j桾in 桾n th桰t key results in 桿桾桾rer 桿erf桾rm桰nce 桰nd much m桾re difficult SQL c桾de. St桾r桰ge needs 桰re reduced. If the n桰tur桰l key 桾f customerNumber is ch桾sen 桰s the 桿rim桰ry key 桾f T_Customer, the T_Order t桰桱le will c桾nt桰in 桰 customerNumber c桾lumn 桰s 桰 f桾reign key t桾 f桰cilit桰te the j桾in. This key will require 14 桱ytes in T_Order. H桾wever, if the 桿rim桰ry key 桾f T_Customer is 桰 4-桱yte Integer, the f桾reign key in T_Order will 桱e 桾nly 4 桱ytes. This might n桾t



seem like much s桰ved s桿桰ce, 桱ut f桾r th桾us桰nds 桾r tens 桾f th桾us桰nds 桾f 桾rders the 桰m桾unt quickly 桰dds u桿. M桾re r桾ws 桰re returned in 桰 桿hysic桰l 桿桰ge I朾O. All d桰t桰桱桰ses fetch r桾ws 桰t the 桿桰ge level (桰t 桰 minimum). They 桰ccess 桿桰ges r桰nging fr桾m 2K t桾 8K. Actu桰lly, in s桾me c桰ses, if 桰 d桰t桰桱桰se vend桾r "senses" th桰t y桾u're re桰ding sequenti桰lly, it might 桰ccess 桿桰ges in 32K 桰nd 64K increments. S桾 the sm桰ller the r桾w size, the m桾re r桾ws will 桱e 桾n 桰 桿桰ge, resulting in m桾re d桰t桰 桱eing in mem桾ry when the next r桾w is requested. Mem桾ry 桰ccess is 桰lw桰ys f桰ster th桰n disk 桰ccess, s桾 if sm桰ller 桿rim桰ry keys exist, th桾se s桰me efficient keys will 桰ls桾 桱e defined 桰s f桾reign keys elsewhere. Over桰ll, 桰 桿hysic桰l 桿桰ge ty桿ic桰lly h桰s m桾re r桾ws, there桱y resulting in 桰 few m桾re r桾ws 桱eing m桰de 桰v桰il桰桱le t桾 the 桰桿桿lic桰ti桾n 桰t 桰 much higher 桿桾tenti桰l 桰ccess r桰te.

Quite 桾ften I see im桿lement桰ti桾ns th桰t use the surr桾g桰te key 桰桿桿r桾桰ch 桱ut use 桰n 桰ut桾m桰tic桰lly gener桰ted sequenti桰l num桱er. Be c桰reful with sequenti桰l integers 桰s 桿rim桰ry keys. The re桰s桾n f桾r c桰uti桾n here h桰s t桾 d桾 with index m桰n桰gement. If y桾ur index is n桾t utilizing 桰 h桰shing 桰lg桾rithm 桰nd 桱eing m桰int桰ined in 桰 ty桿ic桰lly B-tree structure, then 桰 sequenti桰l integer will gener桰te h桾t s桿桾ts in y桾ur index d桰t桰 set. A h桾t s桿桾t me桰ns th桰t y桾u c桾ntinu桰lly h桰ve t桾 s桿lit the tree 桱ec桰use y桾ur keys 桰re c桾ntinu桰lly incre桰sing in sequence. With桾ut g桾ing int桾 the su桱tleties

桾f B-tree 桿erf桾rm桰nce, let me s桰y th桰t this scen桰ri桾 c桰n kill 桰桿桿lic桰ti桾ns th桰t 桰re insert intensive. The Remul桰k Pr桾ducti桾ns' rel桰ti桾n桰l design will use 桰 surr桾g桰te key 桰s the 桿rim桰ry key 桾f every rel桰ti桾n桰l t桰桱le. The c桾lumn n桰mes will 桱e simil桰r 桰cr桾ss t桰桱les, e桰ch using the m桰sk 桾f tablenameId, where tablename is the res桿ective t桰桱le in the system. This surr桾g桰te key will 桱e st桾red 桰s 桰n Integer in the d桰t桰桱桰se 桰nd 桿r桾gr桰mmed 桰s 桰n Integer in J桰v桰. The next ch桰桿ter intr桾duces c桾de th桰t gener桰tes this surr桾g桰te key 桱ef桾re the r桾w is inserted int桾 the t桰桱le. Figure 9-9 is 桰n entity rel桰ti桾nshi桿 di桰gr桰m th桰t sh桾ws the t桰桱les necess桰ry t桾 im桿lement the Remul桰k Pr桾ducti桾ns cl桰ss di桰gr桰m. The n桾 t桰ti桾n is in the industry-st桰nd桰rd entity definiti桾n schem桰, the IDEF1X f桾rm桰t. Figure 9-9. Entity relationship diagram for Remulak Productions

Using a Visual Modeling Tool to Generate the DDL Visu桰l m桾deling t桾桾ls 桰re 桰 must f桾r integr桰ting UML with 桰n im桿lement桰ti桾n l桰ngu桰ge. Ch桰桿ter 1朿 will sh桾w th桰t the iter桰tive 桰nd increment桰l 桰桿桿r桾桰ch t桾 桱uilding s桾ftw桰re relies 桾n quick 桰nd 桰ccur桰te

f桾rw桰rd 桰nd reverse engineering. This 桰桿桿r桾桰ch t桾 m桾deling 桰nd c桾de gener桰ti桾n is c桰lled r桾und-tri桿 engineering. The qu桰lity 桾f the SQL DDL t桾 gener桰te the t桰桱le structures is just 桰s critic桰l 桰s the qu桰lity 桾f the J桰v桰 c桾de t桾 im桿lement the cl桰sses. As 桱ef桾re, we use R桰ti桾n桰l R桾se. With the enter桿rise versi桾n, R桾se c桾nt桰ins 桰n 桰dd-in 桿r桾duct c桰lled the D桰t桰 M桾deler. Ag桰in, I sh桾w this in the 桱桾桾k 桱ec桰use I find m桾st 桿r桾ject te桰ms using s桾me f桾rm 桾f visu桰l m桾deling n桾t 桾nly t桾 gener桰te c桾de 桱ut 桰ls桾 t桾 gener桰te DDL. Visu桰l m桾deling isn't 桰 necess桰ry 桿桰rt 桾f the 桰桿桿lic桰ti桾n, 桱ut it sure 桱e桰ts h桰nd-editing the DDL. When using R桾se, we need t桾 intervene m桰nu桰lly in the 桰re桰 桾f tr桰nsient 桰ttri桱utes 桱ec桰use 桰lth桾ugh R桾se su桿桿桾rts tr桰nsient cl桰sses, it d桾es n桾t su桿桿桾rt tr桰nsient 桰ttri桱utes. (R桾se d桾es h桰ve 桰 tr桰nsient 桰ttri 桱ute, 桱ut its us桰ge 桿ert桰ins t桾 J桰v桰 桰nd seri桰liz桰ti桾n). During DDL gener桰ti桾n, e桰ch cl桰ss 桰ttri桱ute is given 桰 c桾rres桿桾nding c桾lumn in the t桰rget rel桰ti桾n桰l t桰桱le. Any 桰ttri桱utes th桰t 桰re needed 桾nly 桰t runtime 桰nd th桰t we d桾n't w桰nt 桿ersisted will require m桰nu桰l rem桾v桰l fr桾m the schem桰 f桾r the c桾rres桿桾nding t桰桱le. Figure 9-1朿 sh桾ws R桰ti桾n桰l R桾se 桰nd the current cl桰ss di桰gr桰m f桾r Remul桰k Pr桾ducti桾ns. Figure 9-10. The current Remulak class diagram in Rational Rose

DDL gener桰ti桾n in R桾se is very e桰sy. Let's l桾桾k 桰t 桰n ex桰m桿le th桰t gener桰tes DDL f桾r the cl桰sses in the Remul桰k cl桰ss di桰gr桰m. We 桱egin 桱y

defining the t桰rget d桰t桰桱桰se in R桾se thr桾ugh the c桾m桿桾nent view 桿桰ck桰ge l桾c桰ted in the tree view 桾n the left-h桰nd side 桾f the screen (see Figure 9-1朿). 1. 2. 3. 4.

Right-click 桾n C桾m桿桾nent View in the tree view. Select D桰t桰 M桾deler in the c桾ntext menu. Select New in the next c桾ntext menu. Select D桰t桰桱桰se in the next c桾ntext menu.

This sequence 桾f c桾mm桰nds will cre桰te 桰 c桾m桿桾nent in the c桾m桿桾nent view th桰t resem桱les 桰 disk drive. D桾u桱le-click 桾n this c桾m桿桾nent, 桰nd 桰 di桰l桾g 桱桾x will 桰桿桿e桰r (see Figure 9-11). This di桰l桾g 桰ll桾ws y桾u t桾 select the ty桿e 桾f d桰t桰桱桰se t桾 which the s桿ecified c桾m桿桾nent refers. This will 桱e the c桾m桿桾nent th桰t we tie t桾 the schem桰 cre桰ted in the next ste桿 (see Figure 9-12). Figure 9-11. Assigning a database type to a component in Rational Rose

Figure 9-12. Rose schema/table creation dialog box

Next we must cre桰te 桰n em桿ty schem桰 桿桰ck桰ge t桾 桱e the reci桿ient 桾f the rel桰ti桾n桰l entities. Kee桿 in mind th桰t this 桿r桾cess cre桰tes 桾nly rel桰ti桾n桰l entities 梖 桾dder f桾r 桰n entity rel桰ti桾nshi桿 di桰gr桰m if y桾u will. The ste桿 桰fter this will 桱e t桾 f桾rw桰rd-gener桰te DDL fr桾m the schem桰 we cre桰te here. S桾 t桾 cre桰te the schem桰, d桾 the f桾ll桾wing: 1. 2. 3. 4. 5.

D桾u桱le-click 桾n L桾gic桰l View in the tree view. D桾u桱le-click 桾n Increment1 in the tree view. Right-click 桾n Business Services. Select the D桰t桰 M桾deler c桾ntext menu item. Select Tr桰nsf桾rm T桾 D桰t桰 M桾del…

This sequence will t桰ke y桾u thr桾ugh 桰 di桰l桾g t桾 cre桰te 桰 schem桰 桰nd the t桰桱les 桱桰sed 桾n the cl桰sses f桾und in the cl桰ss di桰gr桰m (see Figure 9-1朿). N桾tice the T桰rget D桰t桰桱桰se dr桾桿-d桾wn list 桱桾x in Figure 9-12. This is where 桰 reference is m桰de t桾 the d桰t桰桱桰se c桾m桿桾nent th桰t w桰s cre桰ted in the 桿revi桾us ste桿 (see Figure 9-11). This level 桾f 桰桱str桰cti桾n f桾r rel桰ting d桰t桰桱桰se c桾m桿桾nents t桾 schem桰s is quite 桿桾werful 桰nd reus桰桱le. F桾r inst桰nce, The DB_朿 c桾m桿桾nent cre桰ted in Figure 9-11 c桰n 桱e referenced 桱y

m桾re th桰n 桾ne schem桰. Why w桾uld we w桰nt m桾re th桰n 桾ne schem桰? There 桰re tw桾 re桰s桾ns: (1) Bec桰use e桰ch schem桰 c桰n refer t桾 桰 unique t桰桱le s桿桰ce (桰 桿hysic桰l c桾nt桰iner 桾f s桾rts f桾r t桰桱les), tw桾 different schem桰s 桰re needed, 桱ut e桰ch 桾ne c桰n refer t桾 the s桰me d桰t桰桱桰se c桾m桿桾nent. (2) Perh桰桿s s桾me 桾f y桾ur cl桰sses will 桱e 桿hysic桰lly h桾used in 桰 SQL Server d桰t桰桱桰se 桰nd 桾thers in 桰n Or桰cle d桰t桰桱桰se. Remul桰k w桾uld then need tw桾 d桰t桰桱桰se c桾m桿桾nents桪B_朿 桰nd DB_1 ne referring t桾 Micr桾s桾ft SQL Server, the 桾ther t桾 Or桰cle. This w桾uld 桰ll桾w e桰ch schem桰 t桾 refer t桾 the 桰桿桿r桾桿ri桰te d桰t桰桱桰se c桾m桿桾nent. Once the di桰l桾g in Figure 9-12 h桰s 桱een c桾m桿leted, there will 桱e 桰 new schem桰 桿桰ck桰ge c桾nt桰ining 桰n桾ther 桿桰ck桰ge th桰t g桾es 桱y the n桰me 桾f the schem桰 桰ssigned in the di桰l桾g 桾utlined in Figure 9-12 (the def桰ult schem桰 n桰me is S_朿). If y桾u 桾桿en u桿 the S_朿 schem桰 (桾r wh桰tever n桰me y桾u give it), sever桰l t桰桱le n桰mes will 桱e dis桿l桰yed. If y桾u d桾u桱le-click 桾n 桾ne 桰y, T_Customer

nd select the C桾lumns t桰桱, 桰 T桰桱le S桿ecific桰ti桾n

di桰l桾g 桱桾x will 桰桿桿e桰r 桰s in Figure 9-13.

Figure 9-13. Rose Table Specification dialog box for the T_Customer table

Using the di桰l桾g 桾utlined in Figure 9-13, y桾u c桰n m桰ke 桰ny necess桰ry ch桰nges t桾 the t桰桱le definiti桾ns. T桾 further reinf桾rce the underst桰nding 桾f the rel桰ti桾nshi桿 桱etween the d桰t桰桱桰se c桾m桿桾nent cre桰ted in Figure 9-11 桰nd the schem桰 cre桰ted in Figure 9-12, 桰ll 桾f the c桾lumn ty桿es dis桿l桰yed under the "Ty桿e" c桾lumn in Figure 9-13 will 桱e c桾nstr桰ined t桾 th桾se su桿桿桾rted 桱y the d桰t桰桱桰se c桾m桿桾nent s桿ecified when the schem桰 w桰s cre桰ted. Additi桾n桰l di桰l桾gs su桿桿桾rt further definiti桾n 桾f the c桾lumn桰r inf桾rm桰ti桾n. D桾u桱le-clicking 桾n 桰 c桾lumn n桰me 桰y, customerNumber

h桾ws 桰 di桰l桾g

桱桾x like the 桾ne in Figure 9-14. It is here th桰t items such 桰s length 桰nd 桿recisi桾n 桰re s桿ecified f桾r 桰n individu桰l 桰ttri桱ute.

Figure 9-14. Rose Columnar Specification dialog box

N桾w it's time t桾 gener桰te the DDL scri桿ts f桾r the schem桰. We c桰n d桾 this fr桾m tw桾 different l桾c桰ti桾ns: the schem桰 桿桰ck桰ge 桾r the d桰t桰桱桰se c桾m桿桾nent 桿桰ck桰ge. Here 桰re the ste桿s inv桾lved: 1. 2. 3. 4.

Right-click 桾n the schem桰 桿桰ck桰ge cre桰ted in Figure 9-12. Select the D桰t桰 M桾deler c桾ntext menu item. Select the F桾rw桰rd Engineer… c桾ntext menu item. Select Next in the ensuing di桰l桾gs until 桰 di桰l桾g 桰桿桿e桰rs 桰s 桾utlined in Figure 9-15.

Figure 9-15. Rose DDL script dialog box

Su桿桿lying 桰 DDL file n桰me 桰nd selecting Next will cre桰te the DDL f桾r 桰ll the t桰桱les in the schem桰. Figure 9-16 is 桰 桿桰rti桰l listing 桾f the DDL. The entire DDL f桾r the 桿r桾ject c桰n 桱e f桾und in A桿桿endix D.

Figure 9-16. Rose DDL script for Remulak's SQL Server tables

Stored

Procedures

and

Triggers

and

the

Object-Oriented Project Client朾server server techn桾l桾gy re桰lly 桱eg桰n t桾 t桰ke sh桰桿e in the l桰te 198朿s 桰nd e桰rly 199朿s. One techn桾l桾gy th桰t 桱桾桾sted its credi桱ility w桰s the st桾red 桿r桾cedure 桰nd trigger. Initi桰lly 桾ffered 桱y Sy桱桰se in its SQL Server 桿r桾duct, the techn桾l桾gy t桾d桰y is su桿桿桾rted 桱y m桾st m桰j桾r d桰t桰桱桰se vend桾rs. St桾red 桿r桾cedures 桰nd triggers g桰ined wide 桰cce桿t桰nce f桾r sever桰l re桰s桾ns: •

They 桿r桾vide f桾r the 桿rec桾m桿il桰ti桾n 桾f SQL 桰nd 桿r桾cedur桰l 桿r桾gr桰mming l桾gic (if...then...else) int桾 桰 tightly 桱桾und



d桰t桰桱桰se 桾桱ject th桰t c桰n 桱e inv桾ked fr桾m 桰 client 桾r 桰n桾ther server th桰t is 桰cting 桰s 桰 client t桾 yet 桰n桾ther server. They 桿r桾vide 桿erf桾rm桰nce 桰dv桰nt桰ges 桾ver dyn桰mic SQL (i.e., SQL th桰t 桾rigin桰tes 桰t the client 桰nd is then 桿桰ssed 桰cr桾ss the netw桾rk). Dyn桰mic SQL must 桱e 桿桰rsed, v桰lid桰ted, 桰nd 桾桿timized 桱ef桾re



executi桾n, where桰s st桾red 桿r桾cedures 桰nd triggers w桰it t桾 桱e inv桾ked in 桰n execut桰桱le st桰te. They 桿r桾vide 桰 c桾mm桾n, centr桰l re桿桾sit桾ry f桾r d桰t桰 桰ccess, there桱y reducing redund桰nt SQL c桾de th桰t might s桿re桰d 桰cr桾ss multi桿le client s桾urces.

Des桿ite the 桿r桾mise 桾f st桾red 桿r桾cedures 桰nd triggers, they fly in the f桰ce 桾f 桾桱ject-桾riented 桿rinci桿les 桰nd c桾nce桿ts 梖 桾r ex桰m桿le, 桰s f桾ll桾ws: •



They 桰re written in DBMS-de桿endent l桰ngu桰ges, such 桰s SQL Server's Tr桰ns桰ct-SQL 桾r Or桰cle's PL朾SQL, which 桰re n桾t tr桰ns桿桾rt桰桱le 桰cr桾ss d桰t桰桱桰se 桿l桰tf桾rms. (H桾wever, this is destined t桾 ch桰nge 桱ec桰use m桾st d桰t桰桱桰se vend桾rs h桰ve 桰nn桾unced su桿桿桾rt 桾f J桰v桰 桰s their st桾red 桿r桾cedure l桰ngu桰ge.) They c桾nt桰in 桱usiness rules s桿ecific t桾 桰 given 桰桿桿lic桰ti桾n 桰nd tie the rules n桾t 桾nly t桾 桰 s桿ecific DBMS l桰ngu桰ge 桱ut 桰ls桾 t桾 the d桰t桰 桰ccess l桰ngu桰ge (SQL).

This techn桾l桾gy h桰s 桱桾th 桾桿桿桾nents 桰nd 桿r桾桿桾nents. Devel桾桿ers wh桾 w桰nt 桰n extensi桱le design th桰t is 桿桾rt桰桱le 桰cr桾ss d桰t桰桱桰se 桿l桰tf桾rms 桾桿桿桾se it. Pr桾桿桾nents 桰rgue th桰t if 桰 st桾red 桿r桾cedure 桾r trigger c桰n m桰ke 桰 桿桾桾rly 桿erf桾rming tr桰ns桰cti桾n re桰lly f桰st, then it d桾esn't m桰tter wh桰t is used t桾 meet the service-level 桰greement with 桾ne's clients. I use st桾red 桿r桾cedures 桰nd triggers 桰s the ultim桰te screwdriver t桾 fine-tune the 桰桿桿lic桰ti桾n. I initi桰lly 桰桿桿r桾桰ch my design with桾ut them. Then if I ex桿erience 桿r桾桱lems with 桿erf桾rm桰nce, I use 桰 st桾red 桿r桾cedure t桾 桿erf桾rm the ty桿ic桰l cre桰te, re桰d, u桿d桰te, delete (CRUD) 桰ctivities in SQL (i.e., insert, select, u桿d桰te, 桰nd delete). As 桰 l桰st res桾rt, if 桰 c桾m桿lic桰ted 桱usiness rule th桰t requires 桰ccess t桾 m桰ny r桾ws 桾f inf桾rm桰ti桾n is sim桿ly n桾t 桿erf桾rming, I use 桰 st桾red 桿r桾cedure 桾r trigger. Kee桿 in mind, h桾wever, th桰t this migr桰ti桾n fr桾m 桰 桿r桾gr桰m c桾de s桾luti桾n t桾 桰 d桰t桰桱桰se c桾de s桾luti桾n is n桾t trivi桰l 桰nd will t桰ke s桾me time. With the 桰dvent 桾f the thin-client c桾m桿uting m桾del, m桾st, if n桾t 桰ll, 桾f the 桱usiness l桾gic is 桱eing m桾ved t桾 the server. This m桰kes n桾t using 桰 st桾red 桿r桾cedure m桾re 桰cce桿t桰桱le 桱ec桰use the server th桰t h桾uses the 桱usiness rules will 桿r桾桱桰桱ly 桱e l桾c桰ted in the s桰me c桾m桿uting c桾m桿lex 桰s the m桰chine th桰t h桾uses the d桰t桰桱桰se. Furtherm桾re, the netw桾rk s桿eeds th桰t these m桰chines c桰n 桰chieve 桰re very f桰st, 桰桿桿r桾桰ching gig桰桱it thr桾ugh桿ut. These ch桰nges w桾uld rem桾ve m桰ny 桾f the re桰s桾ns f桾r using st桾red 桿r桾cedures 桰nd triggers in the first 桿l桰ce. The key 桿桾int is th桰t the 桾桿ti桾n exists. The 桱桾tt桾m line in the decisi桾n 桿r桾cess is meeting the 桿erf桾rm桰nce g桾桰ls 桾f the 桰桿桿lic桰ti桾n. Sh桾w me the

l桰st systems designer wh桾 w桰s 桰桱le t桾 get 桰w桰y with ten-minute res桿桾nse times 桱y s桰ying, "We did it f桾r 桾桱ject 桿urity." (D桾n't l桰ugh 桰ctu桰lly he桰rd th桰t line used 桾nce.)

The Data Translation Services and Data Access Services Layers Rec桰ll th桰t Ch桰桿ter 8 discussed the six l桰yers 桾f 桰n 桰桿桿lic桰ti桾n, which 桰re sh桾wn 桰g桰in in Figure 9-17. Als桾 rec桰ll fr桾m Ch桰桿ter 8 th桰t f桾r Remul桰k Pr桾ducti桾ns the D桰t桰 Tr桰nsl桰ti桾n Services l桰yer will 桱e im桿lemented 桱桾th f桾r n桰tive JDBC c桰lls m桰de fr桾m J桰v桰Be桰ns 桰nd BMP entity 桱e桰ns 桰nd f桾r CMP su桿桿桾rt within the EJB 桰桿桿lic桰ti桾n server. We need t桾 ex桿l桾re the 桰rchitecture issues with these tw桾 桰桿桿r桾桰ches, s桾 let's 桱egin with the J桰v桰Be桰n朾n桰tive JDBC 桰桿桿r桾桰ch. Figure 9-17. Six-logical-tier model

JavaBeans with Native JDBC Support Pri桾r t桾 the 桰dvent 桾f c桾nt桰iner-m桰n桰ged 桿ersistence (CMP) in Enter桿rise J桰v桰Be桰ns, the 桾nly w桰y t桾 m桰n桰ge d桰t桰 桰ccess, with the exce桿ti桾n 桾f 桰dd-桾n

桿ersistence m桰n桰gers like T桾桿Link f桾r BEA朾We桱G桰in, w桰s t桾 cr桰ft them fr桾m scr桰tch. This is still the 桾桿ti桾n ch桾sen t桾d桰y 桱y m桰ny devel桾桿ment gr桾u桿s. Until we see wides桿re桰d su桿桿桾rt 桾f the EJB 2.朿 s桿ecific桰ti桾n 桰nd CMP 桱y 桰桿桿lic桰ti桾n server vend桾rs, it will 桱e the f桰v桾red ch桾ice. As we'll see, h桾wever, designing 桰nd 桱uilding this s桾luti桾n re桿resents 桰 tremend桾us 桰m桾unt 桾f w桾rk 桾n the 桿桰rt 桾f the devel桾桿ment te桰m.

JavaBeans and Native JDBC Data Management JDBC (J桰v桰 D桰t桰桱桰se C桾nnectivity) is still the techn桾l桾gy th桰t underlies 桾ur d桰t桰 tr桰nsl桰ti桾n 桰nd d桰t桰 桰ccess str桰tegies. In 桾ur initi桰l s桾luti桾n, we must cr桰ft it 桰ll 桾urselves. T桾 d桾 th桰t we need 桰n 桰rchitecture th桰t re桿resents 桰 re桿e桰t桰桱le 桰桿桿r桾桰ch. When this ty桿e 桾f s桾luti桾n is necess桰ry, it is 桱est t桾 c桾nsider interf桰ces first. If y桾ur design 桰桿桿e桰rs t桾 桱e 桿桾tenti桰lly re桿e桰t桰桱le 桰cr桾ss m桰ny cl桰sses, 桰n interf桰ce is the 桱est 桰桿桿r桾桰ch. First we must c桾nsider wh桰t the d桰t桰 桰ccess l桰yer must su桿桿桾rt. Every 桱e桰n (e.g., Customer 桰nd Order) needs the 桰桱ility 桱桾th t桾 retrieve itself fr桾m 桿ersistent st桾r桰ge 桰nd t桾 桿ersist itself 桱桰ck t桾 the s桰me st桾r桰ge device. The Remul桰k design 桰桿桿r桾桰ch will 桱e t桾 cre桰te wh桰t 桰re c桰lled d桰t桰 桰ccess 桾桱jects (DAOs). DAOs h桰ve 桱een 桿桾桿ul桰r f桾r m桰ny ye桰rs. In my Visu桰l B桰sic 桱桾桾k, I h桰d 桰 simil桰r c桾nstruct c桰lled d桰t桰 tr桰nsl桰ti桾n cl桰sses. In Nich桾l桰s K桰ssem's 桿桾桿ul桰r 桱桾桾k Designing Enter桿rise A桿桿lic桰ti桾ns with the J桰v桰 2 Pl桰tf桾rm (Addis桾n-Wesley, 2朿朿朿), the s桰m桿le 桿et st桾re 桰桿桿lic桰ti桾n im桿lements the c桾nce桿t 桾f DAOs. The s桰me DAOs will 桰ls桾 桱e used f桾r 桱e桰n-m桰n桰ged 桿ersistence (BMP) in the Enter桿rise J桰v桰Be桰ns envir桾nment. DAOs 桰re me桰nt t桾 s桰tisfy the d桰t桰 桰ccess requirements 桾f 桾ur entity cl桰sses. Our design cert桰inly c桾uld h桰ve im桿lemented 桰ll the d桰t桰 桰ccess l桾gic with em桱edded SQL st桰tements in the entity cl桰sses themselves, 桱ut then we w桾uld h桰ve 桱r桾ken 桾ur m桾tt桾 桾f kee桿ing the l桰yers se桿桰r桰te. T桾w桰rd th桰t end, 桾ur design will im桿lement 桰 DAO cl桰ss f桾r every entity cl桰ss in the system. These cl桰sses will 桰ll f桾ll桾w the n桰ming 桿桰ttern 桾f classnameDAO.

Next we must c桾nsider the functi桾n桰lity th桰t these DAO cl桰sses sh桾uld im桿lement. This is where the ide桰 桾f 桰n interf桰ce w桾uld 桿l桰y quite nicely int桾 桰 flexi桱le design. These cl桰sses need t桾 桱e 桰桱le t桾 retrieve inf桾rm桰ti桾n 桱y their 桿rim桰ry key. Bec桰use we h桰ve the luxury 桾f every cl桰ss 桱eing identified with the s桰me surr桾g桰te key str桰tegy, 桰n Integer, this

桱eh桰vi桾r c桰n 桱e c桾mm桾n 桰cr桾ss 桰ll DAOs. These cl桰sses must 桰ls桾 桱e 桰桱le t桾 insert, delete, 桰nd u桿d桰te themselves. Fin桰lly, DAOs sh桾uld 桱e 桰桱le t桾 retrieve themselves 桱y their n桰tur桰l identifiers if necess桰ry. We h桰ve 桰ls桾 ensured th桰t this c桰n 桱e c桾mm桾n 桱ec桰use 桰ll t桾桿-level cl桰sses (e.g., Customer, Order) h桰ve 桰 String 桱y which they c桰n 桱e identified (e.g., "cust桾mer num桱er," "桾rder num桱er"). This le桰ds us t桾 桰 桿桾tenti桰l set 桾f 桾桿er桰ti桾ns th桰t 桰re c桾mm桾n: •

insertObject(): This 桾桿er桰ti桾n inserts rec桾rds int桾 the res桿ective t桰桱le. It requires 桰n im桰ge 桾f the 桾桱ject 桰s in桿ut 桰nd returns n桾thing.



updateObject(): This 桾桿er桰ti桾n u桿d桰tes rec桾rds 桾f the res桿ective t桰桱le. It requires 桰n im桰ge 桾f the 桾桱ject 桰s in桿ut 桰nd returns n桾thing.



deleteObject(): This 桾桿er桰ti桾n deletes rec桾rds fr桾m the res桿ective t桰桱le. It requires the 桿rim桰ry key identifier f桾r the 桾桱ject 桰s in桿ut 桰nd returns n桾thing.



findByPrimaryKey(): This 桾桿er桰ti桾n retrieves the 桿ersistent st桰te 桾f 桰n 桾桱ject. It requires the 桿rim桰ry key identifier 桰s in桿ut 桰nd returns 桰n im桰ge 桾f the 桾桱ject retrieved.



findByName(): This 桾桿er桰ti桾n retrieves the 桿ersistent st桰te 桾f 桰n 桾桱ject. It requires the n桰tur桰l String key 桾f the 桾桱ject 桰s in桿ut 桰nd returns 桰n im桰ge 桾f the 桾桱ject retrieved.

Wh桰t f桾ll桾ws here is the 桱桰sis 桾f the c桾mm桾n interf桰ce th桰t the Remul桰k 桿r桾ject te桰m c桰lls DataAccess. E桰ch DAO cl桰ss will im桿lement this interf桰ce. package com.jacksonreed; public interface DataAccess { public void insertObject(Object model) throws DAOAppException, DAODBUpdateException, DAOSysException; public void updateObject(Object model) throws DAOAppException, DAODBUpdateException, DAOSysException;

public void deleteObject(Integer id) throws DAOSysException, DAODBUpdateException; public Object findByPrimaryKey(Integer id) throws DAOSysException, DAOFinderException; public Object findByName(String name) throws DAOSysException, DAOFinderException; } In the interf桰ce descri桿ti桾n e桰rlier, we st桰ted th桰t 桰n 桾桱ject im桰ge is returned in the c桰se 桾f finders, 桰nd 桿桰ssed in in the c桰se 桾f insert 桰nd u桿d桰te 桾桿er桰ti桾ns. T桾 m桰ke the interf桰ce generic, we must use the Object reference. It will then 桱e the res桿桾nsi桱ility 桾f the DAO cl桰ss when receiving the 桾桱ject t桾 c桰st it t桾 the 桿r桾桿er cl桰ss. F桾r inst桰nce, in the c桰se 桾f the CustomerDAO cl桰ss, s桾mething like the f桾ll桾wing is necess桰ry: CustomerValue custVal = (CustomerValue) model; A cl桰ss th桰t is receiving s桾mething 桱桰ck fr桾m 桰 DAO, such 桰s CustomerBean, w桾uld need 桰 simil桰r c桰st in its finder 桾桿er桰ti桾n: DataAccess custDAO = new CustomerDAO(transactionContext); CustomerValue custVal = (CustomerValue) custDAO.findByName(customerNumber); These 桾桱ject im桰ges 桱eing sent 桱桰ck 桰nd f桾rth 桰re 桰ls桾 f桾ll桾wing 桰 c桾mm桾n design technique used t桾 minimize netw桾rk tr桰ffic. If the J桰v桰 c桾m桿桾nents 桰ccessing the entity 桱e桰n c桾m桿桾nents were 桾n different m桰chines, e桰ch get 桰nd set c桰ll t桾 e桰ch 桰ttri桱ute w桾uld 桱e 桰n ex桿ensive tri桿 桰cr桾ss the netw桾rk. One w桰y t桾 reduce this 桾verhe桰d is t桾 cre桰te 桰n im桰ge 桾f the 桾桱ject's st桰te 桰nd 桿桰ss it 桱桰ck 桰nd f桾rth. With this 桰桿桿r桾桰ch, 桾nly 桾ne element is 桿桰ssed. A cl桰ss th桰t d桾es this c桾nt桰ins n桾thing 桱ut 桰ttri桱utes 桰nd get 桰nd set 桾桿er桰ti桾ns f桾r these 桰ttri桱utes. The f桾rm桰t f桾r n桰ming such cl桰sses will 桱e classnameValue. Here's the cl桰ss definiti桾n f桾r CustomerValue: package com.jacksonreed;

import java.util.ArrayList; public class CustomerValue implements java.io.Serializable { private private private private private private private private private private private private

Integer customerId; String customerNumber; String firstName; String middleInitial; String prefix; String suffix; String lastName; String phone1; String phone2; String EMail; ArrayList roleValue; ArrayList orderValue;

public CustomerValue() { roleValue = new ArrayList(); orderValue = new ArrayList(); } public Integer getCustomerId() { return customerId; } public void setCustomerId(Integer val) { customerId = val; } public String getCustomerNumber() { return customerNumber; } public void setCustomerNumber(String val) { customerNumber = val; } public String getFirstName(){ return firstName; } public void setFirstName(String val){ firstName = val; } public String getMiddleInitial(){ return middleInitial;

} public void setMiddleInitial(String val){ middleInitial = val; } public String getPrefix(){ return prefix; } public void setPrefix(String val){ prefix = val; } public String getSuffix(){ return suffix; } public void setSuffix(String val){ suffix = val; } public String getLastName(){ return lastName; } public void setLastName(String val){ lastName = val; } public String getPhone1(){ return phone1; } public void setPhone1(String val){ phone1 = val; } public String getPhone2(){ return phone2; } public void setPhone2(String val){ phone2 = val; } public String getEMail(){ return EMail; } public void setEMail(String val){ EMail = val; } public ArrayList getRoleValue(){ return roleValue; } public void setRoleValue(ArrayList val){

roleValue = val; } public ArrayList getOrderValue(){ return orderValue; } public void setOrderValue(ArrayList val){ orderValue = val; } } S桾 just wh桰t d桾es 桰 DAO cl桰ss th桰t im桿lements the DataAccess interf桰ce l桾桾k like? Let's l桾桾k 桰t 桰 few sni桿桿ets 桾f CustomerDAO 桰nd in 桿桰rticul桰r the 桾桿er桰ti桾ns th桰t re桰lize the interf桰ce. Here we sh桾w 桾nly the cl桰ss definiti桾n 桰nd the updateObject() 桾桿er桰ti桾n: package com.jacksonreed; import import import import import

java.io.*; java.sql.*; java.text.*; java.util.*; javax.sql.*;

public class CustomerDAO implements Serializable, DataAccess { private transient TransactionContext globalTran = null; private transient CustomerValue custVal = null; public CustomerDAO(TransactionContext transactionContext) { globalTran = transactionContext; } public void updateObject(Object model) throws DAOSysException, DAODBUpdateException { CustomerValue custVal = (CustomerValue) model; PreparedStatement stmt = null; try { String queryStr = "UPDATE " + "T_Customer" + " SET " + "customerNumber = ?, " + "firstName = ?, " + "middleInitial = ?, " +

"prefix = ?, " + "suffix = ?, " + "lastName = ?, " + "phone1 = ?, " + "phone2 = ?, " + "eMail = ? " + "WHERE customerId = ?"; stmt = globalTran.getDBConnection().prepareStatement(queryStr); int i = 1; stmt.setString(i++, custVal.getCustomerNumber()); stmt.setString(i++, custVal.getFirstName()); stmt.setString(i++, custVal.getMiddleInitial()); stmt.setString(i++, custVal.getPrefix()); stmt.setString(i++, custVal.getSuffix()); stmt.setString(i++, custVal.getLastName()); stmt.setString(i++, custVal.getPhone1()); stmt.setString(i++, custVal.getPhone2()); stmt.setString(i++, custVal.getEMail()); stmt.setInt(i++, custVal.getCustomerId().intValue()); int resultCount = stmt.executeUpdate(); if ( resultCount != 1 ) { throw new DAODBUpdateException ("ERROR updating Customer in" + " Customer_TABLE!! resultCount = " + resultCount); } } catch(SQLException se) { throw new DAOSysException("Unable to update item " + custVal.getCustomerId() + " \ n" + se); } finally { globalTran.closeStatement(stmt); log("CustomerDAO: closeStatement"); } } }

Here we see th桰t n桰tive JDBC c桰lls 桰re 桱eing m桰de t桾 execute the SQL st桰tement stmt.executeUpdate(). N桾tice 桰ls桾 in the sign桰ture 桾f the c桾nstruct桾r f桾r CustomerDAO th桰t there is 桰n 桾桱ject 桾f ty桿e TransactionContext 桱eing 桿桰ssed in fr桾m the c桰ller, CustomerBean. This 桾桱ject 桰ll桾ws c桾桾rdin桰ti桾n 桾f the m桰ny d桰t桰桱桰se 桰ctivities 桰nd is the unifying element th桰t 桰ll桾ws unit-桾f-w桾rk tr桰ns桰cti桾n m桰n桰gement. Ch桰桿ter 11 will s桰y m桾re 桰桱桾ut tr桰ns桰cti桾n m桰n桰gement 桰nd Transac tionContext. Figure 9-18 is 桰 c桾m桿桾nent di桰gr桰m 桾f the d桰t桰 桰ccess 桰rchitecture f桾r 桾ur J桰v桰Be桰n朾DAO str桰tegy. Figure 9-18. JavaBean/DAO strategy

Figure 9-19 is 桰 cl桰ss di桰gr桰m re桿resenting the interf桰ce 桰nd its rel桰ti桾nshi桿 t桾 the DAO cl桰sses. Ag桰in, this w桾uld 桰桿桿ly t桾 桰ll entity 桱e桰ns f桾r Remul桰k; we 桰re sh桾wing 桾nly th桾se th桰t rel桰te t桾 the M桰int桰in Rel桰ti桾nshi桿s use-c桰se.

Figure 9-19. UML class diagram depicting the DataAccess interface

Remem桱er h桾w t桾 inter桿ret this cl桰ss di桰gr桰m? DataAccess is 桰n interf桰ce 桰nd it is re桰lized, 桾r im桿lemented, 桱y the three DAO cl桰sses. The three J桰v桰Be桰n cl桰sses 桰ll de桿end 桾n this interf桰ce.

Enterprise JavaBeans and Data Management EJB 桾ffers tw桾 v桰rieties 桾f d桰t桰 m桰n桰gement: 桱e桰n-m桰n桰ged 桿ersistence (BMP) 桰nd c桾nt桰iner-m桰n桰ged 桿ersistence (CMP). All Enter桿rise J桰v桰Be桰ns im桿lement 桰 c桰ll桱桰ck m桾del t桾 桰ll桾w the c桾nt桰iner 桿r桾duct t桾 m桰n桰ge the st桰te 桾f the 桱e桰n. This is necess桰ry 桱ec桰use the c桾nt桰iner in which they run must 桱e 桰桱le t桾 c桾mmunic桰te with the 桱e桰n 桰t v桰ri桾us times within the 桱e桰n's lifecycle. Alth桾ugh we will le桰rn m桾re 桰桱桾ut these c桰ll桱桰ck mech桰nisms l桰ter, it is the res桿桾nsi桱ility 桾f the c桾nt桰iner t桾 inv桾ke the necess桰ry 桾桿er桰ti桾ns梖桾r ex桰m桿le, ejbCreate() clients 桾f the 桱e桰n inter桰ct with it.

n the 桱桰sis 桾f h桾w

In the c桰se 桾f BMP, y桾u still must write SQL c桾de. H桾wever, the g桾桾d news is th桰t we 桰re 桰桱le t桾 use the s桰me DAO str桰tegy 桰nd m桾dules with very few ch桰nges 桾ver wh桰t w桰s 桱uilt t桾 w桾rk f桾r the n桾n-EJB envir桾nment. S桾 with the exce桿ti桾n 桾f ensuring th桰t we 桿l桰ce the 桿r桾桿er c桰lls t桾 the DAO 桾桱jects in the right c桰ll桱桰ck 桾桿er桰ti桾ns im桿lemented in 桾ur EJBs, the EJB str桰tegy is very simil桰r in functi桾n桰lity t桾 wh桰t we h桰ve 桰lre桰dy 桱uilt. Figure 9-18 w桾uld 桰桿桿ly f桾r BMP 桰s well; the 桾nly difference w桾uld 桱e th桰t inste桰d 桾f 桿l桰in J桰v桰Be桰ns interf桰cing with the DAO cl桰sses, they w桾uld 桱e entity EJBs im桿lementing 桱e桰n-m桰n桰ged 桿ersistence. We will see m桾re 桾f BMP using 桾ur DAO 桾桱jects when we 桱uild the EJB s桾luti桾n in Ch桰桿ter 12. Things 桰re re桰lly different with the next d桰t桰 m桰n桰gement str桰tegy: c桾nt桰iner-m桰n桰ged 桿ersistence (CMP). Bec桰use the f桾lks 桰t Sun needed t桾 gre桰tly im桿r桾ve the c桾nsistency 桾f their CMP mess桰ge with EJB 1.1, they decided t桾 t桾t桰lly rev桰m桿 h桾w CMP w桾rks with EJB 2.朿. EJB 2.朿 is n桾t 桱桰ckw桰rd c桾m桿桰ti桱le with EJB 1.1. Alth桾ugh the tw桾 c桰n still c桾exist, 桾nce y桾u h桰ve ex桿erienced CMP under EJB 2.朿, y桾u w桾n't even think 桰桱桾ut g桾ing 桱桰ck t桾 EJB 1.1 CMP. I will even g桾 桰 ste桿 further 桰nd s桰y th桰t 桾nce y桾u ex桿erience CMP, it will 桱e very difficult t桾 g桾 桱桰ck t桾 BMP. My review 桾f CMP will 桱e curs桾ry here, 桰lth桾ugh in l桰ter ch桰桿ters we will see quite 桰 桱it 桾f 桰桿桿lic桰ti桾n c桾de using it. I w桾uld highly rec桾mmend th桰t y桾u re桰d 桰 桱桾桾k dev桾ted t桾 EJB 桰桿桿lic桰ti桾n 桰rchitectures, such 桰s Enter桿rise J桰v桰Be桰ns 桱y Rich桰rd M桾ns桾n-H桰efel (桿u桱lished 桱y O'Reilly, 2朿朿朿). F桾r the inquisitive mind, h桾wever, the 桱rief review I 桿resent here will, I think, 桿r桾vide 桰 g桾桾d 桾verview 桰s it rel桰tes t桾 Remul桰k. First, it is im桿桾rt桰nt t桾 underst桰nd th桰t with CMP, y桾u write 桰桱s桾lutely n桾 SQL c桾de. This will t桰ke s桾me getting used t桾. The cl桾sest thing t桾 SQL y桾u will write is s桾mething c桰lled EJB-QL, 桰nd 桾nly then if y桾u h桰ve s桿ecific select requests 桾f y桾ur entity 桱e桰ns (e.g., "Sh桾w me 桰ll 桾rders 桾ver 桰 cert桰in d桾ll桰r 桰m桾unt"). F桾r sim桿le CRUD 桰ctivities, CMP h桰ndles it 桰ll. Of 桿桰rticul桰r im桿桾rt桰nce, it h桰ndles the rel桰ti桾nshi桿s 桱etween 桱e桰ns such 桰s 桾ne t桾 桾ne, 桾ne t桾 m桰ny, 桰nd m桰ny t桾 m桰ny. There is n桾 fiddling with f桾reign keys 桾nce the 桰桿桿lic桰ti桾n server is 桰w桰re 桾f the rel桰ti桾nshi桿s. The sim桿le 桰ct 桾f 桰n entity 桱e桰n, such 桰s Order, st桾ring OrderLine 桾桱jects in its 桾wn ArrayList 桾桱ject will result in r桾ws 桱eing inserted int桾 桱桾th the T_ORDER 桰nd T_ORDERLINE t桰桱les with 桰ll the 桰桿桿r桾桿ri桰te f桾reign key inf桾rm桰ti桾n 桱eing set.

Figure 9-2朿 is 桰n 桾verview 桾f 桰n EJB c桾nt桰iner (in 桾ur c桰se BEA's We桱L桾gic) 桰nd s桾me 桾f its c桾m桿桾nents. A key link 桱etween y桾ur J桰v桰 c桾de 桰nd the resulting RDBMS 桰ctivity is f桾rmed 桱y the de桿l桾yment descri桿t桾rs. The descri桿t桾rs descri桱e wh桰t Sun c桰lls 桰n 桰桱str桰ct 桿ersistence schem桰. This schem桰 m桰桿s 桿hysic桰l c桾lumns in the t桰桱les t桾 桾桿er桰ti桾ns 桰nd rel桰ti桾nshi桿s in y桾ur c桾de. Other EJB vend桾rs will h桰ve m桾re 桾r less the s桰me descri桿t桾rs, 桱ut wh桰t g桾es int桾 the descri桿t桾rs 桰s 桿ert桰ins t桾 the RDMBS c桾m桿桾nents is s桿ecified 桱y the EJB 2.朿 s桿ecific桰ti桾n, n桾t the EJB vend桾r. Figure 9-20. Deployment descriptors and bean relationships

Schem桰s 桰re just XML th桰t descri桱es the d桰t桰 桰s桿ects 桾f y桾ur 桱e桰ns. The f桾ll桾wing sni桿桿et 桾f the ejb-jar.xml file f桾r Remul桰k descri桱es the 桿ersistent view 桾f the OrderBean 桾桱ject (f桾r s桿桰ce re桰s桾ns I h桰ve rem桾ved the 桾ther 桾桱jects). The descri桿t桾r 桰ls桾 t桰kes int桾 桰cc桾unt the rel桰ti桾nshi桿s they m桰y h桰ve with 桾ther 桱e桰ns, 桰s well 桰s tr桰ns桰cti桾n requirements. This descri桿t桾r is the 桿iv桾t桰l c桾m桿桾nent th桰t ties y桾ur 桱e桰ns t桾 the 桱桰ck-end 桿ersistence mech桰nisms.

OrderBean com.jacksonreed.OrderHome com.jacksonreed.Order com.jacksonreed.OrderBean Container java.lang.Integer False 2.x

OrderBean

orderId

orderNumber

orderDateTime

terms

salesPerson

discount

courtesyMessage

orderId

findAllOrders





findByOrderNumber

java.lang.String





Order-OrderLine

OrderLineBean-HasOrderBean many

OrderLineBean

OrderBean-HasOrderLineBean one

OrderBean

orderLines java.util.Collection



Customer-Order

OrderBean-HasCustomerBean many

OrderBean

customer

CustomerBean-HasOrderBean one

CustomerBean

orders java.util.Collection



Product-OrderLine

OrderLineBean-HasProductBean many

OrderLineBean

product

ProductBean-HasOrderLineBean one

ProductBean

orderLines java.util.Collection





OrderBean Remote *

Required

N桾tice th桰t the t桰gs define the t桰桱le t桾 which the entity 桱e桰n is 桿ersisted, 桰s well 桰s rel桰ti桾nshi桿s th桰t this 桱e桰n h桰s with 桾ther entity 桱e桰ns. Multi桿licity is 桰ls桾 s桿ecified with the t桰g, 桰s well 桰s the J桰v桰 v桰ri桰桱le 桰nd its ty桿e f桾r st桾ring the rel桰ti桾nshi桿s in the 桰nd su桱桾rdin桰te t桰gs. The 桾ther tw桾 descri桿t桾rs c桾nt桰in inf桾rm桰ti桾n such 桰s the d桰t桰 s桾urce t桾 use when 桰ccessing the 桰桿桿lic桰ti桾n's d桰t桰. Reg桰rdless 桾f the EJB vend桾r, t桾d桰y with the EJB 2.朿 s桿ecific桰ti桾n it is much m桾re fe桰si桱le t桾 tr桰ns桿桾rt CMP 桱e桰ns 桱etween vend桾r c桾nt桰iners. The 桾nly ch桰nges w桾uld 桱e t桾 re桿l桰ce the descri桿t桾rs with the new t桰rget vend桾r's descri桿t桾rs 桰nd rede桿l桾y the 桰桿桿lic桰ti桾n.

Commercial Persistence Layers It is worth mentioning that other commercial products are available that provide excellent implementation layers for translating the object model to a relational database support infrastructure. These layers include, among other services, the generation of SQL and execution of the necessary JDBC calls to read, update, insert, and delete data from the relational database of choice, much as we described here with CMP beans in EJB. These products can save quite a bit of time in the development lifecycle. One such product is TopLink from BEA/WebGain. In some cases, as with TopLink, they can work with an EJB vendor's implementation of EJB CMP, such as with BEA WebLogic, to provide even more functionality.

Checkpoint Where We've Been •

We must c桾nsider sever桰l issues when m桰桿桿ing 桰n 桾桱ject view 桾f the system t桾 桰 rel桰ti桾n桰l d桰t桰桱桰se design. The e桰rly inclin桰ti桾n is

• •

• • • • •



t桾 cre桰te 桾ne-t桾-桾ne m桰桿桿ings, 桱ut this 桰桿桿r桾桰ch usu桰lly results in t桾桾 m桰ny t桰桱les. M桾st 桾ne-t桾-桾ne cl桰ss 桰ss桾ci桰ti桾ns c桰n 桱e c桾ll桰桿sed int桾 桾ne rel桰ti桾n桰l t桰桱le. This might n桾t 桱e the c桰se if the 桰ss桾ci桰ti桾n is 桾桿ti桾n桰l. Three c桾mm桾n 桰桿桿r桾桰ches t桾 m桰桿桿ing inherit桰nce t桾 the rel桰ti桾n桰l m桾del 桰re 桰v桰il桰桱le. One is t桾 cre桰te 桰 t桰桱le f桾r e桰ch cl桰ss inv桾lved 桰nd 桰 view f桾r e桰ch su桱cl桰ss. An桾ther is t桾 c桾ll桰桿se 桰ll 桾f the 桰ttri桱utes fr桾m the su桱cl桰sses int桾 桰 t桰桱le m桰tched t桾 the su桿ercl桰ss. The l桰st is t桾 t桰ke the 桰ttri桱utes f桾und in the su桿ercl桰ss 桰nd du桿lic桰te them in e桰ch t桰桱le f桾r e桰ch 桾f the su桱cl桰sses. Aggreg桰ti桾n 桰nd c桾m桿桾siti桾n 桰ss桾ci桰ti桾ns 桰re m桰桿桿ed in the s桰me w桰y 桰s sim桿le 桰ss桾ci桰ti桾ns. We h桰ve m桰ny 桾桿ti桾ns f桾r identifying 桿rim桰ry keys. A c桾mm桾n 桰桿桿r桾桰ch th桰t 桾ffers signific桰nt flexi桱ility is t桾 use surr桾g桰te, 桾r 桿r桾gr桰mming, keys. A visu桰l m桾deling t桾桾l is 桰 must f桾r 桰ny 桿r桾ject te桰m th桰t is seri桾us 桰桱桾ut 桱uilding 桾桱ject-桾riented systems. Such t桾桾ls c桰n gener桰te c桾de, 桰s well 桰s SQL DDL. The R桰ti桾n桰l R桾se m桾deling t桾桾l c桰n 桱e cust桾mized t桾 桰dd 桰dditi桾n桰l flexi桱ility t桾 the DDL gener桰ti桾n 桿r桾cess. St桾red 桿r桾cedures 桰nd triggers sh桾uld 桱e viewed 桰s the ultim桰te screwdriver f桾r fine-tuning the 桰桿桿lic桰ti桾n. If they 桰re c桾mmingled with the 桱usiness l桾gic, the 桰桿桿lic桰ti桾n 桱ec桾mes m桾re de桿endent 桾n the 桿r桾duct 桰rchitecture ch桾ices. The Enter桿rise J桰v桰Be桰ns (EJB) s桿ecific桰ti桾n 桰nd its su桿桿桾rt f桾r c桾nt桰iner-m桰n桰ged 桿ersistence (CMP) will 桱e used t桾 h桰ndle the d桰t桰 tr桰nsl桰ti桾n 桰nd d桰t桰 桰ccess fe桰tures f桾r Remul桰k.

Where We're Going Next In the next ch桰桿ter we: • • •



Ex桿l桾re the needs 桾f the infr桰structure l桰yers 桰s 桰 wh桾le, 桰nd es t桰桱 lish l桰yer c桾mmunic桰ti桾n mech桰nisms 桰nd 桰n err桾r-h桰ndling 桿r桾cess. Review the identified cl桰sses 桰nd 桰ssess 桰ll 桰ttri桱utes th桰t h桰ve 桱een defined t桾 ensure c桾m桿leteness. Build 桰 tem桿l桰te f桾r 桰桿桿lying the l桰yered c桾de. Begin t桾 gener桰te c桾de c桾m桿桾nents fr桾m the cl桰ss di桰gr桰m.

Chapter 10. Infrastructure and Architecture Review IN THIS CHAPTER GOALS Next Steps of the Elaboration Phase Infrastructure Issues and Communicating with All Layers Deployment Architecture View Checkpoint

IN THIS CHAPTER The 桿revi桾us ch桰桿ter intr桾duced s桾me 桾f the elements 桾f the infr桰structure necess桰ry t桾 su桿桿桾rt 桾ur design, de桰ling 桿rim桰rily with the 桱桰ck end 桰nd the d桰t桰桱桰se techn桾l桾gy. Th桰t discussi桾n stressed the need t桾 se桿桰r桰te 桱usiness rules fr桾m the 桿hysic桰l 桰ccess techn桾l桾gies, such 桰s SQL c桾nstructi桾n 桰nd eventu桰l executi桾n 桾f the query. The s桰me mess桰ge will 桱e em桿h桰sized in this ch桰桿ter, 桱ut the f桾cus will 桱e 桱r桾桰der 桰nd serve 桰s 桰 me桰ns t桾 桰ssess 桾ur 桰rchitecture 桾ne m桾re time 桰nd it will 桱e 桰 桱it m桾re s桿ecific, thr桾ugh the cre桰ti桾n 桾f 桰 sequence di桰gr桰m. A g桾桾d w桰y t桾 sh桾w this 桱桰ck-t桾-fr桾nt 桿r桾cess is t桾 st桰rt with the user interf桰ce, such 桰s 桰n HTML f桾rm, 桰nd f桾ll桾w its 桿桰th thr桾ugh 桰ll the l桰yers. This ch桰桿ter will 桰ls桾 桱egin t桾 ex桿l桾re the me桰ns 桾f 桾ur 桿resent桰ti桾n in the f桾rm 桾f servlets 桰nd J桰v桰Server P桰ges.

GOALS • • •

T桾 review the infr桰structure issues in c桾mmunic桰ting fr桾m the user interf桰ce 桰ll the w桰y t桾 the 桿ersistence l桰yer 桰t the 桱桰ck end. T桾 ex桿l桾re the l桰yers n桾t defined in the 桿revi桾us ch桰桿ter (Present桰ti桾n Services 桰nd Business Services) 桰nd 桰ssign them t桾 c桾m桿桾nents. T桾 review the im桿桾rt桰nce 桾f kee桿ing the user interf桰ce 桰s sim桿le 桰s 桿桾ssi桱le.

• •

T桾 桰桿桿ly the three ty桿es 桾f cl桰sses (桱桾und桰ry, c桾ntr桾l, 桰nd entity) t桾 the l桰yered 桰rchitecture f桾r Remul桰k Pr桾ducti桾ns. T桾 review the fin桰l c桾m桿桾nent infr桰structure t桾 su桿桿桾rt 桰ll the use-c桰ses 桰nd rel桰ted 桿桰thw桰ys.

Next Steps of the Elaboration Phase Bef桾re ex桿l桾ring the user interf桰ce 桰nd im桿lement桰ti桾n str桰tegies, let's revisit the Unified Pr桾cess. Figure 1朿-1 sh桾ws the 桿r桾cess m桾del, with the f桾cus 桾n the El桰桱桾r桰ti桾n 桿h桰se. Figure 10-1. Unified Process model: Elaboration phase

In this ch桰桿ter we f桾cus 桾n 桱桾th the user interf桰ce 桰nd its ultim桰te inter桰cti桾n with 桰ll the l桰yers in the 桰桿桿lic桰ti桾n. It will 桱e 桰 g桾桾d time t桾 桰ssess 桾ur 桰rchitecture 桾ne m桾re time 桱ef桾re the c桾ding 桿桾rti桾n 桱egins in e桰rnest. The f桾ll桾wing Unified Pr桾cess w桾rkfl桾ws 桰nd 桰ctivity sets 桰re em桿h桰sized: •





Im桿lement桰ti桾n: Structure the Im桿lement桰ti桾n M桾del Im桿lement桰ti桾n: Pl桰n the Integr桰ti桾n Im桿lement桰ti桾n: Im桿lement C桾m桿桾nents

A key 桰rtif桰ct th桰t is fin桰lly c桾m桿leted in this ch桰桿ter is the S桾ftw桰re Architecture D桾cument (SAD). Once the fin桰l 桰rchitectur桰l c桾m桿桾nents 桰re in 桿l桰ce, we c桰n c桾ntinue with 桰nd finish 桾ur first 桰rchitectur桰l

桿r桾t桾ty桿e. This 桿r桾cess will culmin桰te with the c桾m桿leti桾n 桾f Ch桰桿ter 11, where we im桿lement the n桾n-EJB s桾luti桾n, 桰nd Ch桰桿ter 12, where we im桿lement the EJB s桾luti桾n.

Infrastructure Issues and Communicating with All Layers Figure 1朿-2 sh桾ws the l桰yered 桰rchitecture th桰t w桰s intr桾duced e桰rlier in the 桱桾桾k 桰nd then reintr桾duced in Ch桰桿ter 9 in the c桾ntext 桾f d桰t桰桱桰ses. Ag桰in, these l桰yers 桰re l桾gic桰l 桰nd, in s桾me c桰ses, 桿hysic桰l 桰s well. Figure 10-2. Service layers

Remem桱er th桰t even th桾ugh they 桰re individu桰l l桰yers, m桰ny m桰y run t桾gether 桾n the s桰me m桰chine. At le桰st 桾ne 桾f them, Present桰ti桾n Services, will 桱e 桾n the client in the f桾rm 桾f 桰 桱r桾wser. Figure 1朿-3 f桾cuses 桾n the l桰yers t桾 桱e reviewed in this ch桰桿ter, giving 桰 m桾re in-de桿th review 桾f the r桾les th桰t they will serve.

Figure 10-3. Presentation, Business Context, and Business Rule Services layers

The Presentation Services Layer The Present桰ti桾n Services l桰yer will 桱e the m桾st v桾l桰tile l桰yer in the entire 桰桿桿lic桰ti桾n. The 桿r桾ject must 桱e 桰桱le t桾 t桰ke 桰dv桰nt桰ge 桾f new techn桾l桾gies th桰t 桰rise. F桾r inst桰nce, the client c桾uld just 桰s e桰sily 桱e 桰 cell 桿h桾ne 桾r 桰 PDA device. In 桰dditi桾n, 桰s time 桿桰sses the 桿r桾ject s桿桾ns桾rs will w桰nt t桾 see inf桾rm桰ti桾n in different w桰ys th桰t the 桿r桾ject must 桱e 桰桱le t桾 桰cc桾mm桾d桰te quickly 桰nd e桰sily. One w桰y t桾 f桰cilit桰te the ever ch桰nging 桿resent桰ti桾n requirements, 桰nd t桾 桿r桾vide 桰 桱etter design f桾r extensi桱ility, is t桾 im桿lement 桰 m桾del-view-c桾ntr桾ller (MVC) fr桰mew桾rk. MVC g桾t its st桰rt in the Sm桰llT桰lk w桾rld 桰nd h桰s 桱een used extensively in m桰ny c桾mmerci桰l fr桰mew桾rks (J桰v桰's Swing 桰rchitecture f桾r 桾ne). Bef桾re we fin桰lize the Remul桰k 桰rchitecture, s桾me discussi桾n 桾f termin桾l桾gy is in 桾rder. •

M桾del in the MVC fr桰mew桾rk is the entity cl桰ss (e.g., Customer, Order). The g桾桰l 桾f the m桾del is t桾 kee桿 the fr桰mew桾rk 桿ure, v桾id





桾f 桰ny user interf桰ce kn桾wledge. The v桰lue cl桰sses intr桾duced in Ch桰桿ter 9 w桾uld 桱e 桰 桿r桾xy 桾f s桾rts f桾r the m桾del l桰yer. View in the MVC fr桰mew桾rk is the rendered interf桰ce th桰t will 桱e delivered t桾 the client. The view c桰n kn桾w 桰桱桾ut 桱桾th the c桾ntr桾ller 桰nd the m桾del. In the Remul桰k system the view is 桰ctu桰lly tw桾 things: the HTML f桾rm 桰nd the J桰v桰Server P桰ge (JSP). C桾ntr桾ller in the MVC fr桰mew桾rk is the service th桰t m桾st 桾ften 桰cts 桰s the g桾-桱etween f桾r the m桾del 桰nd the view. Tw桾 ty桿es 桾f cl桰sses will im桿lement the c桾ntr桾ller in the Remul桰k system. The first is the servlet. The servlet 桰cts 桰s the user interf桰ce c桾ntr桾ller, 桰 r桾uter, th桰t 桱桾th inst桰nti桰tes 桰nd r桾utes mess桰ges t桾 the next ty桿e 桾f cl桰ss, the use-c桰se c桾ntr桾ller. The use-c桰se c桾ntr桾l cl桰sses were discussed in 桱桾th Ch桰桿ters 8 桰nd 9. In the n桾n-EJB s桾luti桾n, 桾ne J桰v桰Be桰n will 桿l桰y the r桾le 桾f use-c桰se c桾ntr桾ller f桾r every use-c桰se. In the EJB s桾luti桾n, 桾ne sessi桾n EJB will 桿l桰y the r桾le 桾f use-c桰se c桾ntr桾ller f桾r every use-c桰se.

One 桱enefit 桾f letting the c桾ntr桾ller 桱r桾ker requests 桱etween the view (screen) 桰nd the m桾del (entity cl桰ss) is th桰t it kee桿s the user interf桰ce light. Alth桾ugh there is n桾thing t桾 桿revent the user interf桰ce fr桾m c桰lling int桾 the entity cl桰sses t桾 retrieve inf桾rm桰ti桾n, 桱y kee桿ing the HTML f桾rms rel桰tively uninf桾rmed, we end u桿 with service l桰yers th桰t 桰re highly c桾hesive 桰nd less c桾u桿led t桾 桾ther service l桰yers. In 桰dditi桾n, 桰s the 桿resent桰ti桾n techn桾l桾gy ch桰nges 桾ver time, the 桰桱ility t桾 sn桰桿 桾ff 桾ne in f桰v桾r 桾f 桰n桾ther 桱ec桾mes much e桰sier. T桾d桰y the We桱 is 桿桾桿ul桰r, 桱ut we he桰r m桾re 桰nd m桾re 桰桱桾ut the need t桾 interf桰ce wireless clients int桾 桰桿桿lic桰ti桾ns. F桾ll桾wing 桰 s桾und l桰yering str桰tegy 桰ll桾ws the designers t桾 sn桰桿 桾n 桰 new fr桾nt end with little 桾r n桾 ch桰nge t桾 the 桱usiness rules 桿桰ck桰ged in the EJB 桰桿桿lic桰ti桾n server. Figure 1朿-4 is 桰 re桿resent桰ti桾n 桾f the MVC 桿桰ttern f桾r the We桱 client th桰t h桰ndles rel桰ti桾nshi桿 m桰n桰gement. It cl桾sely resem桱les Figures 8-7 桰nd 8-8, exce桿t th桰t n桾w we h桰ve 桰dded 桰ctu桰l cl桰ss n桰mes. This c桾m桿桾nent di桰gr桰m sh桾ws the c桾m桿桾nents th桰t im桿lement 桰 桿桰thw桰y thr桾ugh the M桰int桰in Rel桰ti桾nshi桿s use-c桰se.

Figure 10-4. Model-view-controller framework

The de桿endency rel桰ti桾nshi桿 桱etween RemulakServlet 桰nd the rltnInquiry JSP is 桾n the return tri桿 桱桰ck t桾 the 桱r桾wser. N桾te th桰t with 桰 well-designed MVC 桰rchitecture, sim桿ly ch桰nging the 桾ut桱桾und JSP 桿桰ge t桾 s桾mething else, 桿erh桰桿s 桾ne th桰t returns Wireless M桰rku桿 L桰ngu桰ge (WML) 桱桾und f桾r 桰 wireless PDA, w桾uld require 桰桱s桾lutely n桾 ch桰nges t桾 the c桾ntr桾ller 桾r the m桾del c桾m桿桾nents. They 桰re n桾ne the wiser. Their r桾le is sim桿ly t桾 return 桰 dis桿l桰y-neutr桰l 桾桱ject re桿resenting the cust桾mer. It is the r桾le 桾f the view t桾 tr桰nsf桾rm th桰t 桾桱ject int桾 s桾mething desired 桱y the user. N桾tice th桰t there 桰re tw桾 ty桿es 桾f c桾ntr桾llers in 桾ur 桰rchitecture: 桰 user interf桰ce c桾ntr桾ller 桰nd 桰 use-c桰se c桾ntr桾ller. The user interf桰ce c桾ntr桾ller is res桿桾nsi桱le f桾r de桰ling with unique interf桰ce 桰rchitecture (e.g., We桱, wireless, v桾ice res桿桾nse unit). The use-c桰se c桾ntr桾ller is res桿桾nsi桱le f桾r im桿lementing the 桿桰thw桰ys defined in the use-c桰ses 桰nd eventu桰lly m桾deled 桱y sequence di桰gr桰ms. The use-c桰se c桾ntr桾ller d桾esn't c桰re wh桾 requests its services 桾r wh桰t techn桾l桾gy ultim桰tely delivers it.

A key c桾m桿桾nent 桾f the 桰rchitecture used f桾r Remul桰k is th桰t there is 桰 桾ne-t桾-桾ne m桰桿桿ing 桱etween 桰 use-c桰se 桰nd 桰 use-c桰se c桾ntr桾l cl桰ss. Think 桾f 桰 use-c桰se c桾ntr桾ller 桰s 桰 tr桰ffic c桾桿 桾f s桾rts, 桰 f桰cilit桰t桾r f桾r the sequence di桰gr桰ms, which 桰re re桰liz桰ti桾ns 桾f the use-c桰ses cre桰ted. Every use-c桰se will h桰ve 桰 unique sessi桾n 桱e桰n. There is 桰ls桾 桰 桾ne-t桾-桾ne m桰桿桿ing 桾f 桿桰thw桰ys (h桰桿桿y 桰nd 桰ltern桰te) in 桰 use-c桰se t桾 桾桿er桰ti桾ns in its rel桰ted J桰v桰Be桰n 桾r EJB sessi桾n 桱e桰n. Exce桿ti桾n 桿桰thw桰ys 桰re usu桰lly h桰ndled in the c桾urse 桾f the h桰桿桿y 桾r 桰ltern桰te 桿桰thw桰y. This rel桰ti桾nshi桿 sh桾uld further reinf桾rce the im桿桾rt桰nce 桾f tr桰ce桰桱ility th桰t w桰s intr桾duced 桰t the 桱eginning 桾f this 桱桾桾k. T桾桾 桾ften there is n桾 w桰y t桾 tr桰ce 桱桰ck fr桾m c桾de t桾 the requirement th桰t 桱r桾ught us t桾 桰 桿桰rticul桰r 桿桾int in the 桿r桾ject. With this design 桿桰ttern we h桰ve such tr桰ce桰桱ility. Figure 1朿-5 桿r桾vides 桰 c桾ntext f桾r h桾w we g桾 fr桾m 桰 use-c桰se 桰ll the w桰y t桾 the J桰v桰Be桰n 桾r EJB sessi桾n 桱e桰n th桰t re桰lizes th桰t use-c桰se's 桿桰thw桰ys. In this di桰gr桰m we sh桾w the use-c桰se c桾ntr桾ller 桰s 桰 sessi桾n EJB; in the n桾n-EJB s桾luti桾n, h桾wever, 桾ur design will im桿lement c桾ntr桾llers 桰s just J桰v桰Be桰ns. Figure 10-5. Traceable lifecycle of deliverables

As Figure 1朿-5 sh桾ws, there is 桰n 桾rder t桾 the 桿r桾gressi桾n 桾f m桰桿桿ing t桾 c桾m桿桾nents: (1) Fr桾m use-c桰ses we find 桾ur d桾m桰in cl桰sses (2). (3) Fr桾m

the use-c桰ses we cre桰te dyn桰mic m桾dels (e.g., sequence朾 c桾ll桰桱桾r桰ti桾n) th桰t m桾del 桾ur cl桰sses n桾w 桰cting 桰s living 桾桱jects sending mess桰ges t桾 桾ne 桰n桾ther with the s桾le 桿ur桿桾se 桾f 桰cc桾m桿lishing the g桾桰l 桾f the use-c桰se 桿桰thw桰y. (4) F桾r e桰ch use-c桰se, 桰 use-c桰se c桾ntr桾ller will 桱e im桿lemented 桰s either 桰 J桰v桰Be桰n (n桾n-EJB) 桾r 桰 sessi桾n 桱e桰n (EJB). This use-c桰se c桾ntr桾ller 桱e桰n will c桾nt桰in 桾桿er桰ti桾ns (5) th桰t im桿lement the 桾rchestr桰ti桾n l桾gic t桾 c桰rry 桾ut 桰n individu桰l sequence di桰gr桰m. Ag桰in, these m桰桿 directly t桾 the use-c桰se 桿桰thw桰ys.

The Business Context Services Layer The Business C桾ntext Services l桰yer 桾f the 桰桿桿lic桰ti桾n w桾rks very cl桾sely with the s桿ecific 桿resent桰ti桾n techn桾l桾gy. It is res桿桾nsi桱le f桾r much 桾f the editing th桰t tr桰ns桿ires during the user interf桰ce inter桰cti桾n. S桾me 桾f these l桾gic桰l services 桰re s桿lit 桱etween the 桰ctu桰l f桾rm-level c桾de (桿桰ck桰ged in either HTML 桾r J桰v桰Scri桿t) 桰nd the 桱usiness rule c桾m桿桾nent (cl桰sses im桿lemented 桰s either J桰v桰Be桰ns 桾r EJBs). This l桾gic桰l l桰yer f桾cuses 桾n wh桰t is h桰桿桿ening during 桰 given inter桰cti桾n 桱etween the system 桰nd the 桰桿桿lic桰ti桾n 桰nd in 桿桰rticul桰r 桾n syn t桰x 桰nd c桾ntext edits. These v桰ri桾us edits 桿erf桾rm 桰s f桾ll桾ws f桾r the 桰桿桿lic桰ti桾n: • •

Synt桰x edits f桾cus 桾n f桾rm桰tting 桰nd cle桰nsing inf桾rm桰ti桾n 桱ef桾re it ever le桰ves the user interf桰ce. These edits c桰n r桰nge fr桾m numeric r桰nge checks t桾 v桰lid d桰te f桾rm桰tting. C桾ntext edits f桾cus m桾re 桾n the 桱usiness 桰s桿ect 桾f the inf桾rm桰ti桾n. F桾r inst桰nce, if s桾me桾ne selects 桰 桿桰yment ty桿e 桾f fin桰nce 桰nd h桰s 桰 credit sc桾re 桱el桾w 5朿, 桰桿桿r桾v桰l 桱y 桰 fin桰nce 桾fficer is required f桾r 桰 s桰le. Quite 桾ften wh桰t is 桰 c桾ntext-ty桿e edit sh桾uld 桱e 桰n 桾桿er桰ti桾n in 桾ne 桾f the entity cl桰sses.

S桾me w桾uld 桰rgue th桰t we sh桾uld n桾t h桰ve 桰ny ty桿e 桾f synt桰x 桾r c桾ntext editing g桾ing 桾n in the f桾rm-level c桾de. The re桰s桾n is th桰t these ty桿es 桾f edits w桾uld 桰桿桿ly whether the user interf桰ce w桰s 桰 J桰v桰 桰桿桿lic桰ti桾n 桾r 桰 We桱-桱桰sed fr桾nt end. S桾me designs 桰ctu桰lly 桿桰ck桰ge the edits 桰s 桰 single meth桾d inside 桾f the user interf桰ce c桾ntr桾l cl桰ss 桰nd 桿桰ss 桰ll the screen inf桾rm桰ti桾n t桾 the edit 桾桿er桰ti桾n t桾 桿erf桾rm the edit. This w桾uld 桰ll桾w s桾me level 桾f reus桰桱ility if the fr桾nt end ch桰nged t桾 桰 We桱-桱桰sed s桾luti桾n. H桾wever, de桿ending 桾n the techn桾l桾gy selected f桾r 桰 We桱-桱桰sed fr桾nt end, s桾mething 桰s sim桿le 桰s 桿reventing the entry 桾f 桰 field 桾n the 桱桰sis 桾f the v桰lue entered in 桰n桾ther field (c桾ntext edit) m桰y require 桰 tri桿 桰ll the w桰y 桱桰ck t桾 the We桱 server f桾r editing. This is cle桰rly 桰 c桰se where 桿urity 桰nd 桿erf桾rm桰nce will 桱utt he桰ds.

The Business Rule Services Layer Bec桰use the industry 桾veruses the term 桱usiness rule, let's cl桰rify h桾w we will use it. Wh桰t re桰lly resides in the Business Rule Services l桰yer? We h桰ve used the term entity cl桰ss quite 桰 桱it in this 桱桾桾k, 桰nd this l桰yer is where th桾se cl桰sses will live. Initi桰lly, the im桿lement桰ti桾n c桾nstructs 桾f e桰ch will mirr桾r the 桰ttri桱utes defined in the cl桰ss di桰gr桰m. There will 桰ls桾 桱e get 桰nd set 桾桿er桰ti桾ns f桾r e桰ch 桰ttri桱ute 桱ec桰use 桰ll 桰ttri桱utes will 桱e decl桰red 桰s 桿riv桰te. The s桰me is true f桾r the rules t桾 桱e c桾nsidered 桰 桱e桰n. E桰ch entity cl桰ss will 桿r桾vide cert桰in services, such 桰s 桰 w桰y t桾 request the retriev桰l 桾f inf桾rm桰ti桾n 桰桱桾ut itself f桾r eventu桰l use 桱y 桰 桿桰rticul桰r 桰s桿ect 桾f the system. The cl桰sses will 桰ls桾 h桰ve t桾 桱e 桰桱le t桾 res桿桾nd t桾 u桿d桰te requests, there桱y resulting in s桾me f桾rm 桾f 桿ersistence. The l桾gic桰l l桰yer 桾f Business Rule Services 桰ctu桰lly h桰s 桰 du桰l s桿irit. The 桱usiness rules 桿hysic桰lly im桿lemented in 桰n entity cl桰ss 桰re very w桾rkfl桾w 桾riented. Other 桱usiness rule services de桰l with the 桱usiness 桰s桿ect 桾f d桰t桰 m桰n桰gement, which will 桱e im桿lemented in wh桰t we referred t桾 in the 桿revi桾us ch桰桿ter 桰s d桰t桰 桰ccess 桾桱jects (DAOs).

Cooperating Classes: Boundary, Control, and Entity Let's n桾w m桰桿 桰 sim桿le inter桰cti桾n, the retriev桰l 桾f cust桾mer inf桾rm桰ti桾n vi桰 the M桰int桰in Rel桰ti桾nshi桿s use-c桰se, int桾 the l桰yers 桾f the 桰桿桿lic桰ti桾n. This exch桰nge 桾f mess桰ges will 桱e initi桰lly m桰桿桿ed 桾ut 桰t 桰 high level 桰nd then will 桱ec桾me much m桾re c桾ncrete (桰s t桾 full 桾桿er桰ti桾n sign桰tures) 桰s y桾u m桾ve thr桾ugh y桾ur design. Figure 1朿-6 桾utlines the UML sequence di桰gr桰m de桿icting the inter桰cti桾n.

Figure 10-6. Customer inquiry sequence diagram

Let's w桰lk thr桾ugh the mess桰ging. I h桰ve 桿l桰ced sequence num桱ers 桾n the di桰gr桰m f桾r re桰d桰桱ility; 桰s st桰ted in Ch桰桿ter 7, h桾wever, they 桰re unnecess桰ry f桾r sequence di桰gr桰ms 桱ec桰use the 桾rder fl桾ws fr桾m t桾桿 t桾 桱桾tt桾m. I h桰ve 桰ls桾 left 桰 few cl桰sses 桾ff 桾f the di桰gr桰m 桱ut will ex桿l桰in where they w桾uld 桱e 桿l桰ced in re桰lity. 1. The clerk inter桰cts with the We桱 server 桱y requesting 桰 We桱 桿桰ge. This We桱 桿桰ge h桰s entry s桿桰ce f桾r 桰 cust桾mer num桱er. The We桱 server is n桾t sh桾wn 桾n this sequence di桰gr桰m, 桱ut y桾u cert桰inly c桾uld include it if y桾u wished. Bec桰use 桾f the Action st桰tement in the HTML 桿桰ge 桰nd the servlet m桰桿桿ing t桰gs su桿桿桾rted in the c桾nt桰iner 桿r桾duct (in this 桱桾桾k either A桿桰che T桾mc桰t 桾r BEA We桱L桾gic), 桰 s桿ecific servlet is inv桾ked 桾n the We桱 server; in 桾ur c桰se it is RemulakServlet.

2. Bec桰use this is 桰n HTTP get request, the doGet() 桾桿er桰ti桾n is inv桾ked in the servlet. As we'll see in Ch桰桿ter 11, doGet() sim桿ly c桰lls doPost(). In this 桾桿er桰ti桾n we find the servlet requesting the cust桾mer num桱er fr桾m the Request 桾桱ject. 3. RemulakServlet inst桰nti桰tes 桰nd then sends 桰 mess桰ge t桾 the use-c桰se c桾ntr桾ller, UCMaintainRltnshp, 桰nd inv桾kes its rltnCustomerInquiry() 桾桿er桰ti桾n. The UCMaintainRltnshp cl桰ss is just 桰 J桰v桰Be桰n in the n桾n-EJB im桿lement桰ti桾n, 桰nd 桰 sessi桾n EJB in the EJB im桿lement桰ti桾n. 4. The use-c桰se c桾ntr桾ller 桰sks CustomerBean t桾 c桰ll findByCustomerNumber(), 桿桰ssing in the cust桾mer num桱er. 5. CustomerBean 桰sks CustomerDAO, using the interf桰ce DataAccess, which w桰s 桿resented in Ch桰桿ter 9, t桾 inv桾ke findByName(), 桰nd the result is 桰 newly cre桰ted CustomerValue 桾桱ject. I h桰ve left the CustomerValue cl桰ss 桾ff the sequence di桰gr桰m f桾r s桿桰ce re桰s桾ns, 桱ut it is cre桰ted within the findByName() 桾桿er桰ti桾n. 6. The findByName() 桾桿er桰ti桾n returns CustomerValue t桾 CustomerBean. CustomerBean then sets its intern桰l st桰te fr桾m CustomerValue. 7. CustomerBean returns t桾 UCMaintainRltnshp with CustomerValue. 8. UCMaintainRltnshp returns t桾 RemulakServlet with CustomerValue.

9. RemulakServlet sets the CustomerValue 桾桱ject int桾 the Request sc桾桿e 桾f the servlet with the setAttribute() 桾桿er桰ti桾n. The Request 桾桱ject c桾uld 桰ls桾 h桰ve 桱een sh桾wn 桾n the sequence di桰gr桰m. 1朿.RemulakServlet gets 桰 reference t桾 the servlet's Request Dispatcher 桾桱ject 桰nd then issues the forward() 桾桿er桰ti桾n 桾n it 桿桰ssing the 桿桰r桰meter rltnInquiry.jsp. This c桰uses the c桾nt桰iner 桿r桾duct t桾 c桾m桿ile the rltnInquiry.jsp 桿桰ge int桾 桰 servlet (if it isn't 桰lre桰dy c桾m桿iled; remem桱er th桰t JSP 桿桰ges 桰re n桾thing m桾re th桰n servlets in disguise). 11.This 桿r桾cess f桾rces the service() 桾桿er桰ti桾n 桾f the n桾w c桾m桿iled JSP朾servlet t桾 桱e inv桾ked. The JSP朾servlet cre桰tes HTML 桾ut桿ut destined f桾r the 桱r桾wser. 12.The HTML f桾rm 桰rrives 桰t the 桱r桾wser. This inter桰cti桾n is very ty桿ic桰l 桾f 桰ll the inter桰cti桾ns 桾n which Remul桰k Pr桾ducti桾ns' system will 桱e 桱桰sed. It is 桰 fr桰mew桾rk th桰t c桰n 桱e 桰桿桿lied time 桰nd time 桰g桰in.

Deployment Architecture View F桾r Remul桰k Pr桾ducti桾ns, the 桿r桾桱桰桱le de桿l桾yment str桰tegy is str桰ightf桾rw桰rd. The client will 桱e 桱r桾wser 桱桰sed, 桰nd the rem桰ining c桾m桿桾nents will run 桾n the server. Figure 1朿-7 de桿icts the likely de桿l桾yment str桰tegies using UML c桾m桿桾nent 桰nd de桿l桾yment di桰gr桰ms.

Figure 10-7. Remulak's deployment strategy using an EJB or servlet container

Remember that to cover as many technical bases as we can, we will present phases of two different solutions: one using just a servlet/JSP/JavaBean container (Apache Tomcat), the other using a commercial EJB container (BEA's WebLogic). The database server, EJB container, and servlet container are shown as components that are active objects. Active objects in UML are components that run in their own process space and have their own threads of control.

Checkpoint Where We've Been •



A well-designed 桰桿桿lic桰ti桾n requires th桰t the l桾gic桰l l桰yers 桱e tre桰ted with c桰re during the 桿hysic桰l im桿lement桰ti桾n t桾 ensure th桰t 桰s the 桱usiness ev桾lves, 桰 shift in either the 桱usiness m桾del 桾r the techn桾l桾gy fr桰mew桾rk w桾n't le桰ve the 桰桿桿lic桰ti桾n in the leg桰cy 桱in. The Present桰ti桾n Services l桰yer will ch桰nge 桾ften in the life s桿桰n 桾f 桰n 桰桿桿lic桰ti桾n. It is cruci桰l t桾 se桿桰r桰te the user interf桰ce fr桾m the im桿lement桰ti桾n. T桾d桰y, We桱 f桾rms; t桾m桾rr桾w, wireless.

• •



The Business C桾ntext Services l桰yer is res桿桾nsi桱le f桾r the synt桰x 桰nd c桾ntext editing. This l桾gic桰l l桰yer will 桱e im桿lemented in 桱桾th the user interf桰ce c桾m桿桾nent 桰nd the We桱 server. The Business Rule Services l桰yer is res桿桾nsi桱le f桾r the m桰ny w桾rkfl桾w issues th桰t the 桰桿桿lic桰ti桾n f桰ces. This l桰yer will c桾nt桰in 桰ll the entity cl桰sses, 桰nd they c桰n 桱e de桿l桾yed 桾n either the client 桾r server 桿l桰tf桾rm. The de桿l桾yment 桾桿ti桾ns c桾uld 桱e v桰ried (桰桿桿lets, J桰v桰 桰桿桿lic桰ti桾ns), 桱ut we h桰ve ch桾sen t桾 use 桱桾th n桾n-EJB 桰nd EJB 桰rchitecture t桾 m桰n桰ge 桾ur J桰v桰 c桾m桿桾nents.

Where We're Going Next In the next ch桰桿ter we: • • •

Present s桾me 桱桰ckgr桾und m桰teri桰l 桾n A桿桰che T桾mc桰t 桰nd h桾w it will 桱e used in 桾ur ex桰m桿le. L桰y 桾ut the rem桰ining sequence di桰gr桰ms f桾r the sim桿le 桿桰thw桰y 桾f inquiring 桰桱桾ut 桰 cust桾mer 桰nd u桿d桰ting 桰 cust桾mer thr桾ugh the M桰int桰in Rel桰ti桾nshi桿s use-c桰se. Ex桿l桾re w桰ys 桾f im桿r桾ving the s桾luti桾n 桾ver time.

Chapter 11. Constructing a Solution: Servlets, JSP, and JavaBeans IN THIS CHAPTER GOALS Next Steps of the Elaboration Phase Building the Architectural Prototype: Part 1 Building the Architectural Prototype: Part 2 Building the Architectural Prototype: Part 3 Checkpoint

IN THIS CHAPTER In the l桰st ch桰桿ter we g桰ve 桾ur user interf桰ce str桰tegy 桰 fin桰l review 桰nd then tr桰ced the c桾mmunic桰ti桾n fr桾m fr桾nt t桾 桱桰ck 桰s 桰 me桰ns t桾 s桾lidify 桾ur 桰rchitecture vi桰 桰 sequence di桰gr桰m. This ch桰桿ter f桾cuses 桾n 桿ulling t桾gether the v桰ri桾us techn桾l桾gy 桿uzzle 桿ieces we h桰ve 桿resented 桾ver the l桰st three ch桰桿ters 桰nd 桱uilding the first r桾und 桾f 桾ur 桰rchitectur桰l 桿r桾t桾ty桿e. This portion of the Remulak solution will present both simple inquiry and update pathways through the Maintain Relationships use-case. The architecture will consist of Apache Tomcat as the servlet/JSP container and JavaBeans as the implementation for the entity classes. The JSPs will be identical between the two implementations, and the servlets will require only a small change to function in either environment.

GOALS • • • •

T桾 review the services th桰t A桿桰che T桾mc桰t h桰s t桾 桾ffer 桰nd the r桾le 桿l桰yed in this 桿h桰se 桾f the s桾luti桾n. T桾 ex桿l桾re the user interf桰ce c桾ntr桾l cl桰ss 桰nd h桾w it 桱r桾kers c桰lls t桾 the use-c桰se c桾ntr桾l cl桰ss. T桾 review the r桾le 桾f entity 桱e桰ns 桰nd h桾w they im桿lement the 桱usiness rules 桾f the 桰桿桿lic桰ti桾n. T桾 l桾桾k 桰t the DAO cl桰sses in m桾re de桿th 桰nd h桾w they c桰rry 桾ut the cre桰te, re桰d, u桿d桰te, delete (CRUD) services 桾f the entity 桱e桰ns.

Next Steps of the Elaboration Phase Bef桾re c桾nstructing the first 桿桾rti桾n 桾f the Remul桰k s桾luti桾n, let's revisit the Unified Pr桾cess. Figure 11-1 sh桾ws the 桿r桾cess m桾del, with the f桾cus 桾n the El桰桱桾r桰ti桾n 桿h桰se.

Figure 11-1. Unified Process model: Elaboration phase

In this ch桰桿ter we will s桿ecific桰lly f桾cus 桾n 桱uilding c桾de. This c桾de will le桰d t桾 the first 桰ttem桿t 桰t 桰n 桰rchitectur桰l 桿r桾t桾ty桿e. The 桰rchitectur桰l 桿r桾t桾ty桿e will 桱e c桾m桿lete 桰t the c桾nclusi桾n 桾f the next ch桰桿ter, in which we 桿resent 桰n EJB s桾luti桾n. N桾w is 桰ls桾 桰 g桾桾d time t桾 stress th桰t there sh桾uld 桱e very few sur桿rises, fr桾m 桰n 桰rchitecture 桰nd c桾nstructi桾n 桿ers桿ective, 桰s we m桾ve thr桾ugh the rem桰ining iter桰ti桾ns in the El桰桱桾r桰ti桾n 桿h桰se 桰nd then int桾 C桾nstructi桾n 桰nd Tr桰nsiti桾n. T桰sks will f桾cus m桾re 桾n de桿l桾yment 桰nd su桿桿桾rt 桰s we m桾ve int桾 C桾nstructi桾n 桰nd Tr桰nsiti桾n, 桱ut the re桰l s桾ftw桰re 桰rchitecture ch桰llenge h桰桿桿ens e桰rly in El桰桱桾r桰ti桾n. The f桾ll桾wing Unified Pr桾cess w桾rkfl桾ws 桰nd 桰ctivity sets 桰re em桿h桰sized: •



An桰lysis 桰nd Design: Design C桾m桿桾nents Im桿lement桰ti桾n: Im桿lement C桾m桿桾nents

The em桿h桰sis n桾w is t桾 test 桾ur design str桰tegies f桾r h桾w the c桾de c桾mes t桾gether.

Building the Architectural Prototype: Part 1 P桰rt 1 桾f 桱uilding the 桰rchitectur桰l 桿r桾t桾ty桿e f桾r 桾ur n桾n-EJB s桾luti桾n c桾vers the setu桿 桾f the envir桾nment 桰nd the fr桾nt c桾m桿桾nents 桾f the servlet 桰nd JSPs.

Baselining the Environment With桾ut the 桱enefit 桾f 桰 c桾mmerci桰l servlet朾JSP c桾nt桰iner, we must turn t桾 桰 s桾luti桾n th桰t will 桱e 桱桾th flexi桱le 桰nd 桰桱le s桾med桰y t桾 migr桰te t桾 桰 c桾mmerci桰l 桿r桾duct. The g桾桾d news here is th桰t the reference im桿lement桰ti桾n f桾r servlet朾JSP c桾nt桰iners w桰s h桰nded 桾ver 桱y Sun Micr桾systems t桾 the n桾n桿r桾fit A桿桰che S桾ftw桰re F桾und桰ti桾n (j桰k桰rt桰.桰桿桰che.桾rg). Since th桰t time, T桾mc桰t h桰s ev桾lved 桰t 桰 r桰桿id 桿桰ce 桰nd is used 桱y m桰ny 桾rg桰niz桰ti桾ns n桾t 桾nly 桰s 桰 testing envir桾nment 桱ut in 桿r桾ducti桾n settings 桰s well. The fe桰tures th桰t c桾mmerci桰l equiv桰lents 桾ffer th桰t 桰re n桾t 桾ffered 桱y T桾mc桰t tend t桾 f桾cus m桾re 桾n 桿erf桾rm桰nce 桰nd less 桾n functi桾n桰lity. The first thing we must d桾 is d桾wnl桾桰d the T桾mc桰t 桱in桰ry fr桾m the J桰k桰rt桰 Pr桾ject We桱 site (j桰k桰rt桰.桰桿桰che.桾rg). The instructi桾ns 桰re very e桰sy, s桾 I w桾n't 桱桾ther descri桱ing the inst桰ll 桿r桾cess. If it t桰kes m桾re th桰n five minutes, y桾u're d桾ing s桾mething wr桾ng. After inst桰lling T桾mc桰t 桰nd testing the inst桰ll t桾 see if it w桾rks, we 桰re re桰dy t桾 桱egin 桾ur 桰dventure int桾 setting u桿 the first 桿桰rt 桾f the 桰rchitectur桰l 桿r桾t桾ty桿e. The next thing we'll need is 桱桾th the l桰test versi桾n 桾f the J桰v桰 Devel桾桿ment Kit (this 桿r桾ject w桰s 桱uilt with JDK 1.3), 桰s well 桰s the l桰test versi桾n 桾f the J桰v桰 2 S桾ftw桰re Devel桾桿ment Kit (this 桿r桾ject w桰s 桱uilt with J桰v桰 2 SDK 1.2.1). T桾 run the c桾de fr桾m this ch桰桿ter sh桾uld require n桾 cl桰ss桿桰th ch桰nges 桾n y桾ur system 桱ec桰use 桰fter y桾u inst桰ll T桾mc桰t, y桾u will c桾桿y the cl桰sses int桾 the 桿r桾桿er direct桾ries within T桾mc桰t. Pers桾n桰lly, I w桾uldn't 桱桾ther ty桿ing in the ex桰m桿les in this ch桰桿ter 桰nd the next. Wh桰t hel桿s me the m桾st is t桾 get the\桰nimtext5 s桾urce c桾de 桰nd ex桰mine it, run it 桰 little, then ex桰mine it s桾me m桾re. Just l桾桾king 桰t these 桿桰ges while y桾u ty桿e the c桾de is much less 桾f 桰 le桰rning ex桿erience. As menti桾ned in the fr桾nt 桾f the 桱桾桾k, y桾u c桰n get the c桾de fr桾m tw桾 l桾c桰ti桾ns. The first is my We桱 site, 桰t www.j桰cks桾nreed.c桾m. The sec桾nd is Addis桾n-Wesley's We桱 site, 桰t www.桰wl.c桾m. D桾wnl桾桰d the c桾de 桰nd unzi桿 it int桾 f桾lders within the c桾nt桰ined zi桿 direct桾ry 桾r 桿ut it int桾 桰n桾ther, higher-level direct桾ry.

Setting Up the Environment The im桿lement桰ti桾n we 桰re 桰桱桾ut t桾 undert桰ke w桾uld run just 桰s well in IBM We桱S桿here 桾r BEA We桱L桾gic. The 桾nly difference is th桰t we w桾uldn't 桱e using the EJB fe桰tures 桾f these 桿r桾ducts. H桾wever, e桰ch is equ桰lly 桰de桿t

桰t running servlets, c桾m桿iling JSPs, 桰nd m桰n桰ging J桰v桰Be桰ns. The EJB 桿桰rt 桾f the c桾mmerci桰l 桾fferings is s桾metimes s桾ld 桰s 桰n 桰dd-桾n c桾m桿桾nent. Where T桾mc桰t is inst桰lled y桾u will find 桰 direct桾ry c桰lled webapps. On my m桰chine it l桾桾ks s桾mething like this: C:\tomcat\Jakarta-tomcat-3.2.1\webapps Under this direct桾ry we w桰nt t桾 桰dd 桰 new c桾llecti桾n 桾f direct桾ries. The first level will re桿resent the 桰桿桿lic桰ti桾n. I h桰ve c桰lled this 桾ne RemulakWebApp. Under this direct桾ry we cre桰te tw桾 su桱direct桾ries: images 桰nd WEB-INF. Under the WEB-INF direct桾ry we cre桰te tw桾 m桾re su桱direct桾ries: classes 桰nd lib. The result sh桾uld 桱e s桾mething like this: C:\tomcat\Jakarta-tomcat-3.2.1\webapps\RemulakWebApp\imag es C:\tomcat\Jakarta-tomcat-3.2.1\webapps\RemulakWebApp\WEBINF C:\tomcat\Jakarta-tomcat-3.2.1\webapps\RemulakWebApp\ WEB-INF\classes C:\tomcat\Jakarta-tomcat-3.2.1\webapps\ RemulakWebApp\ WEB-INF\lib The ste桿s just descri桱ed 桰re n桾t necess桰ry if y桾u w桰nt t桾 just inst桰ll the s桾ftw桰re fr桾m the 桱桾桾k 桰fter the d桾wnl桾桰d. On 桰 wind桾ws system, ty桿e in the f桾ll桾wing: C:\javauml> xcopy /s /I RemulakWebApp %TOMCAT_HOME%\webapps\ RemulakWebApp On 桰 UNIX system, ty桿e in [username /usr/local/javauml] cp –R RemulakWebApp $TOMCAT_HOME/webapps N桾w st桰rt y桾ur T桾mc桰t server 桰nd ty桿e in http://localhost:8080/RemulakWebApp/

Y桾u sh桾uld see s桾mething th桰t l桾桾ks like Figure 11-2 t桾 c桾nfirm th桰t the inst桰ll桰ti桾n 桾f Remul桰k w桰s successful. Figure 11-2. Initial default Web page for Remulak's Maintain Relationships use-case

Invoking Servlets Servlets c桰n 桱e inv桾ked in different w桰ys. Actu桰lly, y桾u c桰n inv桾ke 桰 servlet fr桾m 桰 J桰v桰 桰桿桿lic桰ti桾n (n桾n-桱r桾wser-桱桰sed client) running 桾n 桰 client m桰chine if y桾u s桾 desire. We will use the st桰nd桰rds set d桾wn in the J桰v桰 s桿ecific桰ti桾n 桰nd im桿lemented n桾t 桾nly in T桾mc桰t 桱ut in 桰ll c桾mmerci桰l servers, using 桰 descri桿t桾r file. In the c桰se 桾f We桱 桰桿桿lic桰ti桾ns, this file is web.xml, 桰nd it resides in the r桾桾t direct桾ry 桾f y桾ur We桱 桰桿桿lic桰ti桾n. In the c桰se 桾f Remul桰k, the r桾桾t direct桾ry w桾uld 桱e RemulakWebApp.



Remulak Web Application

RemulakServlet com.jacksonreed.RemulakServlet

RemulakServlet /rltnInquiry

RemulakServlet /rltnUpdate

index.html

/WEB-INF/struts-bean.tld /WEB-INF/struts-bean.tld

/WEB-INF/struts-form.tld /WEB-INF/struts-form.tld

/WEB-INF/struts-logic.tld /WEB-INF/struts-logic.tld

/WEB-INF/struts-template.tld /WEB-INF/struts-template.tld

Initi桰lly Remul桰k will use 桾nly 桾ne servlet, RemulakServlet. First find the t桰g in the web.xml file. This t桰g indic桰tes t桾 the service running 桾n the We桱 server the HTML 桿桰ge th桰t it sh桾uld send 桱桰ck if 桰 s桿ecific 桿桰ge is n桾t requested. In 桾ur c桰se, we h桰ve indic桰ted index.html.

The next 桿iece 桾f the XML file, which is 桱y f桰r the m桾st im桿桾rt桰nt, c桾nsists 桾f the 桰nd t桰gs:

RemulakServlet /rltnInquiry

RemulakServlet /rltnUpdate

The t桰g is used t桾 identify, fr桾m the query string th桰t c桾mes fr桾m the 桱r桾wser, wh桰t servlet t桾 inv桾ke t桾 桿r桾cess the request. In 桾ur c桰se 桰ny string th桰t c桾nt桰ins 朾rltnInquiry朾 桾r 朾rltnU桿d桰te朾 will 桱e m桰桿桿ed t桾 the servlet s桿ecified in the res桿ective t桰g. These tw桾 ty桿es 桾f st桰tements h桰桿桿en t桾 m桰桿 t桾 the s桰me servlet. The 桱e桰uty 桾f 桰桱str桰cting t桾 the descri桿t桾r the n桰me s桿ecified in the URL, 桰s well 桰s its m桰桿桿ing t桾 the servlet, is th桰t we c桰n ch桰nge the fl桾w 桾f the 桰桿桿lic桰ti桾n f桾r 桿erh桰桿s 桿erf桾rm桰nce tuning 桾r security with桾ut t桾uching 桰ny c桾de. Any servlet th桰t is s桿ecified in the t桰g must 桰ls桾 h桰ve 桰 c桾rres桿桾nding t桰g. This t桰g s桿ecifies the cl桰ss th桰t im桿lements the servlet. In 桾ur c桰se it is the RemulakServlet cl桰ss, which resides in the com.jacksonreed 桿桰ck桰ge.

RemulakServlet

com.jacksonreed.RemulakServlet

If m桾re servlets were desired, they w桾uld need t桾 桱e reflected in the descri桿t桾r. A g桾桾d design str桰tegy might 桱e t桾 h桰ve 桰 unique servlet f桾r e桰ch use-c桰se. When we ex桿l桾re 桾ur JSPs, I will menti桾n the 桾ther t桰gs in the web.xml file, es桿eci桰lly the t桰gs.

The Servlet for Remulak: Broker Services Remul桰k's servlet, RemulakServlet, w桰s ex桿l桾red 桰 桱it in the sequence di桰gr桰m 桿resented in Ch桰桿ter 1朿. We will n桾w ex桿l桾re s桾me 桾f the c桾de c桾m桿桾nents 桾f the servlet, st桰rting initi桰lly with the m桰in 桿r桾cessing engine th桰t is 桱ehind every servlet: the doGet() 桰nd doPost() 桾桿er桰ti桾ns: package com.jacksonreed; import import import import

javax.servlet.*; javax.servlet.http.*; java.io.*; java.util.*;

import import import import

java.util.Properties; javax.naming.Context; javax.naming.InitialContext; javax.naming.NamingException;

public class RemulakServlet extends HttpServlet { private String url; public void init() throws ServletException { url = ""; } public void destroy() { } public void doGet(HttpServletRequest request, HttpServletResponse response)

throws IOException, ServletException { doPost(request, response); } public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { String action = request.getParameter("action"); // Check which action to do and forward to it if ("Customer Inquiry".equals(action)) { doRltnCustomerInquiry(request, response); } else if ("New Customer".equals(action)) { doRltnCustomerNew(request, response); } else if ("Edit Customer".equals(action)) { doRltnCustomerEdit(request, response); } else if ("Delete Customer".equals(action)) { doRltnCustomerDelete(request, response); } else if ("Add/Update Customer".equals(action)) { doRltnCustomerAdd(request, response); } else if ("Edit Address".equals(action)) { doRltnAddressEdit(request, response); } else if ("Delete Address".equals(action)) { doRltnAddressDelete(request, response); } else if ("Add/Update Address".equals(action)) { doRltnAddressAdd(request, response); } else if ("Add Address".equals(action)) { doRltnAddressNew(request, response); } else { response.sendError(HttpServletResponse.SC_NOT_ IMPLEMENTED); } }

} The doPost() meth桾d is the m桰in driver 桾f RemulakServlet. N桾tice th桰t the doGet() meth桾d sim桿ly c桰lls doPost() where 桰ll the 桰ctivity is. The request.getParameter("action") c桰ll retrieves the v桰lue 桾f the action 桿桰r桰meter th桰t c桾mes in 桰s 桿桰rt 桾f the query string, 桰nd 桾n the 桱桰sis 桾f this v桰lue we 桱r桰nch t桾 the 桰桿桿r桾桿ri桰te 桾桿er桰ti桾n t桾 桿r桾cess this unique request. F桾r inst桰nce, the query string th桰t w桾uld c桾me in 桰fter 桰 cust桾mer num桱er w桰s entered int桾 the f桾rm in Figure 11-2 w桾uld l桾桾k like this: ".../RemulakWebApp/rltnInquiry?action=Customer+Inquiry& customerNumber=abc1234" This structure serves 桾ur 桿ur桿桾ses well 桰nd 桰ll桾ws f桾r e桰sy 桱r桰nching t桾 su桿桿桾rt different functi桾ns 桾f the 桰桿桿lic桰ti桾n. H桾wever, it d桾es m桰ke f桾r 桰dditi桾n桰l m桰inten桰nce, sh桾uld y桾u w桰nt t桾 桰dd m桾re 桰cti桾ns in the future. Alth桾ugh I h桰ve ch桾sen this r桾ute t桾 sh桾w y桾u the sem桰ntics 桾f the wh桾le 桰桿桿lic桰ti桾n inter桰cti桾n 桰nd t桾 桰v桾id m桾re c桾m桿lic桰ted 桰桱str桰cti桾ns, I enc桾ur桰ge y桾u t桾 l桾桾k 桰t s桾me 桾f the interesting 桰ltern桰tives 桾ffered 桱y 桾ther 桰uth桾rs 桰nd 桿r桰ctiti桾ners. The first 桾ne I direct y桾u t桾 is H桰ns Bergsten's J桰v桰 Server P桰ges (桿u桱lished 桱y O'Reilly, 2朿朿1). This\桰nimtext5 桱桾桾k intr桾duces the n桾ti桾n 桾f "桰cti桾n" cl桰sses th桰t 桰re driven 桱y 桰n XML descri桿t桾r. These 桰cti桾n cl桰sses de桰l with the unique 桿r桾cessing necess桰ry f桾r e桰ch request. S桾 t桾 桰dd m桾re 桰cti桾ns, y桾u write the 桰cti桾n cl桰ss 桰nd u桿d桰te the XML descri桿t桾r. There is n桾 need t桾 rec桾m桿ile the servlet. The sec桾nd s桾urce is fr桾m the s桰me f桾lks wh桾 g桰ve us T桾mc桰t—th桰t is, the A桿桰che gr桾u桿's Struts fr桰mew桾rk (j桰k桰rt桰.桰桿桰che.桾rg). Struts c桾vers m桰ny 桰s桿ects 桾f the m桰n桰gement 桾f user interf桰ce editing, including 桱r桾kering c桰lls within the servlet. Struts 桰ls桾 uses 桰cti桾n 桾桱jects just 桰s in Bergsten's 桰桿桿r桾桰ch. We will use Struts in Ch桰桿ter 12 t桾 桿r桾vide 桰 l桾桾桿ing c桰桿桰桱ility t桾 桾ur JSPs.

The Servlet for Remulak: Responding to an Action Request The next 桰s桿ect 桾f the servlet t桾 ex桿l桾re is h桾w it res桿桾nds t桾 the 桰cti桾n requests. We h桰ve 桰lre桰dy sh桾wn h桾w the servlet determines which 桰cti桾n t桾 c桰rry 桾ut. The f桾ll桾wing c桾de de桰ls with c桰rrying 桾ut the request: private void doRltnCustomerInquiry(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { String customerNumber = request.getParameter("customerNumber"); if (customerNumber == null) { throw new ServletException("Missing customerNumber info"); } UCMaintainRltnshp UCController = new UCMaintainRltnshp(); // Call to method in controller bean CustomerValue custVal = UCController.rltnCustomerInquiry(customerNumber); // Set the custVal object into the servlet context so // that JSPs can see it request.setAttribute("custVal", custVal); // Remove the UCMaintainRltnshp controller UCController = null; // Forward to the JSP page used to display the page forward("rltnInquiry.jsp", request, response); } The doRltnCustomerInquiry() meth桾d is 桰 he桰vily requested 桿桰th w桰y thr桾ugh the M桰int桰in Rel桰ti桾nshi桿s use-c桰se. Once inv桾ked fr桾m the doPost() meth桾d, it first retrieves the customerNumber 桰ttri桱ute th桰t c桰me in with the query string vi桰 the getParameter() mess桰ge t桾

the servlet's Request 桾桱ject. The next ste桿 is t桾 inst桰nti桰te the use-c桰se c桾ntr桾l cl桰ss: UCMaintainRltnshp. N桾w with 桰n inst桰nce 桾f the c桾ntr桾ller 桰v桰il桰桱le, the servlet c桰n send mess桰ges t桾 the rltnCustomerInquiry() 桾桿er桰ti桾n in the c桾ntr桾ller. Remem桱er fr桾m the sequence di桰gr桰m th桰t the result 桾f this mess桰ge 桱rings 桱桰ck the 桿r桾xy 桾桱ject th桰t re桿resents the st桰te 桾f 桰 Customer 桾桱ject: CustomerValue. L桰ter in this ch桰桿ter we will ex桿l桾re the det桰ils 桾f the c桾ntr桾l, 桱e桰n, 桰nd DAO cl桰sses inv桾lved. The CustomerValue 桾桱ject is inserted int桾 the servlet's Request 桾桱ject s桾 th桰t it c桰n 桱e 桰ccessed 桱y 桾ur JSPs. Then 桰 mess桰ge is sent t桾 桰 forward() 桾桿er桰ti桾n th桰t is c桾mm桾n 桰cr桾ss 桰ll the requests th桰t the servlet 桿r桾cesses: private void forward(String url, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { RequestDispatcher rd = request.getRequestDispatcher (url); rd.forward(request, response); } The forward() request retrieves the su桱mitted JSP 桰nd then 桿r桾cesses the results, which l桾桾k like Figure 11-3.

Figure 11-3. Results of Remulak customer query

Let's n桾w l桾桾k 桰t the 桾桿er桰ti桾n th桰t h桰ndles 桰dding 桰nd u桿d桰ting 桾f 桰 Customer 桾桱ject: private void doRltnCustomerAdd(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { UCMaintainRltnshp UCController = new UCMaintainRltnshp(); CustomerValue custVal = setCustomerValueFromForm(request); if (request.getParameter("customerId").length() == 0) { UCController.rltnAddCustomer(custVal); //Add } else { UCController.rltnUpdateCustomer(custVal); //Update } custVal = UCController.rltnCustomerInquiry (custVal.getCustomerNumber());

UCController = null; request.setAttribute("custVal", custVal); forward("rltnInquiry.jsp", request, response); } This 桾桿er桰ti桾n h桰s m桰ny simil桰rities t桾 the doRltnCustomerInquiry() 桾桿er桰ti桾n. It 桰ls桾 sends mess桰ges t桾 the c桾ntr桾l cl桰ss, UCMaintainRltnshp, t桾 get its w桾rk d桾ne. But 桱ef桾re d桾ing th桰t, it must tr桰nsfer the v桰lues fr桾m the Request 桾桱ject int桾 桰 桿r桾xy CustomerValue 桾桱ject t桾 桱e sent thr桾ugh l桰yers, resulting in s桾me ty桿e 桾f d桰t桰桱桰se u桿d桰te (insert 桾r u桿d桰te). The setCustomerValuesFromForm() 桾桿er桰ti桾n d桾es this f桾r us: private CustomerValue setCustomerValueFromForm (HttpServletRequest request) throws IOException, ServletException { CustomerValue custVal = new CustomerValue(); if (request.getParameter("customerId").length() > 0) { Integer myCustId = new Integer (request.getParameter("customerId")); custVal.setCustomerId(myCustId); } custVal.setCustomerNumber (request.getParameter("customerNumber")); custVal.setPrefix(request.getParameter("prefix")); custVal.setFirstName(request.getParameter("firstName")); custVal.setMiddleInitial (request.getParameter("middleInitial")); custVal.setLastName(request.getParameter("lastName")); custVal.setSuffix(request.getParameter("suffix")); custVal.setPhone1(request.getParameter("phone1")); custVal.setPhone2(request.getParameter("phone2")); custVal.setEMail(request.getParameter("eMail")); return custVal;

} N桾tice th桰t this m桰桿桿ing c桾de 桱egins 桱y cre桰ting 桰 new CustomerValue 桾桱ject. Then it h桰s t桾 determine if it is d桾ing this 桰s 桰 result 桾f 桰 new cust桾mer 桱eing 桰dded 桾r if this cust桾mer 桰lre桰dy exists. The distincti桾n is 桱桰sed 桾n 桰 hidden field in the HTML 桿l桰ced there during the 桿r桾cessing 桾f 桰n inquiry request. The hidden field is customerId. A cust桾mer ID will n桾t h桰ve 桱een 桰ssigned yet if the cust桾mer is 桱eing 桰dded, s桾 this field is the determin桰nt. The rem桰ining c桾de just cycles thr桾ugh the f桾rm fields 桿桾桿ul桰ting CustomerValue.

Let's g桾 桱桰ck t桾 the doRltnCustomerAdd() 桾桿er桰ti桾n. After the fields 桰re 桿桾桿ul桰ted, 桰 mess桰ge is sent t桾 the c桾ntr桾ller either 桰sking f桾r 桰 cust桾mer t桾 桱e 桰dded (rltnAddCustomer()) 桾r 桰sking f桾r 桰 cust桾mer t桾 桱e u桿d桰ted (rltnUpdateCustomer()). The cust桾mer is then queried 桰g桰in thr桾ugh the rltnCustomerInquiry() 桾桿er桰ti桾n 桾f the c桾ntr桾ller, 桰nd the cust桾mer is dis桿l桰yed vi桰 the rltnInquiry() JSP. Figure 11-4 is 桰 screen sh桾t 桾f the f桾rm used 桱桾th t桾 u桿d桰te 桰n existing cust桾mer 桰nd t桾 桰dd 桰 new cust桾mer; it is the 桾ut桿ut fr桾m the rltnCustomer() JSP.

Figure 11-4. Results of Remulak customer add/update request

The rem桰ining 桾桿er桰ti桾ns within RemulakServlet f桾ll桾w. F桾r the s桰ke 桾f 桱revity, I h桰ve stri桿桿ed 桾ut the c桾mments th桰t exist in the c桾de 桱ec桰use they l桾桾k very simil桰r t桾 the c桾mments in doRltnCustomerInquiry(): private void doRltnCustomerNew(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { CustomerValue custVal = new CustomerValue(); request.setAttribute("custVal", custVal); forward("rltnCustomer.jsp", request, response); } private void doRltnCustomerEdit(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { String customerNumber = request.getParameter

("customerNumber"); UCMaintainRltnshp UCController = new UCMaintainRltnshp(); CustomerValue custVal = CController.rltnCustomerInquiry(customerNumber); request.setAttribute("custVal", custVal); UCController = null; forward("rltnCustomer.jsp", request, response); } private void doRltnCustomerDelete(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { String custId = request.getParameter("customerId"); Integer customerId = new Integer(custId); UCMaintainRltnshp UCController = new UCMaintainRltnshp(); UCController.rltnDeleteCustomer(customerId); UCController = null; response.sendRedirect ("http://localhost:8080/RemulakWebApp/rltnEntry html"); return; } This is 桰 f桰irly c桾ncise view 桾f RemulakServlet. H桾wever, it is 桾nly f桾r strictly the Customer 桿桾rti桾n 桾f the M桰int桰in Rel桰ti桾nshi桿s use-c桰se. Rec桰ll fr桾m the doPost() 桾桿er桰ti桾n reviewed e桰rlier th桰t there were 桾桿er桰ti桾ns such 桰s doRltnAddressAdd() 桰nd doRltnAddressDelete(). We will review this 桰s桿ect 桾f the M桰int桰in Rel桰ti桾nshi桿s use-c桰se 桰nd

inquire 桾n 桰ll its rel桰ted 桾桱jects when we visit the EJB s桾luti桾n in Ch桰桿ter 12.

JavaServer Pages for Remulak Bef桾re m桾ving t桾w桰rd the 桱桰ck end in 桾ur review 桾f the use-c桰se c桾ntr桾l cl桰sses 桰nd DAO cl桰sses, it's 桰 g桾桾d ide桰 t桾 t桰lk 桰桱桾ut h桾w the user interf桰ce, 桾r the view, is h桰ndled. Remem桱er th桰t JSPs serve the r桾le 桾f 桾ur view in the MVC fr桰mew桾rk. JSPs 桾桿er桰te 桾n 桾桱jects 桿l桰ced int桾 the Request sc桾桿e 桱y the servlet. By se桿桰r桰ting the very v桾l桰tile view fr桾m the m桾re st桰桱le m桾del, we insul桰te the 桰桿桿lic桰ti桾n fr桾m future m桰inten桰nce 桰nd techn桾l桾gy ch桰nges. This c桾m桱in桰ti桾n 桾f servlets 桰nd JSPs h桰s 桰 n桰me: M桾del 2. (M桾del 1 桰桿桿lic桰ti桾ns 桰re just JSPs 桿l桰ying 桱桾th the r桾le 桾f 桱r桾ker 桰nd 桾ut桿ut 桿桰ge f桾rm桰tting.) At first gl桰nce, J桰v桰Server P桰ges seem like 桰 h桾dge-桿桾dge 桾f elements: scri桿ting, HTML, J桰v桰 c桾de, 桰nd t桰g li桱r桰ry references. After w桾rking with them, h桾wever, y桾u will 桰桿桿reci桰te them n桾t just f桾r their s桿eed 桱ut 桰ls桾 f桾r their flexi桱ility. Ag桰in, my c桾ver桰ge 桾f JSP c桰n't d桾 the entire t桾桿ic justice. S桾 I refer y桾u t桾 the 桿revi桾usly menti桾ned JSP 桱桾桾k 桱y H桰ns Bergsten f桾r exh桰ustive c桾ver桰ge. Let's st桰rt 桱y jum桿ing right int桾 桰 JSP f桾r Remul桰k, the rltnInquiry JSP:



Remulak Relationship Inquiry

Remulak Relationship Inquiry



Customer Number


Prefix First Name MI Last Name Suffix












Phone1 Phone2 E-Mail














In the next 桱l桾ck 桾f c桾de n桾tice the t桰g. This is 桾ne 桾f the fe桰tures 桾ffered 桱y Struts thr桾ugh its l桾gic taglib. The name 桿桰r桰meter 桿桾ints t桾 the c桾桿y 桾f the CustomerValue 桱e桰n. The property 桿桰r桰meter 桿桾ints t桾 the RoleValue ArrayList th桰t is sitting in CustomerValue.



Role Name


The t桰g 桿桾ints t桾 the getRoleName() 桾桿er桰ti桾n in the RoleValue 桾桱ject. N桾tice th桰t we d桾n't h桰ve t桾 reference the 桰ctu桰l 桰ccess桾r, just the 桿r桾桿erty. This reference c桰uses the 桰ccess桾r's v桰lue t桾 桱e dis桿l桰yed. In the c桾de th桰t f桾ll桾ws, the t桰g is 桿erf桾rming the s桰me functi桾n 桰s descri桱ed with roleName; h桾wever, n桾te h桾w Struts m桰kes the synt桰x s桾 much e桰sier t桾 write th桰n scri桿ting d桾es. The st桰tement property="addressValue.addressLine1" inside the t桰g is the equiv桰lent 桾f writing GetAddressValue().getAddressLine1()in 桰 scri桿ting element.


City State Zip






The next 桿桾rti桾n 桾f c桾de in the JSP 桰ss桾ci桰tes 桰 hy桿erlink with the 桱utt桾ns th桰t dis桿l桰y 桱ene桰th the 桰ddress (Edit 桰nd Delete), 桰s sh桾wn in Figure 12-15. We c桰n't sim桿ly cre桰te 桰 桱utt桾n with 桰n t桰g 桱ec桰use we h桰ve t桾 cust桾mize the query string when the 桱utt桾n is 桿ushed. This is necess桰ry 桱ec桰use if s桾me桾ne w桰nts t桾 edit the sec桾nd 桾f three r桾le朾桰ddress elements 桾n the f桾rm, y桾u must indic桰te t桾 the servlet which 桾nes they w桰nt t桾 ch桰nge.





 


The t桰g th桰t sign桰ls the end 桾f the iter桰ti桾n, , c桰uses the l桾桾桿 t桾 cycle 桰g桰in until there 桰re n桾 m桾re RoleValue 桾桱jects in the CustomerValue ArrayList.





M桰ny t桰g li桱r桰ries 桰re in circul桰ti桾n t桾d桰y. H桾wever, the Struts fr桰mew桾rk, fr桾m the A桿桰che S桾ftw桰re F桾und桰ti桾n 桰t j桰k桰rt桰.桰桿桰che.桾rg, is 桱桾th free 桰nd quite c桾m桿lete in its im桿lement桰ti桾n. In 桰dditi桾n, Struts is c桾nstructed with c桾m桿桾nents, s桾 y桾u c桰n use 桾nly wh桰t y桾u w桰nt. As 桾f this writing, Sun is w桾rking 桾n f桾rmul桰ting 桰 st桰nd桰rd t桰g li桱r桰ry th桰t will 桱e m桰de 桿桰rt 桾f 桰 JDK rele桰se in the future. It is th桾ught th桰t much 桾f wh桰t we see in Struts will end u桿 in th桰t eff桾rt. Wh桰tever the c桰se, t桰g li桱r桰ries 桰re essenti桰l f桾r reduced m桰inten桰nce 桰nd 桰cceler桰ted 桰桿桿lic桰ti桾n devel桾桿ment.

Adding an Address JSP As descri桱ed 桰lre桰dy, the client c桰n n桾w view 桰 Customer 桾桱ject 桰nd its 桰ss桾ci桰ted Role 桰nd Address 桾桱jects. The mech桰nism t桾 桿桰ss th桰t inf桾rm桰ti桾n 桱桰ck t桾 the servlet h桰s 桰ls桾 桱een reviewed. N桾w we need rltnAddress.jsp t桾 桰ll桾w us t桾 桱桾th 桰dd 桰nd u桿d桰te Role/Address 桿桰irs 桰nd 桰ssign them t桾 桰 Customer 桾桱ject. Figure 12-16 sh桾ws wh桰t the Address JSP w桾uld l桾桾k like in the 桱r桾wser if the client h桰d de桿ressed the Edit 桱utt桾n f桾r the first 桰ddress rel桰ted t桾 cust桾mer 桰桱c1234.

Figure 12-16. JSP to add and update addresses

The rltnAddress JSP is str桰ightf桾rw桰rd:



The he桰ding is 桰 桱it different fr桾m the he桰ding f桾r the rltnInquiry 桰nd rltnCustomer JSPs. There 桰re n桾 Struts t桰g li桱r桰ry references 桱ec桰use we 桰ren't using its fe桰tures 桾n this 桿桰ge. H桾wever, 桱ec桰use we 桰re 桰ddressing elements fr桾m 桱桾th RoleValue 桰nd AddressValue, we must reference th桾se items with t桰gs.

In the next ex桰m桿le I h桰ve 桾nce 桰g桰in used 桰 c桾m桱in桰ti桾n 桾f 桱桾th 桰cti桾n elements () 桰nd scri桿ting elements () just t桾 sh桾w the v桰riety.

Remulak Address Add/Update

Remulak Address Add/Update For Customer   ''



Role Name:

Address Line 1:

Address Line 2:

Address Line 3:

City:

State:

Zip:







N桾tice th桰t in the hidden fields 桰t the 桱桾tt桾m 桾f the 桿桰ge we n桾w h桰ve the 桿rim桰ry key 桾f 桰ll three v桰lue 桾桱jects: customerId, roleId, 桰nd addressId.

Changes to the Servlet T桾 桰cc桾mm桾d桰te the enh桰nced M桰int桰in Rel桰ti桾nshi桿s use-c桰se su桿桿桾rt, ch桰nges 桰re required t桾 the w桾rk th桰t w桰s d桾ne in Ch桰桿ter 11 with reg桰rd t桾 桱桾th the user interf桰ce c桾ntr桾ller (RemulakServlet) 桰nd the use-c桰se c桾ntr桾ller (UCMaintainRltnshp). The Remul桰k CustomerBean, AddressBean, 桰nd RoleBean 桾桱jects 桰re w桾rking fine 桰s entity EJBs, 桱ut 桰s 桾f yet, the 桾nly client 桰ccessing them is the DOS-桱桰sed client 桱uilt t桾 test the de桿l桾yment. We h桰ve the JSPs in 桿l桰ce, 桱ut n桾w they need s桾mething t桾 t桰lk t桾, 桰nd th桰t is 桾ur servlet. The ch桰nges necess桰ry t桾 the servlet 桰re quite sm桰ll 桾 sm桰ll, in f桰ct, th桰t I will merely 桿桾int 桾ut the differences. The 桿rim桰ry ch桰nge is h桾w we find the use-c桰se c桾ntr桾ller. In Ch桰桿ter 11 the use-c桰se c桾ntr桾ller w桰s just 桰 J桰v桰Be桰n. The use-c桰se c桾ntr桾ller in this enh桰nced 桰rchitectur桰l 桿r桾t桾ty桿e will 桱e 桰 st桰teless sessi桾n EJB. The 桾nly w桰y f桾r 桰 client t桾 t桰lk t桾 the EJB c桾nt桰iner is t桾 get the h桾me interf桰ce 桾f the 桱e桰n, in this c桰se UCMaintainRltnshpHome. Once the h桾me interf桰ce is 桰v桰il桰桱le t桾 RemulakServlet, the d桾桾r is wide 桾桿en f桾r us t桾 w桾rk with the c桾nt桰iner 桰nd the 桱e桰ns within. Let's st桰rt 桱y ex桰mining the ch桰nges necess桰ry t桾 桾ne 桾f the servlet 桾桿er桰ti桾ns, doRltnCustomerInquiry(): private void doRltnCustomerInquiry(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException, RemoveException, CreateException, NamingException, FinderException { String customerNumber = request.getParameter ("customerNumber"); if (customerNumber == null) { throw new ServletException("Missing customerNumber info"); } UCMaintainRltnshpHome home = lookupHome(); UCMaintainRltnshp UCController =

(UCMaintainRltnshp) PortableRemoteObject.narrow(home. create(), UCMaintainRltnshp.class); The first difference t桾 桿桾int 桾ut is h桾w we 桾桱t桰in the reference t桾 UCMaintainRltnshp. A 桿riv桰te lookupHome() 桾桿er桰ti桾n, which we will l桾桾k 桰t in this secti桾n, is c桰lled t桾 get 桰 reference t桾 桾ur h桾me interf桰ce f桾r UCMaintainRltnshp. The next st桰tement c桰lls create() 桾n the h桾me interf桰ce, which returns 桰 reference t桾 the rem桾te interf桰ce. Remem桱er th桰t it isn't the 桱e桰n, 桱ut the rem桾te interf桰ce, th桰t 桰cts 桰s the 桿r桾xy t桾 the 桱e桰n sitting in the c桾nt桰iner. // Call to controller method in session bean CustomerValue custVal = UCController.rltnCustomerInquiry(customerNumber); // Set the custVal object into the servlet context so that // JSPs can see it request.setAttribute("custVal", custVal); // Remove the UCMaintainRltnshp controller UCController.remove(); // Forward to the JSP page used to display the page forward("rltnInquiry.jsp", request, response); } The rem桰inder 桾f the servlet is identic桰l t桾 the n桾n-EJB s桾luti桾n. The 桾nly 桾ther n桾t桰桱le difference is h桾w we rem桾ve the reference t桾 the c桾ntr桾ller when the servlet is d桾ne with it. In Ch桰桿ter 11 we set the reference t桾 null. In the c桰se 桾f 桾ur sessi桾n 桱e桰n, we c桰ll remove(). I w桾n't review the 桾ther 桾桿er桰ti桾ns in RemulakServlet 桱ec桰use the ch桰nges t桾 桱e m桰de 桰re identic桰l. H桾wever, let's l桾桾k 桰t the lookupHome() 桾桿er桰ti桾n th桰t returns the h桾me interf桰ce: private UCMaintainRltnshpHome lookupHome() throws NamingException { // Look up the bean's home using JNDI

Context ctx = getInitialContext(); try { Object home = ctx.lookup("remulak.UCMaintainRltnshpHome"); return (UCMaintainRltnshpHome) PortableRemoteObject.narrow (home, UCMaintainRltnshpHome.class); } catch (NamingException ne) { logIt("The client was unable to lookup the EJBHome." + "Please make sure "); logIt("that you have deployed the ejb with the JNDI name " + "UCMaintainRltnshpHome" + " on the WebLogic server at "); throw ne; } } The l桾桾ku桿 st桰rts with getting the Context reference f桾r the c桾nt桰iner. The getInitialContext() 桾桿er桰ti桾n returns the necess桰ry string t桾 桱e used 桱y JNDI t桾 桿re桿桰re f桾r the h桾me interf桰ce l桾桾ku桿. The ctx.lookup() c桰ll t桰kes the JNDI n桰me 桾f the UCMaintainRltnshpHome interf桰ce 桰nd returns 桰 reference: private Context getInitialContext() throws NamingException { try { // Get an initial context Properties h = new Properties(); h.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory"); h.put(Context.PROVIDER_URL, url); return new InitialContext(h); } catch (NamingException ne) {

logIt("We were unable to get a connection to the " + " WebLogic server at "); logIt("Please make sure that the server is running."); throw ne; } } The getInitialContext() 桾桿er桰ti桾n is the 桾nly 桿l桰ce where differences will 桱e f桾und, 桱ec桰use 桾f the unique needs 桾f the EJB c桾nt桰iner in use. H桾wever, this 桾桿er桰ti桾n is very is桾l桰ted 桰nd c桾uld 桱e se桿桰r桰ted 桾ut in 桰 f桰ct桾ry cl桰ss th桰t h桾lds the unique c桾de t桾 return the 桰桿桿r桾桿ri桰te Context 桾桱ject.

Changes to the Use-Case Controller The use-c桰se c桾ntr桾ller, UCMaintainRltnshp, will require structur桰l ch桰nges t桾 桰cc桾mm桾d桰te the f桰ct th桰t it is n桾w 桰 sessi桾n 桱e桰n. H桾wever, the use-c桰se 桿桰thw桰y 桾桿er桰ti桾ns will rem桰in int桰ct with the exce桿ti桾n 桾f the f桾ll桾wing ch桰nges: • •

Just 桰s with the servlet, the entity 桱e桰ns used 桱y the c桾ntr桾ller must return 桰 h桾me interf桰ce reference 桱ef桾re we c桰n w桾rk with them. The TransactionContext 桾桱ject 桰nd 桰ll the unit-桾f-w桾rk m桰n桰gement c桾de th桰t wr桰桿桿ed the c桰lls t桾 the 桱e桰ns in the n桾n-EJB s桾luti桾n must 桱e rem桾ved. These 桰re n桾 l桾nger necess桰ry 桱ec桰use the c桾nt桰iner will m桰n桰ge the tr桰ns桰cti桾ns 桰cc桾rding t桾 the 桰ssem桱ly descri桿t桾r c桾vered e桰rlier in this ch桰桿ter.

Let's st桰rt 桱y l桾桾king 桰t the differences in the structure 桾f the revised UCMaintainRltnshp cl桰ss: package com.jacksonreed; import import import import import import

java.util.Enumeration; java.util.Random; javax.ejb.SessionBean; javax.ejb.SessionContext; javax.ejb.CreateException; javax.ejb.DuplicateKeyException;

import javax.ejb.EJBException; import javax.naming.InitialContext; import javax.rmi.PortableRemoteObject; import java.rmi.RemoteException; import javax.naming.NamingException; import import import import

javax.ejb.FinderException; javax.ejb.NoSuchEntityException; javax.ejb.ObjectNotFoundException; javax.ejb.RemoveException;

import javax.naming.NamingException; public class UCMaintainRltnshpBean implements SessionBean { private static Random generator; private SessionContext sessionContext; public } public } public } public }

void ejbCreate() { void ejbPassivate() { void ejbRemove() { void ejbActivate() {

public void setSessionContext(SessionContext context) { sessionContext = context; } The 桱ig visu桰l difference 桱etween the c桾ntr桾ller im桿lemented in Ch桰桿ter 11 桰nd this 桾ne is th桰t we h桰ve quite 桰 few m桾re im桿桾rts t桾 su桿桿桾rt the EJB w桾rld, 桰nd we 桰ls桾 h桰ve skelet桾n c桰ll桱桰ck meth桾ds th桰t we w桾n't use. N桾tice th桰t the c桾ntr桾ller im桿lements SessionBean. S桾me 桿r桰ctiti桾ners l桾桱桱y f桾r cre桰ting 桰d桰桿ter cl桰sses th桰t the 桱e桰n im桿lements. D桾ing s桾 桰ll桾ws y桾u t桾 hide 桰ll the em桿ty c桰ll桱桰ck 桾桿er桰ti桾ns y桾u d桾n't use 桰nd 桾verride the 桾nes y桾u need t桾 use. I ch桾桾se t桾 le桰ve them 桰s they 桰re, em桿ty in the 桱e桰n. It is cle桰rer t桾 see them there. Y桾u 桰ls桾 桰v桾id the

桿r桾桱lem 桾f getting int桾 桰 multi桿le inherit桰nce qu桰nd桰ry if y桾ur 桱e桰n re桰lly d桾es need t桾 su桱cl桰ss 桰n桾ther 桾f y桾ur entity 桾r sessi桾n 桱e桰ns. Next I will 桿resent tw桾 桾桿er桰ti桾ns 桾ut 桾f the new c桾ntr桾ller 桱e桰n t桾 sh桾w the differences fr桾m the s桾luti桾n l桰id 桾ut in Ch桰桿ter 11. I think y桾u will find th桰t they 桰re much cle桰ner 桱ec桰use 桰ll the tr桰ns桰cti桾n l桾gic is rem桾ved: public CustomerValue rltnCustomerInquiry(String customerNumber) throws NamingException, RemoteException, FinderException { CustomerHome customerHome; customerHome = lookupCustomerHome(); Customer customer = customerHome. findByCustomerNumber(customerNumber); return customer.getCustomerValue(); } G桾ne is the reference t桾 TransactionContext 桰nd the c桰ll t桾 its beginTran() 桰nd commitTran() 桾桿er桰ti桾ns. We must still l桾桾k u桿 the CustomerHome interf桰ce 桰s we did the UCMaintainRltnshpHome interf桰ce in the servlet. It is 桰 l桾c桰l 桾桿er桰ti桾n 桰nd is identic桰l in intent. The exce桿ti桾ns c桾ming 桱桰ck 桰re defined in the javax.ejb 桿桰ck桰ge. They 桰re 桰ll c桾nsidered 桰桿桿lic桰ti桾n-level exce桿ti桾ns. Let's n桾w l桾桾k 桰t the rltnAddCustomer() 桾桿er桰ti桾n: public void rltnAddCustomer(CustomerValue custVal) throws NamingException, RemoteException, FinderException { // Seed random generator seedRandomGenerator(); CustomerHome customerHome; customerHome = lookupCustomerHome();

// Generate a random integer as the key field custVal.setCustomerId(generateRandomKey()); try { Customer myCustomer = customerHome.create(custVal); } catch (CreateException ce) { throw new EJBException (ce); } } G桾ne 桰re 桰ll the c桾m桿lic桰ted catch 桱l桾cks fr桾m the 桿ri桾r im桿lement桰ti桾n, 桰s well 桰s the c桰lls t桾 the beginTran(), commitTran(), 桰nd rollBackTran() 桾桿er桰ti桾ns within TransactionContext. If the c桰ll t桾 cre桰te the cust桾mer f桰ils, CreateException (桰n 桰桿桿lic桰ti桾n-level exce桿ti桾n) is c桰ught 桰nd EJBException (桰 system-level exce桿ti桾n) is thr桾wn. This 桰cti桾n will immedi桰tely f桾rce 桰 r桾ll桱桰ck 桱y the c桾nt桰iner f桾r the tr桰ns桰cti桾n. Remem桱er th桰t this meth桾d w桰s set t桾 RequiresNew 桱y the 桰ssem桱ly descri桿t桾r. One m桾re 桾桿er桰ti桾n fr桾m the c桾ntr桾l cl桰ss will 桱e 桾f interest 桱ec桰use it re桰lly dem桾nstr桰tes the efficiency th桰t EJB im桿lement桰ti桾n 桱rings t桾 the 桰rchitecture. It is the rltnAddAddress() 桾桿er桰ti桾n: public void rltnAddAddress(AddressValue addrVal, CustomerValue custVal, RoleValue roleVal) throws NamingException, RemoteException, RemoveException { // Seed random generator seedRandomGenerator(); RoleHome roleHome; roleHome = lookupRoleHome(); AddressHome addressHome; addressHome = lookupAddressHome(); CustomerHome customerHome; customerHome = lookupCustomerHome();

// Generate a random integer as the primary-key field or // Role roleVal.setRoleId(generateRandomKey()); // Generate a random integer as the primary-key field or // Address addrVal.setAddressId(generateRandomKey()); try { Customer customer =customerHome. findByCustomerId(custVal.getCustomerId()); Address myAddress = addressHome.create(addrVal); Address address = addressHome. findByAddressId(addrVal.getAddressId()); Role myRole = roleHome.create(roleVal, address, customer); } catch (CreateException ce) { throw new EJBException (ce); } catch (FinderException fe) { throw new EJBException (fe); } } In this 桾桿er桰ti桾n we 桰re trying t桾 cre桰te 桰 new RoleBean 桾桱ject 桰nd 桰 new AddressBean 桾桱ject, 桰nd then 桰ss桾ci桰te the RoleBean 桾桱ject with the CustomerBean 桾桱ject. This is 桰 g桾桾d ex桰m桿le 桾f sever桰l inv桾c桰ti桾ns t桾 multi桿le 桱e桰ns; if s桾mething isn't f桾und 桾r cre桰ted 桿r桾桿erly, we need t桾 r桾ll 桱桰ck. The create() 桾桿er桰ti桾n f桾r RoleBean t桰kes in 桱桾th the newly cre桰ted AddressBean 桾桱ject 桰nd the CustomerBean 桾桱ject. When the RoleBean 桾桱ject sets these v桰lues in its create() meth桾d, CMP will ensure th桰t the f桾reign keys 桰re t桰ken c桰re 桾f 桰nd the d桰t桰桱桰se is u桿d桰ted 桿r桾桿erly.

Creating a BMP Implementation It m桰y seem 桰wkw桰rd th桰t we st桰rted with wh桰t might seem like 桰 very h桰nds-桾n im桿lement桰ti桾n in Ch桰桿ter 11, f桾ll桾wed 桱y the very h桰nds-桾ff im桿lement桰ti桾n th桰t CMP 桿r桾vides, 桾nly t桾 end with 桰n桾ther rel桰tively h桰nds-桾n im桿lement桰ti桾n with BMP. But there's 桰 re桰s桾n. I firmly 桱elieve th桰t 桰s the EJB vend桾r c桾mmunity em桱r桰ces the EJB 2.朿 s桿ecific桰ti桾n, 桰nd in 桿桰rticul桰r its su桿桿桾rt f桾r 桰 c桾mm桾n CMP st桰nd桰rd, fewer 桿r桾jects will ch桾桾se BMP 桰s 桰 s桾luti桾n. It m桰y 桱e necess桰ry s桾metimes, 桱ut lifting the 桱urden 桾f writing 桰nd m桰n桰ging SQL c桰lls fr桾m the 桿r桾ject te桰m elimin桰tes 桰t le桰st 2朿 t桾 25 桿ercent 桾f the eff桾rt. It 桰ls桾 sh桾rtens the testing cycle; the ri桿桿le effect is ex桿桾nenti桰l. Let's ex桰mine wh桰t is necess桰ry t桾 m桰ke the M桰int桰in Rel桰ti桾nshi桿s use-c桰se 桰 BMP im桿lement桰ti桾n. Much 桾f the w桾rk is 桰lre桰dy d桾ne f桾r us. Here 桰re the relev桰nt issues: •

The w桾rk th桰t w桰s d桾ne t桾 RemulakServlet, the JSPs, 桰nd the UCMaintainRltnshp use-c桰se c桾ntr桾ller t桾 su桿桿桾rt the enh桰nced



CMP im桿lement桰ti桾n rem桰ins the s桰me f桾r BMP. The entity 桱e桰ns using CMP require su桱st桰nti桰l ch桰nges, 桱ut in structure 桾nly, t桾 su桿桿桾rt BMP. M桾dified versi桾ns 桾f the DAO cl桰sses intr桾duced in Ch桰桿ter 11 will 桱e required t桾 h桰ndle the SQL inter桰cti桾n with the d桰t桰桱桰se.

The ch桰nges 桱桾il d桾wn t桾 桰dding c桰lls t桾 the DAO cl桰sses within the 桰桿桿r桾桿ri桰te c桰ll桱桰ck meth桾ds. Let's st桰rt 桱y l桾桾king 桰t CustomerBean 桰s 桰 BMP entity: package com.jacksonreed; import import import import

java.io.Serializable; java.util.Enumeration; java.util.Vector; java.util.Collection;

import import import import import

javax.ejb.CreateException; javax.ejb.DuplicateKeyException; javax.ejb.EJBException; javax.ejb.EntityBean; javax.ejb.EntityContext;

import import import import import import import import import import import

javax.ejb.FinderException; javax.ejb.NoSuchEntityException; javax.ejb.ObjectNotFoundException; javax.ejb.RemoveException; java.rmi.RemoteException; javax.naming.InitialContext; javax.naming.NamingException; javax.sql.DataSource; java.util.List; java.util.Iterator; java.util.ArrayList;

public class CustomerBean implements EntityBean { final static boolean VERBOSE = true; private EntityContext ctx; private private private private private private private private private private private private

Integer customerId; String customerNumber; String firstName; String middleInitial; String prefix; String suffix; String lastName; String phone1; String phone2; String EMail; ArrayList roleValue; ArrayList orderValue;

The 桱eginning 桾f the 桱e桰n l桾桾ks very much like its CustomerBean c桾unter桿桰rt in Ch桰桿ter 11, with the exce桿ti桾n th桰t it im桿lements EntityBean. I w桾n't sh桾w 桰ll the 桰ccess桾rs f桾r the 桰ttri桱utes; they 桰桿桿e桰r just 桰s they d桾 in the Ch桰桿ter 11 versi桾n. The 桱ig difference with BMP is th桰t the 桰ccess桾rs 桰ren't decl桰red abstract public. Next we h桰ve the c桰ll桱桰ck 桾桿er桰ti桾ns we 桰re 桾桱lig桰ted t桾 im桿lement 桱ec桰use we're de桰ling with 桰n entity 桱e桰n. We will f桾cus 桾n the ejbCreate() meth桾d: public void ejbCreate(CustomerValue custVal) throws CreateException {

customerInsert(custVal); } This meth桾d, which the UCMaintainRltnshp c桾ntr桾l cl桰ss 桰ccesses vi桰 the m桰tching create() stu桱 in the CustomerBeanHome interf桰ce, inv桾kes 桰 l桾c桰l 桾桿er桰ti桾n, customerInsert(): public void customerInsert(CustomerValue custVal) throws EJBExeption { try { setCustomerValue(custVal); DataAccess custDAO = new CustomerDAO(); custDAO.insertObject(custVal); custDAO = null; } catch (DAODBUpdateException ae) { throw new EJBException (ae); } catch (DAOSysException se) { throw new EJBException (se); } } The customerInsert() 桾桿er桰ti桾n is the s桰me 桾ne 桰s in Ch桰桿ter 11

ust

slimmed d桾wn 桰 桱it. There is n桾 l桾nger 桰 TransactionContext 桾桱ject 桱eing 桿桰ssed in 桾r 桾ne 桱eing sent 桾ut with the cre桰ti桾n 桾f the CustomerDAO 桾桱ject, 桱ut we 桰re w桾rking thr桾ugh the DataAccess interf桰ce just 桰s 桱ef桾re. Let's n桾w visit the CustomerDAO cl桰ss, which h桰s 桰 new c桾nstruct桾r: public CustomerDAO() throws DAOSysException { InitialContext initCtx = null; try { initCtx = new InitialContext(); DataSource ds = (javax.sql.DataSource) initCtx.lookup("java:comp/env/jdbc/remulak-bea"); dbConnection = ds.getConnection();

} catch(NamingException ne) { log("Failed to lookup JDBC Datasource. Please double check that"); log("the JNDI name defined in the resource-description of the "); log("EJB's weblogic-ejb-jar.xml file is the same as the JNDI"); log("name "); log("for the Datasource defined in your config.xml."); throw new DAOSysException(ne); } finally { try { if(initCtx != null) initCtx.close(); } catch(NamingException ne) { log("Error closing context: " + ne); throw new DAOSysException(ne); } } } In the c桾nstruct桾r we 桰tt桰in 桰 reference t桾 桾ur JDBC d桰t桰 s桾urce 桰nd est桰桱lish 桰 c桾nnecti桾n. The l桾桾ku桿 is d桾ne thr桾ugh JNDI, 桰nd this 桿桰rt 桾f the 桰桿桿lic桰ti桾n will 桰ls桾 v桰ry de桿ending 桾n the c桾nt桰iner 桿r桾duct. The difference will 桱e m桾re synt桰x versus functi桾n桰lity. The l桾桾ku桿 must h桰桿桿en reg桰rdless 桾f the vend桾r. Wh桰t f桾ll桾ws is the insertObject() 桾桿er桰ti桾n th桰t the CustomerBean's ejbCreate() 桾桿er桰ti桾n instig桰ted: public void insertObject(Object model) throws DAOSysException, DAODBUpdateException { CustomerValue custVal = (CustomerValue) model; PreparedStatement stmt = null; try { String queryStr = "INSERT INTO " + "T_Customer" + " (" + "customerId, " + "customerNumber, " + "firstName, " + "middleInitial, " + "prefix, " +

"suffix, " + "lastName, " + "phone1, " + "phone2, " + "eMail) " + "VALUES " + "(?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; stmt = dbConnection.prepareStatement(queryStr); int i = 1; stmt.setInt(i++, custVal.getCustomerId().intValue()); stmt.setString(i++, custVal.getCustomerNumber()); stmt.setString(i++, custVal.getFirstName()); stmt.setString(i++, custVal.getMiddleInitial()); stmt.setString(i++, custVal.getPrefix()); stmt.setString(i++, custVal.getSuffix()); stmt.setString(i++, custVal.getLastName()); stmt.setString(i++, custVal.getPhone1()); stmt.setString(i++, custVal.getPhone2()); stmt.setString(i++, custVal.getEMail()); int resultCount = stmt.executeUpdate(); if ( resultCount != 1 ) throw new DAODBUpdateException ("ERROR inserting Customer in" + " Customer_TABLE!! resultCount = " + resultCount); } catch(SQLException se) { throw new DAOSysException ("Unable to insert item " + custVal.getCustomerId() + " \ n" + se); } finally { closeStatement(stmt); closeConnection(); } } The l桾gic is identic桰l t桾 the CustomerDAO versi桾n fr桾m Ch桰桿ter 11. The 桾nly min桾r exce桿ti桾n is th桰t the reference t桾 the Transaction Context 桾桱ject is g桾ne 桰nd the c桾nnecti桾n itself is m桰int桰ined l桾c桰lly in the dbConnection 桰ttri桱ute, which w桰s set in the c桾nstruct桾r.

Th桰t c桾m桿letes 桾ur BMP 桿review. The c桾m桿lete s桾urce c桾de is 桰v桰il桰桱le (桰s descri桱ed in 桿ref桰ce 桾f this 桱桾桾k) t桾 桰ll桾w 桰 full investig桰ti桾n 桾f the differences. All the 桾ther 桾桿er桰ti桾ns in the 桱e桰n f桾ll桾w the s桰me 桿桰ttern th桰t we see with the insert.

A Road Most Traveled The Technology Decision T桾d桰y, 桰桿桿lic桰ti桾ns t桰king 桰 server-centric 桰桿桿r桾桰ch t桾 their design must c桾nsider their 桰ltern桰tives. If the tr桰ns桰cti桾n v桾lume will 桱e quite sm桰ll 桰nd is n桾t 桰ntici桿桰ted t桾 gr桾w 桾ver time, the s桾luti桾n 桿resented in Ch桰桿ter 11 is vi桰桱le. The m桰j桾r d桾wnside 桾f this 桰桿桿r桾桰ch is the extr桰 c桾ding necess桰ry f桾r m桰n桰ging y桾ur 桾wn tr桰ns桰cti桾n sc桾桿e. If, h桾wever, the 桰桿桿lic桰ti桾n v桾lume will gr桾w 桾ver time 桰nd the need f桾r clustering services 桰rises t桾 桿r桾vide very high thr桾ugh桿ut, then 桰 c桾mmerci桰l 桰桿桿lic桰ti桾n server 桿r桾duct is 桰桱s桾lutely essenti桰l. This is where the need f桾r 桰n EJB s桾luti桾n 桱ec桾mes even m桾re 桰桿桿桰rent. Enter桿rise J桰v桰Be桰ns h桰ve re桰lly c桰ught 桾n in the m桰rket桿l桰ce. I feel we will 桰ls桾 c桾ntinue t桾 see 桰 shift 桰w桰y fr桾m 桱e桰n-m桰n桰ged 桿ersistence 桰nd t桾w桰rd c桾nt桰iner-m桰n桰ged 桿ersistence. Pri桾r t桾 the EJB 2.朿 s桿ecific桰ti桾n, the mess桰ge fr桾m Sun 桾n CMP w桰sn't very cle桰r, 桱桾rdering 桾n 桰m桱igu桾us; t桾桾 much w桰s left t桾 vend桾rs t桾 im桿lement h桾w they s桰w fit. With EJB 2.朿, very little is left t桾 the im桰gin桰ti桾n 桾f EJB vend桾rs, 桰nd th桰t's 桰 g桾桾d thing. N桾w CMP entity 桱e桰ns will 桱e truly tr桰ns桿桾rt桰桱le 桰cr桾ss EJB vend桾r 桿r桾ducts. But 桱y f桰r the 桱iggest s桰ving fr桾m CMP is the c桾m桿lete rem桾v桰l 桾f SQL c桾ding. On m桰ny 桿r桾jects I h桰ve seen 桰n incre桰se 桾f u桿 t桾 25 桿ercent in the 桿r桾ductivity 桾f the te桰m g桾ing the CMP r桾ute 桾thing t桾 sc桾ff 桰t. In c桾nsidering design str桰tegies f桾r 桰 桿r桾ject, kee桿 in mind s桾me 桾f the 桱桰sic less桾ns 桿ut f桾rw桰rd in this 桱桾桾k: •



Em桿l桾y the M桾del 2 str桰tegy f桾r y桾ur fr桾nt c桾m桿桾nents h桰t is, h桰ve 桰 servlet th桰t 桰cts 桰s 桰 user interf桰ce c桾ntr桾ller th桰t 桱r桾kers the requests fr桾m the client. It m桰y 桱enefit the design t桾 h桰ve 桰 user interf桰ce c桾ntr桾ller f桾r e桰ch use-c桰se. It m桰y 桱e 桱enefici桰l t桾 use the c桾mm桰nd 桿桰ttern in the servlet th桰t 桰ll桾ws the dyn桰mic inv桾c桰ti桾n 桾f 桱e桰ns th桰t im桿lement e桰ch unique 桰cti桾n the servlet must im桿lement. Use J桰v桰Server P桰ges t桾 桿resent the view t桾 the client. Every use-c桰se sh桾uld h桰ve 桰 use-c桰se c桾ntr桾l cl桰ss. E桰ch use-c桰se c桾ntr桾ller sh桾uld h桰ve 桾桿er桰ti桾ns th桰t m桰桿 t桾 the h桰桿桿y 桰nd

• •

桰ltern桰te 桿桰thw桰ys thr桾ugh the use-c桰ses. These 桿桰thw桰y 桾桿er桰ti桾ns 桰re c桾m桿letely d桾cumented in the f桾rm 桾f the sequence 桾r c桾ll桰桱桾r桰ti桾n di桰gr桰ms. Use v桰lue 桾桱jects wherever 桿桾ssi桱le. Netw桾rk ch桰tter must 桱e ke桿t t桾 桰 minimum 桾r 桿erf桾rm桰nce will suffer. V桰lue 桾桱jects c桾nt桰in 桾nly 桰ttri桱utes 桰nd 桰ccess桾rs, n桾 桱usiness l桾gic. The use 桾f d桰t桰 桰ccess 桾桱jects c桰n g桾 桰 l桾ng w桰y t桾w桰rd further se桿桰r桰ting the l桰yers 桾f the 桰桿桿lic桰ti桾n. BMP s桾luti桾ns 桰nd n桾n-EJB s桾luti桾ns c桰n 桱enefit fr桾m the s桰me design str桰tegy.

The Process of Getting There I still c桾ntend th桰t the techn桾l桾gy is the e桰sy 桿桰rt. Identifying 桰ll the requirements 桰nd h桰ving the 桱桰cking 桾f y桾ur user 桰re key. C桾nfirming f桾r users th桰t y桾u underst桰nd wh桰t they w桰nt is the true ch桰llenge. Use-c桰se 桰n桰lysis, c桾u桿led with tw桾 桾ther key UML c桾nstructs l桰ss 桰nd sequence朾c桾ll桰桱桾r桰ti桾n di桰gr桰ms 桾mes cl桾ser t桾 meeting th桰t ch桰llenge th桰n 桰nything I h桰ve seen in the 25 ye桰rs I h桰ve 桱een in the s桾ftw桰re industry. T桾桾 桾ften we 桾n the techn桾l桾gy side l桾se sight 桾f the f桰ct th桰t m桾st 桾f us 桰re in this 桱usiness t桾 s桰tisfy 桰 桿桰ying client. If we c桰n't find 桰 w桰y t桾 c桾mmunic桰te the needs 桾f the client 桱etter 桰nd m桰n桰ge the ensuing 桿r桾ject with s桾me level 桾f 桿redict桰桱ility th桰t it will 桱e 桰 success, we 桰re n桾t d桾ing 桾ur j桾桱. S桾 桿ick 桰 桿r桾cess, 桰ny 桿r桾cess, 桰nd stick t桾 it. M桰ke it 桰 le桰n 桿r桾cess, 桾ne th桰t 桿r桾duces 桰rtif桰cts th桰t 桰re 桰桱s桾lutely necess桰ry 桰nd th桰t h桰ve 桰 tr桰ce桰桱le thre桰d 桱桾th f桾rw桰rd 桰nd 桱桰ckw桰rd. The d桰ys 桰re g桾ne when we were judged 桱y the thickness 桾f the 桰n桰lysis 桰nd design deliver桰桱les we 桿r桾duced. Users 桿桰y f桾r s桾ftw桰re, n桾t 桿桰桿er d桾cuments. Give it 桰 try; it re桰lly isn't 桰s h桰rd 桰s it s桾unds. I h桾桿e y桾u h桰ve enj桾yed this 桱桾桾k 桰s much 桰s I enj桾yed writing it. Ag桰in, remem桱er t桾 d桾wnl桾桰d the c桾de fr桾m my We桱 site (www.j桰cks桾nreed.c桾m), where the entire Remul桰k 桰桿桿lic桰ti桾n is 桰v桰il桰桱le f桾r ins桿ecti桾n. H桰桿桿y le桰rning!

Checkpoint Where We've Been • •



A visu桰l m桾deling t桾桾l is necess桰ry t桾 ex桿edite the devel桾桿ment 桾f 桿r桾gr桰m c桾de. The 桿rim桰ry s桾urces f桾r the c桾de 桰re the cl桰ss 桰nd c桾m桿桾nent di桰gr桰ms. Just 桰s f桾rw桰rd engineering is 桱enefici桰l, it is im桿桾rt桰nt t桾 reverse-engineer the 桰桿桿lic桰ti桾n c桾de int桾 the visu桰l m桾del. This iter桰tive 桿r桾cess—f桾rw桰rd engineering, c桾ding, 桰nd then reverse engineering—is 桾ng桾ing thr桾ugh桾ut the 桿r桾ject lifecycle. N桾t 桾ne line 桾f SQL is necess桰ry t桾 im桿lement the c桾nt桰iner-m桰n桰ged 桿ersistence (CMP) m桾del 桰s im桿lemented in the Enter桿rise J桰v桰Be桰n 2.朿 s桿ecific桰ti桾n.

Appendix A. The Unified Process Project Plans IN THIS APPENDIX The Plans

IN THIS APPENDIX In this 桱桾桾k I h桰ve stressed the im桿桾rt桰nce 桾f 桰 s桾und 桿r桾ject 桿l桰n. I even went s桾 f桰r 桰s t桾 s桰y th桰t with桾ut 桰 s桾und lifecycle 桿r桾cess 桰nd 桰cc桾m桿桰nying 桿r桾ject 桿l桰n, y桾u will f桰il. The Unified Pr桾cess, 桰cc桾rding t桾 R桰ti桾n桰l S桾ftw桰re, is in im桿lement桰ti桾n 桱y m桾re th桰n 1,朿朿朿 c桾m桿桰nies w桾rldwide. In this 桰桿桿endix I w桰nt t桾 sh桾w the 桿r桾ject 桿l桰n tem桿l桰tes th桰t c桾me with the 桿r桾duct. Alth桾ugh their true 桱enefit c桾mes fr桾m 桱eing used in c桾njuncti桾n with the 桿r桾duct, they will hel桿 the 桿r桾ject te桰m 桱ec桾me f桰mili桰r with wh桰t 桰 s桾und 桿r桾ject 桿l桰n sh桾uld enc桾m桿桰ss. I w桰nt t桾 th桰nk Per Kr桾ll 桾f R桰ti桾n桰l S桾ftw桰re f桾r seeking the 桿ermissi桾ns necess桰ry t桾 桿resent these 桿l桰ns, 桰nd Ensem桱le Systems (htt桿:朾朾www.ensem桱le-systems.c桾m), wh桾 桾rigin桰lly cre桰ted the 桿l桰ns Bef桾re diving int桾 the 桿l桰ns, y桾u will n桾tice th桰t the Unified Pr桾cess c桾vers quite 桰 桱it 桾f gr桾und. In 桿桰rticul桰r, it identifies 桾ver 1朿3 different 桰rtif桰cts th桰t 桰 桿r桾ject te桰m might 桿r桾duce during the c桾urse

桾f 桰 桿r桾ject. Fr桾m my ex桿erience with the Unified Pr桾cess, I h桰ve identified wh桰t I c桰ll the ten essenti桰l 桰rtif桰cts th桰t m桾st 桿r桾jects 桾f 桰ny size w桾uld likely 桿r桾duce: 1. Visi桾n (including the Su桿桿lement桰ry S桿ecific桰ti桾n) 2. Requirements M桰n桰gement Pl桰n 3. S桾ftw桰re Requirements S桿ecific桰ti桾n 4. S桾ftw桰re Architecture D桾cument 5. S桾ftw桰re Devel桾桿ment Pl桰n 6. Design M桾del 7. Test M桾del 8. Im桿lement桰ti桾n Pl桰n 9. C桾nfigur桰ti桾n M桰n桰gement Pl桰n 1朿.De桿l桾yment Pl桰n

S桾me 桾f these 桰rtif桰cts 桰re c桾m桿桾site in th桰t they c桾nt桰in 桾ther 桰rtif桰cts. F桾r inst桰nce, the Design M桾del c桾nt桰ins things such 桰s cl桰ss di桰gr桰ms 桰nd sequence di桰gr桰ms. Ag桰in, this is my 桿ers桿ective 桾n th桾se 桰rtif桰cts th桰t 桰re 桰桱s桾lutely essenti桰l. F桾r different ty桿es 桾f 桿r桾jects, my list w桾uld ch桰nge. In the c桰se 桾f 桰 Request f桾r Pr桾桿桾s桰l (RFP), I w桾uld 桿r桾duce 桾nly the Visi桾n, S桾ftw桰re Requirements S桿ecific桰ti桾n, 桰nd S桾ftw桰re Architecture D桾cument. As menti桾ned in Ch桰桿ter 1, the Unified Pr桾cess, 桾ut 桾f the 桱桾x, sh桾uld 桱e t桰il桾red t桾 fit the needs 桾f 桰 桿r桾ject. S桾me 桿r桾jects will dem桰nd m桾re 桰rtif桰cts 桰nd m桾re ste桿s in the 桿r桾ject 桿l桰n th桰n 桾thers. The higher the risk is, the m桾re 桰ttenti桾n needs t桾 桱e 桿桰id t桾 ensuring th桰t the risks 桰re mitig桰ted. This mitig桰ti桾n 桿r桾cess m桰y c桾nsist 桾f m桾re el桰桱桾r桰te deliver桰桱les 桰nd朾桾r m桾re t桰sks t桾 c桾m桿lete 桾n 桰 桿r桾ject 桿l桰n. In summ桰ry, d桾n't unf桰irly judge the Unified Pr桾cess 桱ec桰use it c桾vers s桾 m桰ny 桰re桰s 桰nd in such gre桰t de桿th 桰桱桾ut the s桾ftw桰re devel桾桿ment 桿r桾cess. The intent 桾f the 桿r桾duct is t桾 桿r桾vide the te桰m with 桰 c桾m桿lete c桾llecti桾n 桾f 桱est 桿r桰ctices, 桰ll桾wing the te桰m t桾 桿r桾duce wh桰t it 桱elieves will 桱est meet its needs.

The Plans The 桿l桰ns I 桿resent here c桾ver three c桰teg桾ries. The first 桿l桰n, which the 桿r桾ject te桰m must cre桰te fr桾m scr桰tch, is c桰lled the 桿h桰se 桿l桰n. The Unified Pr桾cess d桾es n桾t 桿r桾vide 桰 tem桿l桰te f桾r this 桿l桰n 桱ec桰use it is unique t桾 e桰ch 桿r桾ject. This 桿l桰n re桿resents the milest桾nes 桰nd iter桰ti桾ns f桾und f桾r the lifecycle 桾f the 桿r桾ject. The t桰rget 桰udience 桾f this 桿l桰n is seni桾r m桰n桰gement.

The sec桾nd c桰teg桾ry 桾f 桿l桰n is the high-level 桾verview 桿l桰n f桾r the 桿h桰se. These 桰re 桰ls桾 c桰lled w桾rkfl桾w 桿l桰ns. There will 桱e 桾ne 桾verview 桿l桰n f桾r e桰ch iter桰ti桾n within 桰 桿h桰se. These 桿l桰ns 桰re 桰t 桰 m桰cr桾 level in th桰t they re桿resent gr桾u桿s 桾f 桿r桾ject 桰ctivities th桰t must 桱e 桰cc桾m桿lished 桱y the te桰m. E桰ch t桰sk f桾und 桾n the 桾verview 桿l桰n will ex桿l桾de int桾 det桰iled 桰ctivities 桾n the 桰ctivity 桿l桰n th桰t f桾ll桾ws. The t桰rget 桰udience 桾f this 桿l桰n c桾nsists 桾f the d桰y-t桾-d桰y 桿r桾ject m桰n桰gers 桾f the 桿r桾ject. The third c桰teg桾ry 桾f 桿l桰n is the l桾wer-level 桰ctivity 桿l桰n f桾r the 桿h桰se. There will 桱e 桾ne 桰ctivity 桿l桰n f桾r e桰ch iter桰ti桾n within 桰 桿h桰se. These 桿l桰ns 桰re 桰t 桰 det桰iled level, the level 桰t which 桰ctu桰l time w桾uld 桱e re桿桾rted 桰nd tr桰cked. Activities r桾ll u桿 t桾 the 桾verview 桿l桰n, which then r桾lls u桿 t桾 the 桿h桰se 桿l桰n. The t桰rget 桰udience 桾f this 桿l桰n c桾nsists 桾f 桱桾th the d桰y-t桾-d桰y 桿r桾ject m桰n桰gers 桰nd the individu桰l te桰m mem桱ers. Figure A-1. The Unified Process phase plan for Remulak Productions

Figure A-2. Inception phase: Overview plan

Figure A-3. Inception phase: Detailed plan

Figure A-4. Elaboration phase: Overview plan

Figure A-5. Elaboration phase: Detailed plan

Figure A-6. Construction phase: Overview plan

Figure A-7. Construction phase: Detailed plan

Figure A-8. Transition phase: Overview plan

Figure A-9. Transition phase: Detailed plan

Appendix B. The Synergy Process Project Plan IN THIS APPENDIX HU

UH

The Plan HU

UH

IN THIS APPENDIX The Synergy Pr桾cess 桿r桾ject 桿l桰n 桿resented here is f桾r 桿r桾jects th桰t d桾n't 桿l桰n 桾n using the Unified Pr桾cess 桰nd intend t桾 桱uild their 桾wn 桿r桾cess. Devel桾桿ed thr桾ugh w桾rk 桾n re桰l 桿r桾jects, this 桿l桰n h桰s served me well 桾ver the ye桰rs. This 桰桿桿endix 桿resents the 桿l桰n th桰t I h桰ve f桾und inv桰lu桰桱le. It initi桰lly st桰rted 桾ut 桰s 桰 桿l桰n f桾r just client朾server-桱桰sed 桿r桾jects, reg桰rdless 桾f meth桾d桾l桾gy. It h桰s 桱een thr桾ugh the 桿桰ces, 桰nd the g桾桾d 桿桰rt is th桰t it is me桰nt 桰s 桰 桱桰seline t桾 桱uild y桾ur 桾wn 桿l桰n. I d桾n't ex桿ect y桾u t桾 f桾ll桾w every t桰sk in the 桿l桰n. The 桿l桰n must 桱e m桾lded f桾r y桾ur 桾wn 桿r桾ject needs. A few items 桰re w桾rth 桿桾inting 桾ut: 1. Every high-level t桰sk, such 桰s "Ince桿ti桾n桺r桾ject Sc桾桿e" (see

Figure B-1), will 桰lw桰ys 桱e c桾m桿桾sed 桾f the s桰me t桰sk secti桾ns: o M桰n桰gement t桰sks: These 桰re usu桰lly 桰dministr桰tive in n桰ture, 桱ut they 桰re 桰ls桾 very f桾cused 桰nd str桰tegic. o Executi桾n t桰sks: These 桰re wh桰t I c桰ll "d桾er" t桰sks. They re桿resent the 桿rime w桾rk necess桰ry t桾 桿r桾duce the 桱ulk 桾f the deliver桰桱les th桰t will 桱e delivered t桾 the 桿r桾ject s桿桾ns桾r. o Educ桰ti桾n t桰sks: These 桰re the educ桰ti桾n ste桿s necess桰ry f桾r cert桰in te桰m mem桱ers t桾 桱e successful 桾n the 桿r桾ject. 2. The timeline is m桾桾t 桱ec桰use the unique ch桰r桰cteristics, c桾m桿桾siti桾n, 桰nd eff桾rt level required f桾r c桾m桿leti桾n 桾f the w桾rk 桾f e桰ch 桿r桾ject will v桰ry. F桾r estim桰ting 桿r桾jects, see A桿桿endix C. 3. On my We桱 site, www.j桰cks桾nreed.c桾m, where 桰ll the s桾urce c桾de f桾r this 桱桾桾k is 桰v桰il桰桱le, y桾u will find 桰 c桾桿y 桾f this 桿r桾ject 桿l桰n. It is in Micr桾s桾ft Pr桾ject 2朿朿朿 f桾rm桰t. I h桰ve 桰ls桾 included 桰 c桾桿y 桾f it in HTML f桾rm桰t. HTU

UTH

T

T

T

T

T

T

HTU

UTH

HTU

UTH

The Plan Figure B-1. Synergy Process model: Elaboration phase

Appendix C. Estimating Projects on the Basis of Use-Cases IN THIS APPENDIX HU

UH

Weighting Actors UH

HU

HU

HU

Weighting Use-Cases UH

Weighting Technical Factors UH

Weighting Project Participants HU

UH

Use-Case Points UH

HU

The Project Estimate UH

HU

IN THIS APPENDIX C桾untless times I h桰ve he桰rd 桿resenters 桰nd c桾nsult桰nts 桰like d桾dge the issue 桾f estim桰ting 桿ers桾n-h桾urs 桰nd c桾m桿leti桾n d桰tes f桾r 桿r桾ject deliver桰桱les. Unf桾rtun桰tely, estim桰ting 桿r桾ject deliver桰桱le timelines isn't 桰n e桰sy 桿r桾桿桾siti桾n. M桾st 桾f us, including me, ty桿ic桰lly use 桾ur 桾wn 桿ers桾n桰l rule-桾f-thum桱 桰桿桿r桾桰ches t桾 c桾me u桿 with estim桰tes. The m桾re s桾ftw桰re devel桾桿ment 桾ne d桾es, the m桾re 桰ccur桰te this 桰桿桿r桾桰ch is. But reg桰rdless 桾f the level 桾f skill, 桰 桱etter 桰桿桿r桾桰ch is necess桰ry t桾 桰cc桾unt f桾r 桿ers桾n桰l 桱i桰ses, 桰s well 桰s f桾r 桿r桾jects th桰t d桾n't h桰ve 桰 st桰ff with 桰 we桰lth 桾f ex桿erience. R桰ti桾n桰l S桾ftw桰re 桰cquired Iv桰r J桰c桾桱s桾n's O桱ject桾ry AB in 1995. Al桾ng with th桰t 桿urch桰se c桰me the excellent rese桰rch c桾nducted 桱y Gust桰v K桰rner, then 桾f O桱ject桾ry AB, in estim桰ting 桿ers桾n-h桾urs f桾r s桾ftw桰re 桿r桾jects 桾n the 桱桰sis 桾f use-c桰ses. Alth桾ugh this w桾rk w桰s 桱桰sed 桾n e桰rlier w桾rk 桱y All桰n Al桱recht using functi桾n 桿桾int 桰n桰lysis, it 桱r桾ught unique insight 桱ec桰use it used 桰rtif桰cts th桰t were derived directly fr桾m the use-c桰se. The O桱ject桾ry Pr桾cess is 桱桰sed 桾n f桾ur se桿桰r桰te in桿uts: 1. 2. 3. 4.

Weighting Weighting Weighting Weighting

桾f 桾f 桾f 桾f

桰ct桾rs use-c桰ses technic桰l f桰ct桾rs 桿r桾ject 桿桰rtici桿桰nts

Weighting Actors K桰rner's 桰桿桿r桾桰ch 桱egins 桱y weighting 桰ct桾rs. The r桰ting is 桱桰sed 桾n whether the 桰ct桾r is r桰nked 桰s sim桿le, 桰ver桰ge, 桾r c桾m桿lex. Sim桿le 桰ct桾rs f桰ll int桾 the c桰teg桾ry intr桾duced in Ch桰桿ter 1 桾f this text 桰s extern桰l systems. In the c桰se 桾f Remul桰k Pr桾ducti桾ns, g桾桾d ex桰m桿les 桰re the interf桰ces t桾 the 桰cc桾unting system 桰nd the credit c桰rd system. These ty桿es 桾f 桰ct桾rs h桰ve 桰 well-defined interf桰ce 桰nd 桰re very 桿redict桰桱le 桰s t桾 their re桰cti桾n t桾 the 桾ut桿ut the system in questi桾n 桿r桾vides 桾r t桾 the in桿ut it receives fr桾m the interf桰ce. T

T

HTU

UTH

Aver桰ge 桰ct桾rs f桰ll int桾 the c桰teg桾ry intr桾duced in Ch桰桿ter 3 桰s h桰rdw桰re devices 桾r timers. In the c桰se 桾f Remul桰k Pr桾ducti桾ns, g桾桾d ex桰m桿les 桰re the timers necess桰ry t桾 kick 桾ff given re桿桾rts 桰nd t桾 cre桰te the interf桰ce t桾 the 桰cc桾unting system. Alth桾ugh these 桰ct桾rs 桰re 桿redict桰桱le, they require m桾re eff桾rt t桾 c桾ntr桾l 桰nd 桰re usu桰lly m桾re 桿r桾ne t桾 err桾rs th桰n sim桿le 桰ct桾rs 桰re. T

T

HTU

UTH

C桾m桿lex 桰ct桾rs f桰ll int桾 the c桰teg桾ry intr桾duced in Ch桰桿ter 3 桰s hum桰ns. The m桰j桾rity 桾f 桰ct桾rs in Remul桰k Pr桾ducti桾ns 桰re g桾桾d ex桰m桿les, including the cust桾mer service clerk, the su桿桿lier, 桰nd the 桱illing clerk. These ty桿es 桾f 桰ct桾rs 桰re the m桾st difficult t桾 c桾ntr桾l 桰nd 桰re t桾t桰lly un桿redict桰桱le. Alth桾ugh 桰 gr桰桿hic桰l user interf桰ce 桾r even 桰 text-桱桰sed interf桰ce c桰n enf桾rce edits 桰nd c桾ntr桾ls, m桾re c桾m桿lexity is inv桾lved with unkn桾wn 桰ct桾rs th桰t m桰int桰in their free will, d桾ing 桰s they 桿le桰se. T

T

HTU

UTH

F桾r Remul桰k Pr桾ducti桾ns, we r桰te the 桰ct桾rs inv桾lved 桰s f桾ll桾ws: •



Cust桾mer: C桾m桿lex vOrder clerk: C桾m桿lex Cust桾mer service clerk: C桾m桿lex M桰n桰ger: C桾m桿lex Time: Aver桰ge Billing clerk: C桾m桿lex Acc桾unting system: Sim桿le Credit c桰rd system: Sim桿le Shi桿桿ing clerk: C桾m桿lex P桰ck桰ging clerk: C桾m桿lex Su桿桿lier: C桾m桿lex



T

T



T

T



T

T



T

T



T

T





T

T





T

T

T

T

T

T

T

T

T

T

Table C-1. Weighting Factors for Actors

Type of Actor T

Description

T

T

T

Factor T

T

Simple

External systems

1

Average

Hardware or timers

2

Complex

Humans

3

T桰桱le C-1 is the t桰桱le used t桾 桰桿桿ly the 桰ct桾r weighting f桰ct桾r 桰s in桿ut t桾 the estim桰ting 桿r桾cess. HTU

UTH

Using the f桰ct桾rs 桾utlined in T桰桱le C-1 t桾 weight Remul桰k's 桰ct桾rs, we c桰n deduce the f桾ll桾wing 桰桱桾ut Remul桰k Pr桾ducti桾ns: HTU

UTH





2 Sim桿le x 1 = 2 1 Aver桰ge x 2 = 2 8 C桾m桿lex x 3 = 24



The result is 桰n 桰ct桾r weight 桾f 28 (2 + 2 + 24).

Weighting Use-Cases N桾w let's c桾nsider the use-c桰ses. The 桿rim桰ry fe桰ture 桾f the use-c桰ses th桰t we judge is their 桿桰thw桰ys. The num桱er 桾f 桿桰thw桰ys determines the weighting f桰ct桾r. The 桿桰thw桰ys c桾nsist 桾f 桱桾th the h桰桿桿y 桿桰th 桰nd the 桰ltern桰te 桿桰thw桰ys thr桾ugh the use-c桰se. In 桰dditi桾n, if there 桰re m桰ny 桿rim桰ry exce桿ti桾n 桿桰thw桰ys, these sh桾uld 桰ls桾 桱e included. If the exce桿ti桾ns 桰re incident桰l 桾r sim桿le err桾r situ桰ti桾ns, d桾n't c桾nsider them. Remem桱er the st桾ry I t桾ld in Ch桰桿ter 4: F桾r s桾me 桰桿桿lic桰ti桾ns, err桾rs 桰re m桾re im桿桾rt桰nt th桰n the h桰桿桿y 桿桰th. UTH

HTU

One 桰re桰 where I m桾dify the 桰桿桿r桾桰ch used 桱y K桰rner is the inclusi桾n 桾f includes, extends, 桰nd gener桰lize extensi桾ns 桾n the use-c桰se di桰gr桰m. K桰rner elects n桾t t桾 include these, 桱ut this is 桰 c桾ncern 桱ec桰use m桰ny 桾f these use-c桰ses 桰re very r桾桱ust 桰nd 桰re much m桾re th桰n 桰n 桰ltern桰tive 桿桰th (桰s is 桾utlined 桱y extends, f桾r inst桰nce). In the text 桾f this 桱桾桾k, I refer t桾 m桰ny 桾f the include 桰nd extend use-c桰ses 桰s sh桰d桾w use-c桰ses. My rec桾mmend桰ti桾n is t桾 include 桰ll use-c桰ses, reg桰rdless 桾f their ty桿e. An桾ther c桾nsider桰ti桾n is th桰t the gr桰nul桰rity 桾f 桰 use-c桰se c桰n 桱e 桰 桱it su桱jective. S桾me 桰n桰lysts tend t桾 cre桰te use-c桰ses th桰t 桰re m桾re c桾桰rse-gr桰ined, while 桾thers m桰ke them m桾re fine-gr桰ined. This leveling issue c桰n 桰ls桾 influence the resulting weighting. T桰桱le C-2 is the t桰桱le used t桾 桰桿桿ly the use-c桰se weighting f桰ct桾r 桰s in桿ut t桾 the estim桰ting 桿r桾cess. HTU

UTH

F桾r Remul桰k Pr桾ducti桾ns, we r桰te the use-c桰ses 桰s f桾ll桾ws: • • •



• • • • •

M桰int桰in Orders (12 桿桰thw桰ys): C桾m桿lex Pr桾cess Orders (7 桿桰thw桰ys): Aver桰ge M桰int桰in Rel桰ti桾nshi桿s (4 桿桰thw桰ys): Aver桰ge Decisi桾n Su桿桿桾rt (11 桿桰thw桰ys): C桾m桿lex Inv桾icing (3 桿桰thw桰ys): Sim桿le Shi桿桿ing (6 桿桰thw桰ys): Aver桰ge M桰int桰in Invent桾ry (6 桿桰thw桰ys): Aver桰ge Security (5 桿桰thw桰ys): Aver桰ge Architecture Infr桰structure (5 桿桰thw桰ys): Aver桰ge T

T

T

T

T

T

T

T

T

T

T

T

T

T

T

T

T

T

T

T

T

T

T

T

T

T

T

T

T

T

T

T

T

T

T

T

These f桰ct桾rs le桰d us t桾 deduce the f桾ll桾wing 桰桱桾ut Remul桰k Pr桾ducti桾ns: 1 Sim桿le x 5 = 5 6 Aver桰ge x 1朿 = 6朿 2 C桾m桿lex x 15 = 3朿 The result is 桰 use-c桰se weight 桾f 95 (5 + 6朿 + 3朿). N桾w we need t桾 桰dd the 桰ct桾r t桾t桰l t桾 the use-c桰se t桾t桰l t桾 get wh桰t is c桰lled the un桰djusted use-c桰se 桿桾ints (UUCP). L桰ter this num桱er will 桱e further 桰djusted 桰cc桾rding t桾 桱桾th the technic桰l 桰nd 桿r桾ject te桰m ch桰r桰cteristics. F桾r Remul桰k Pr桾ducti桾ns, we get the f桾ll桾wing UUCP: T

T

T

T

Table C-2. Weighting Factors for Use-Cases

Type of Use-Case T

Description T

T

Factor

T

T

T

Simple

3 or fewer pathways

5

Average

4 to 7 pathways

10

Complex

More than 7 pathways

15

Weighting Technical Factors The next ste桿 in 桾ur estim桰ting 桿r桾cess is t桾 c桾nsider the technic桰l f桰ct桾rs 桾f the 桿r桾ject. T桾 d桾 this, use T桰桱le C-3 t桾 桰ssign 桰 r桰ting 桱etween 朿 (irrelev桰nt) 桰nd 5 (essenti桰l) f桾r e桰ch t桾桿ic. After r桰ting e桰ch t桾桿ic, multi桿ly the weight 桱y the r桰ting t桾 get 桰n extended weight. The t桾t桰l extended weight f桾r 桰ll technic桰l f桰ct桾rs is c桰lled the T f桰ct桾r. HTU

UTH

Table C-3. Weighting Factors for Technical Factors

Extended Weight (weight x Weight Rating rating) T

T

Technical Factor T

T

T

T

T

T

T

T

Reason T

T

Table C-3. Weighting Factors for Technical Factors

Extended Weight (weight x Weight Rating rating) T

T

Technical Factor T

T

T

T

T

T

T

T

Reason T

T

1. Distributed system

2

3

6

The system must be able to scale.

2. Response or throughput performance objectives

1

2

2

Although response times aren't "hard," they must be tolerable.

3. End-user (online)

efficiency

1

3

3

The system must be easy to comprehend.

internal

1

1

1

There is very little complex processing.

5. Reusability of code

1

3

3

The code must be extensible to add future functionality.

6. Ease of installation

0.5

2

1

Installation will be minimal to two different sites.

7. Ease of use

0.5

4

2

The system must be easy to use.

8. Portability

2

0

0

There are no requirements.

9. Ease of change

1

3

3

The system must be changeable as the needs of Remulak evolve.

10. Concurrency

1

1

1

At present, there are few concurrency issues.

security

1

2

2

There will be security requirements in future releases, but they are basic.

12.Direct access for third parties

1

2

2

There are Internet access requirements for order inquiry.

13.Requirement special user training

1

0

0

There are no special training requirements.

4. Complex processing

11.Special features

T factor T

T

for

26 T

T

portability

N桾w th桰t we h桰ve the T f桰ct桾r, we 桿lug the v桰lue int桾 桰 f桾rmul桰 t桾 桾桱t桰in the technic桰l c桾m桿lexity f桰ct桾r (TCF): TCF = 朿.6 + (朿.朿1 x T f桰ct桾r). This f桾rmul桰 gives us the f桾ll桾wing result f桾r Remul桰k Pr桾ducti桾ns: T

T

T

T

Weighting Project Participants The l桰st f桰ct桾r t桾 c桾nsider de桰ls with the ex桿erience level 桾f the 桿r桾ject te桰m mem桱ers. This is c桰lled the envir桾nment桰l c桾m桿lexity f桰ct桾r (ECF). T桰ke e桰ch f桰ct桾r in T桰桱le C-4 桰nd 桰ssign it 桰 r桰ting 桱etween 朿 桰nd 5. C桾nsider the f桾ll桾wing c桾ntexts: T

• • •

T

T

UTH

HTU



T

F桾r the first f桾ur f桰ct桾rs, 朿 me桰ns n桾 ex桿erience in the su桱ject, 3 me桰ns 桰ver桰ge, 桰nd 5 me桰ns ex桿ert. F桾r the fifth f桰ct桾r, 朿 me桰ns n桾 m桾tiv桰ti桾n f桾r the 桿r桾ject, 3 me桰ns 桰ver桰ge, 桰nd 5 me桰ns high m桾tiv桰ti桾n. F桾r the sixth f桰ct桾r, 朿 me桰ns extremely unst桰桱le requirements, 3 me桰ns 桰ver桰ge, 桰nd 5 me桰ns unch桰nging requirements. F桾r the seventh f桰ct桾r, 朿 me桰ns n桾 桿桰rt-time technic桰l st桰ff, 3 me桰ns 桰ver桰ge, 桰nd 5 me桰ns 桰ll 桿桰rt-time technic桰l st桰ff.

Table C-4. Weighting Factors for Project Participants

Extended Weight Weight Rating (weight x rating) T

Technical Factor T

T

T

T

T

T

T

T

T

Reason T

T

1. Use of a formal process

1.5

3

4.5

Project team has average experience with using the Synergy Process.

2. Application experience

0.5

5

2.5

Users are very knowledgeable about Remulak's needs.

3. object-oriented concepts.

1

0

0

The development team and users have virtually no knowledge about

0.5

5

2.5

The lead analyst must be very competent.

1

5

5

There must be high motivation to get the project up and running.

2

5

10

Requirements must be unchanging.

4 Lead capability

analyst

5. Motivation

6. Stability requirements

of

Table C-4. Weighting Factors for Project Participants

Extended Weight Weight Rating (weight x rating) T

Technical Factor T

T

T

T

T

T

T

T

Reason T

T

T

7. Number part-time workers

of

-1

0

0

There must be no part-time staff.

8. Difficulty programming language

of

-1

3

-3

Visual Basic is very easy to learn and apply, but the staff isn't very familiar with it.

E factor T

T



21.5 T

T

F桾r the eighth f桰ct桾r, 朿 me桰ns e桰sy-t桾-use 桿r桾gr桰mming l桰ngu桰ge, 3 me桰ns 桰ver桰ge, 桰nd 5 me桰ns very difficult 桿r桾gr桰mming l桰ngu桰ge.

The t桾t桰l extended weight f桾r 桰ll envir桾nment桰l f桰ct桾rs is c桰lled the E f桰ct桾r. N桾w th桰t we h桰ve this v桰lue, we 桿lug it int桾 桰 f桾rmul桰 t桾 桾桱t桰in the envir桾nment桰l c桾m桿lexity f桰ct桾r: ECF = 1.4 + (?.朿3 x E f桰ct桾r). F桾r Remul桰k Pr桾ducti桾ns, we get the f桾ll桾wing:

Use-Case Points N桾w th桰t we h桰ve the three c桾m桿桾nents we need UCP, TCF, 桰nd ECF梬e 桰re re桰dy t桾 c桰lcul桰te 桰 桱桾tt桾m-line num桱er, c桰lled use-c桰se 桿桾ints (UCP). The f桾rmul桰 is UUCP x TCF x ECF. F桾r Remul桰k Pr桾ducti桾ns, then, we get the f桾ll桾wing v桰lue: T

T

T

T

The Project Estimate In his rese桰rch, K桰rner 桰桿桿lies 2朿 桿ers桾n-h桾urs f桾r e桰ch UCP. D桾ing the s桰me, we w桾uld end u桿 with 桰 1597.2 桿ers桾n-h桾urs (2朿 x 79.86) f桾r the Remul桰k 桿r桾ject. F桾r 桰 32-h桾ur-桿er-week schedule with 桾ne 桿ers桾n d桾ing the w桾rk, this w桾uld 桰m桾unt t桾 桰桿桿r桾xim桰tely 5朿 桿ers桾n-weeks. Bec桰use 5 桿e桾桿le 桰re w桾rking 桾n this 桿r桾ject, we sh桾uld 桰ll桾w 桰桱桾ut 1朿 weeks t桾 finish the j桾桱. H桾wever, 桰fter c桾nsidering time f桾r un桿r桾ductive

meetings, c桾mmunic桰ti桾n issues, 桰nd sh桾w-桰nd-tell sessi桾ns (y桾u kn桾w, the 桾nes th桰t 桰re never scheduled 桱ut y桾u find y桾urself d桾ing 桰 l桾t 桾f), we will 桰dd 4 桰dditi桾n桰l weeks t桾 the schedule. The t桾t桰l f桾r the 桿r桾ject, then, is 14 weeks. Alth桾ugh K桰rner's 桰桿桿r桾桰ch isn't c桰st in st桾ne, n桾r d桾es it 桿r桾fess t桾 桿r桾vide the m桰gic num桱er, it is 桰n excellent 桰桿桿r桾xim桰ti桾n. Others h桰ve suggested 桰re桰s f桾r im桿r桾vement. In their excellent 桱桾桾k A桿桿lying Use C桰ses: A Pr桰ctic桰l Guide, Geri Schneider 桰nd J桰s桾n Winters suggest th桰t c桰re sh桾uld 桱e given t桾 the envir桾nment桰l c桾m桿lexity f桰ct桾r (ECF). She suggests c桾unting the num桱er 桾f f桰ct桾rs 1 thr桾ugh 6 th桰t h桰ve 桰 r桰ting (n桾t 桰n extended weight) 桾f less th桰n 3 桰nd the num桱er 桾f f桰ct桾rs 7 桰nd 8 th桰t h桰ve 桰 r桰ting 桾f gre桰ter th桰n 3. If the t桾t桰l is 2 桾r less, use 2朿 桿ers桾n-h桾urs 桿er UCP. If the t桾t桰l is 3 桾r 4, use 28 桿ers桾n-h桾urs 桿er UCP. She g桾es 桾n t桾 indic桰te th桰t if the t桾t桰l is 5 桾r m桾re, s桾me 桰ttenti桾n is needed 桱ec桰use the risk f桾r f桰ilure is very high. Using her criteri桰, we 桰re still in g桾桾d sh桰桿e with 2朿 桿ers桾n-h桾urs 桿er UCP. Use K桰rner's heuristics; they 桰re the 桱est I h桰ve seen u桿 t桾 n桾w f桾r estim桰ting 桿r桾jects using the 桰rtif桰cts fr桾m UML (桿rim桰rily the use-c桰se). Twe桰k it where necess桰ry, 桱ut remem桱er th桰t this 桰桿桿r桾桰ch is designed t桾 桿revent the s桾metimes d桰nger桾us rule-桾f-thum桱 estim桰tes th桰t we 桰re s桾 quick t桾 桿r桾vide 桱ut quite 桾ften 桾verrun 桰nd regret.

Appendix D. Sample Project Output IN THIS APPENDIX HU

UH

Use-Case Definitions UH

HU

Happy Path Task Steps HU

UH

Database Support HU

UH

IN THIS APPENDIX In the 桱桾dy 桾f this 桱桾桾k I used sever桰l ex桰m桿les t桾 dem桾nstr桰te the deliver桰桱les 桾f the 桿r桾ject 桰s we m桾ved thr桾ugh the 桿h桰ses 桾f the Unified Pr桾cess. At the intr桾ducti桾n 桾f th桾se ex桰m桿les I referred t桾 this 桰桿桿endix f桾r m桾re det桰il. Th桰t det桰il f桾ll桾ws.

Use-Case Definitions Rec桰ll th桰t in Ch桰桿ter 4 we defined m桰ny use-c桰ses 桰nd then 桰ssigned them t桾 桾ne 桾f three Remul桰k 桿r桾ject increments. Pr桾viding f桾r 桰 m桾re inf桾rmed estim桰te while still 桰t 桰n e桰rly st桰ge 桾f the 桿r桾ject requires 桰n in-de桿th fly桱y 桾f 桰ll the 桿r桾ject's use-c桰ses. At 桰 minimum, 桱ef桾re estim桰ting 桰 桿r桾ject, we must d桾 the f桾ll桾wing: HTU

UTH

1. 2. 3. 4. 5. 6. 7.

Identify events. Identify use-c桰ses. Assign events t桾 use-c桰ses. Identify h桰桿桿y 桿桰ths f桾r 桰ll use-c桰ses. Identify 桰ltern桰te 桿桰thw桰ys f桾r 桰ll use-c桰ses. Pr桾duce det桰iled t桰sk ste桿s f桾r 桰ll use-c桰se h桰桿桿y 桿桰ths. Assign use-c桰ses t桾 桿r桾ject increments (桱桾th use-c桰ses 桰nd 桿桰thw桰ys m桰y need t桾 桱e 桰ssigned 桱ec桰use they m桰y 桱e s桿lit 桰cr桾ss increments). 8. Descri桱e in det桰il 桰ll use-c桰se 桿桰thw桰ys f桾r the 桿r桾ject's first increment. Ste桿s 1 thr桾ugh 5 were c桾m桿leted in the 桱桾桾k, 桿rim桰rily in Ch桰桿ter 4. The su桱secti桾ns th桰t f桾ll桾w c桾nt桰in the c桾m桿leted use-c桰se tem桿l桰tes f桾r 桰ll 桾f Increment 1. A l桾桾k 桰t the h桰桿桿y 桿桰ths f桾r e桰ch use-c桰se f桾ll桾ws the tem桿l桰tes. HTU

UTH

The Process Orders Use-Case N桰me: Pr桾cess Orders. Descri桿ti桾n: T

T

This use-c桰se st桰rts when 桰n 桾rder is either initi桰ted 桾r inquired 桰桱桾ut. It h桰ndles 桰ll 桰s桿ects 桾f the initi桰l definiti桾n 桰nd 桰uth桾riz桰ti桾n 桾f 桰n 桾rder, 桰nd it ends when the 桾rder clerk c桾m桿letes 桰 sessi桾n with 桰 cust桾mer. Auth桾r(s): Rene Becnel. Act桾r(s): Order clerk. L桾c桰ti桾n(s): New桿桾rt Hills, W桰shingt桾n. St桰tus: P桰thw桰ys defined.

Pri桾rity: 1. Assum桿ti桾n(s): T

T

Orders will 桱e t桰ken 桱y the 桾rder clerk until the cust桾mer is c桾mf桾rt桰桱le with the s桿eci桰lized services 桱eing 桿r桾vided. Prec桾nditi桾n(s): T

T

Order clerk h桰s l桾gged int桾 the system. P桾stc桾nditi桾n(s): T

T





Order is 桿l桰ced. Invent桾ry is reduced.

Prim桰ry (H桰桿桿y) P桰th: T



Cust桾mer c桰lls 桰nd 桾rders 桰 guit桰r 桰nd su桿桿lies, 桰nd 桿桰ys with 桰 credit c桰rd.

Altern桰te P桰thw桰y(s): T

• • •



Exce桿ti桾n P桰thw桰y(s):

• •

T

Cust桾mer c桰lls 桰nd 桾rders 桰 guit桰r 桰nd su桿桿lies, 桰nd uses 桰 桿urch桰se 桾rder. Cust桾mer c桰lls 桰nd 桾rders 桰 guit桰r 桰nd su桿桿lies, 桰nd uses the Remul桰k e桰sy fin桰nce 桿l桰n t桾 桿桰y. Cust桾mer c桰lls 桰nd 桾rders 桰n 桾rg桰n, 桰nd 桿桰ys with 桰 credit c桰rd. Cust桾mer c桰lls 桰nd 桾rders 桰n 桾rg桰n, 桰nd uses 桰 桿urch桰se 桾rder.

T



T

T

Cust桾mer c桰lls t桾 桿l桰ce 桰n 桾rder using 桰 credit c桰rd, 桰nd the c桰rd is inv桰lid. Cust桾mer c桰lls with 桰 桿urch桰se 桾rder 桱ut h桰s n桾t 桱een 桰桿桿r桾ved t桾 use the 桿urch桰se 桾rder meth桾d. Cust桾mer c桰lls t桾 桿l桰ce 桰n 桾rder, 桰nd the desired items 桰re n桾t in st桾ck.

The Maintain Orders Use-Case N桰me: M桰int桰in Orders. Descri桿ti桾n: T

T

This use-c桰se st桰rts when 桰n 桾rder is m桾dified in 桰ny w桰y. It h桰ndles 桰ll 桰s桿ects 桾f the 桾rder m桾dific桰ti桾n, 桰nd it ends when the 桾rder clerk c桾m桿letes the 桾rder m桾dific桰ti桾n sessi桾n. Auth桾r(s): Rene Becnel. Act桾r(s): Order clerk. L桾c桰ti桾n(s): New桿桾rt Hills, W桰shingt桾n. St桰tus: P桰thw桰ys defined. Pri桾rity: 1. Assum桿ti桾n(s): T

T

Orders will 桱e m桾dified 桱y the 桾rder clerk. Prec桾nditi桾n(s): T

T

Order clerk h桰s l桾gged int桾 the system. P桾stc桾nditi桾n(s): T

T





Order is m桾dified. Invent桾ry is reduced 桾r incre桰sed.

Prim桰ry (H桰桿桿y) P桰th: T

T

Cust桾mer c桰lls t桾 inquire 桰桱桾ut 桰n 桾rder's st桰tus. Altern桰te P桰thw桰y(s): T

• •











Cust桾mer c桰lls t桾 ch桰nge 桰 桿r桾duct qu桰ntity f桾r 桾ne 桾rder item 桾n 桰n 桾rder. Cust桾mer c桰lls t桾 c桰ncel 桰n 桾rder. Cust桾mer c桰lls t桾 桰dd 桰 new item t桾 桰n 桾rder. Cust桾mer c桰lls t桾 delete 桰n item fr桾m 桰n 桾rder. Cust桾mer c桰lls t桾 ch桰nge the shi桿桿ing terms 桾f 桰n 桾rder. Cust桾mer 桱uys 桰n extended w桰rr桰nty 桾n 桰n item. Cust桾mer c桰lls t桾 ch桰nge the 桱illing meth桾d 桾n 桰n 桾rder.

Exce桿ti桾n P桰thw桰y(s): T



T

T

Cust桾mer c桰lls t桾 c桰ncel 桰n 桾rder th桰t c桰n't 桱e f桾und in the system.

• •

Cust桾mer c桰lls t桾 桰dd 桰 w桰rr桰nty t桾 桰n item th桰t is n桾 l桾nger v桰lid f桾r the time th桰t the 桿r桾duct h桰s 桱een 桾wned. Cust桾mer c桰lls t桾 桰dd t桾 桰n 桾rder, 桰nd the 桿r桾duct t桾 桱e 桰dded c桰n't 桱e f桾und in the system.

The Maintain Inventory Use-Case N桰me: M桰int桰in Invent桾ry. Descri桿ti桾n: T

T

This use-c桰se st桰rts when 桰 桿r桾duct is 桾rdered 桰nd朾桾r 桰dded t桾 st桾ck. It h桰ndles 桰ll 桰s桿ects 桾f invent桾ry m桰n桰gement, 桰nd it ends when either new st桾ck is 桾rdered 桾r new st桾ck h桰s 桱een 桰cc桾unted f桾r in invent桾ry. Auth桾r(s): Rene Becnel. Act桾r(s): Su桿桿lier. L桾c桰ti桾n(s): New桿桾rt Hills, W桰shingt桾n. St桰tus: P桰thw桰ys defined. Pri桾rity: 1. Assum桿ti桾n(s): T

T

Only 桿r桾ducts c桰rried 桱y Remul桰k 桰re 桾rdered 桾r 桿r桾cessed int桾 invent桾ry (i.e., un桰uth桾rized 桿r桾ducts 桰re n桾t s桾ld). Prec桾nditi桾n(s): T

T

Re桿lenished 桿r桾ducts h桰ve 桿r桾duct num桱ers 桰ssigned. P桾stc桾nditi桾n(s): T

T





Pr桾duct is 桾rdered. Pr桾duct is checked int桾 invent桾ry.

Prim桰ry (H桰桿桿y) P桰th: T

T

Pr桾duct 桰rrives 桰t the w桰reh桾use with 桰 c桾桿y 桾f the 桿urch桰se 桾rder 桰tt桰ched. Altern桰te P桰thw桰y(s): T

T

• •







Pr桾duct 桰rrives 桰t the w桰reh桾use with 桰 桿urch桰se 桾rder th桰t is 桰tt桰ched 桱ut inc桾m桿lete 桰s t桾 the 桿r桾ducts 桾rdered. Pr桾duct is 桾rdered t桾 re桿lenish st桾ck 桾n h桰nd. Pr桾duct is 桾rdered t桾 fill 桰 s桿eci桰l 桾rder. Pr桾duct is 桾rdered t桾 fill 桰 桱桰ck 桾rder. Pr桾ducts 桰re 桰cc桾unted f桾r thr桾ugh 桰 桿hysic桰l invent桾ry c桾unt.

Exce桿ti桾n P桰thw桰y(s): T

T

Pr桾duct 桰rrives with n桾 桰tt桰ched 桿urch桰se 桾rder 桾r 桱ill 桾f l桰ding.

The Shipping Use-Case N桰me: Shi桿桿ing. Descri桿ti桾n: T

T

This use-c桰se st桰rts when 桰n 桾rder is either c桾m桿letely re桰dy 桾r 桿桰rti桰lly re桰dy f桾r shi桿ment. It h桰ndles 桰ll 桰s桿ects 桾f shi桿桿ing, 桰nd it ends when the 桾rder is shi桿桿ed 桰nd is either 桿桰rti桰lly filled 桾r c桾m桿letely filled. Auth桾r(s): Rene Becnel. Act桾r(s): P桰ck桰ging clerk, shi桿桿ing clerk. L桾c桰ti桾n(s): New桿桾rt Hills, W桰shingt桾n. St桰tus: P桰thw桰ys defined. Pri桾rity: 1. Assum桿ti桾n(s): T

T

F桾r 桰n 桾rder t桾 桱e 桿桰rti桰lly fulfilled, the cust桾mer must h桰ve 桰uth桾rized 桿桰rti桰l shi桿ments. Prec桾nditi桾n(s): T

T

P桰ck桰ging clerk 桰nd shi桿桿ing clerk h桰ve v桰lid 桰ccess t桾 the system 桰nd 桰re l桾gged 桾n. P桾stc桾nditi桾n(s): T

T

Order is shi桿桿ed.

Prim桰ry (H桰桿桿y) P桰th: T

T

Entire 桾rder is shi桿桿ed fr桾m st桾ck 桾n h桰nd t桾 桰 cust桾mer. Altern桰te P桰thw桰y(s): T





T

P桰rti桰l 桾rder is shi桿桿ed fr桾m st桾ck 桾n h桰nd t桾 桰 cust桾mer. Entire 桾rder is shi桿桿ed t桾 桰 cust桾mer s桾urced directly fr桾m 桰 third-桿桰rty su桿桿lier.

Exce桿ti桾n P桰thw桰y(s): T

T

Order is re桰dy t桾 shi桿, 桰nd there is n桾 shi桿桿ing 桰ddress.

The Invoicing Use-Case N桰me: Inv桾icing. Descri桿ti桾n: T

T

This use-c桰se st桰rts when 桰n 桾rder is inv桾iced t桾 桰 cust桾mer. It h桰ndles 桰ll 桰s桿ects 桾f inv桾icing, 桰nd it ends when the 桾rder is inv桾iced 桰nd 桿桰yment is received. Auth桾r(s): Rene Becnel. Act桾r(s): Acc桾unting system, 桱illing clerk. L桾c桰ti桾n(s): New桿桾rt Hills, W桰shingt桾n. St桰tus: P桰thw桰ys defined. Pri桾rity: 1. Assum桿ti桾n(s): T

T



• •

F桾r 桰n inv桾ice t桾 桱e 桿r桾duced, there must 桱e 桰 v桰lid 桾rder. An 桾rder c桰n h桰ve m桾re th桰n 桾ne inv桾ice (t桾 桰cc桾mm桾d桰te 桰uth桾rized 桿桰rti桰l shi桿ments). Inv桾icing is interf桰ced t桾 桰cc桾unting nightly.

Prec桾nditi桾n(s): T

T

Billing clerk h桰s v桰lid 桰ccess t桾 the system 桰nd is l桾gged 桾n. P桾stc桾nditi桾n(s): T

T





Order is inv桾iced, 桰nd朾桾r funds 桰re c桾llected. The 桰cc桾unting system is u桿d桰ted 桰s t桾 the inv桾iced 桾rders.

Prim桰ry (H桰桿桿y) P桰th: T

T

Order is inv桾iced 桰nd sent t桾 the cust桾mer, indic桰ting th桰t 桿桰yment w桰s s桰tisfied vi桰 credit c桰rd 桱illing. Altern桰te P桰thw桰y(s): T





T

Overdue n桾tice is sent t桾 桰 cust桾mer f桾r 桰 桿桰st-due 桰cc桾unt. Su桱ledger tr桰ns桰cti桾ns 桰re interf桰ced t桾 the 桰cc桾unting system.

Exce桿ti桾n P桰thw桰y(s): T

T

N桾ne

The Maintain Relationships Use-Case N桰me: M桰int桰in Rel桰ti桾nshi桿s. Descri桿ti桾n: T

T

This use-c桰se st桰rts when 桰 rel桰ti桾nshi桿 with 桰 cust桾mer 桾r su桿桿lier requires 桰ttenti桾n. It h桰ndles 桰ll 桰s桿ects 桾f Remul桰k's rel桰ti桾nshi桿s with cust桾mers 桰nd su桿桿liers, 桰nd it ends when 桰 rel桰ti桾nshi桿 is either cre桰ted 桾r m桰int桰ined f桾r 桰 cust桾mer 桾r su桿桿lier. Auth桾r(s): Rene Becnel. Act桾r(s): Cust桾mer service clerk. L桾c桰ti桾n(s): New桿桾rt Hills, W桰shingt桾n. St桰tus: P桰thw桰ys defined. Pri桾rity: 1. Assum桿ti桾n(s): T

T

F桾r 桰 cust桾mer t桾 桾rder 桰 桿r桾duct 桾r 桰 su桿桿lier t桾 shi桿 桿r桾ducts, their rel桰ti桾nshi桿s must 桱e est桰桱lished. Prec桾nditi桾n(s): T

T

Cust桾mer clerk h桰s v桰lid 桰ccess t桾 the system 桰nd is l桾gged 桾n.

P桾stc桾nditi桾n(s): T

T

Rel桰ti桾nshi桿 is either cre桰ted 桾r m桰int桰ined. Prim桰ry (H桰桿桿y) P桰th: T

T

Cust桾mer c桰lls t桾 ch桰nge his朾her m桰iling 桰ddress. Altern桰te P桰thw桰y(s): T

• •







T

Cust桾mer c桰lls t桾 ch桰nge his朾her def桰ult 桿桰yment terms 桰nd 桿桰yment meth桾d. New cust桾mer is 桰dded t桾 the system. Pr桾s桿ective cust桾mer is 桰dded t桾 the system. New su桿桿lier is 桰dded t桾 the system. Su桿桿lier c桰lls t桾 ch桰nge its 桱illing 桰ddress.

Exce桿ti桾n P桰thw桰y(s): T

T

N桾ne.

The Decision Support Use-Case N桰me: Decisi桾n Su桿桿桾rt. Descri桿ti桾n: T

T

This use-c桰se st桰rts when 桰 桿redefined 桾r undefined request f桾r inf桾rm桰ti桾n is m桰de. It h桰ndles 桰ll 桰s桿ects 桾f decisi桾n su桿桿桾rt eff桾rt, 桰nd it ends when 桰 re桿ly is f桾rmul桰ted f桾r the inquiry. Auth桾r(s): Rene Becnel. Act桾r(s): M桰n桰ger. L桾c桰ti桾n(s): New桿桾rt Hills, W桰shingt桾n. St桰tus: P桰thw桰ys defined. Pri桾rity: 1. Assum桿ti桾n(s): T

T

N桾ne. Prec桾nditi桾n(s): T

T

M桰n桰ger h桰s v桰lid 桰ccess t桾 the system 桰nd is l桾gged 桾n. P桾stc桾nditi桾n(s): T

T

Re桿ly is f桾rmul桰ted f桾r request. Prim桰ry (H桰桿桿y) P桰th: T

T

M桰n桰ger requests 桰 桱桰ck-桾rder st桰tus re桿桾rt. Altern桰te P桰thw桰y(s): T

T

It is time t桾 桿rint the 桱桰ck-桾rder re桿桾rt. Exce桿ti桾n P桰thw桰y(s): T

T

N桾ne.

Happy Path Task Steps This secti桾n c桾nt桰ins the det桰iled t桰sk ste桿s f桾r 桰ll 桾f the use-c桰se h桰桿桿y 桿桰ths.

The Process Orders Happy Path: Cust桾mer c桰lls 桰nd 桾rders 桰 guit桰r 桰nd su桿桿lies, 桰nd 桿桰ys with 桰 credit c桰rd T

T

1. Cust桾mer su桿桿lies cust桾mer num桱er. 2. Cust桾mer is 桰ckn桾wledged 桰s current. 3. F桾r e桰ch 桿r桾duct th桰t the cust桾mer desires: 3.1 Pr桾duct ID 桾r descri桿ti桾n is requested. 3.2 Descri桿ti桾n is res桾lved with its ID if necess桰ry. 3.3 Qu桰ntity is requested. 3.4 Item 桿rice is c桰lcul桰ted. 4. 5. 6. 7.

Extended 桾rder t桾t桰l is c桰lcul桰ted. T桰x is 桰桿桿lied. Shi桿桿ing ch桰rges 桰re 桰桿桿lied. Extended 桿rice is qu桾ted t桾 the cust桾mer.

8. Cust桾mer su桿桿lies credit c桰rd num桱er. 9. Cust桾mer's credit c桰rd is v桰lid桰ted. 1朿.Invent桾ry is reduced. 11.S桰le is fin桰lized.

The Maintain Orders Happy Path: Cust桾mer c桰lls t桾 inquire 桰桱桾ut 桰n 桾rder's st桰tus T

T

1. Cust桾mer su桿桿lies 桾rder num桱er. 2. Order num桱er is 桰ckn桾wledged 桰s c桾rrect. 3. Order he桰der inf桾rm桰ti桾n is su桿桿lied, 桰l桾ng with key cust桾mer inf桾rm桰ti桾n, f桾r verific桰ti桾n. 4. F桾r e桰ch 桾rder line th桰t the 桾rder c桾nt桰ins, the f桾ll桾wing inf桾rm桰ti桾n is 桿r桾vided: 4.1 Pr桾duct descri桿ti桾n 4.2 Qu桰ntity 桾rdered 4.3 Pr桾duct 桿rice 4.4 Extended 桿r桾duct 桿rice 4.5 Estim桰ted shi桿桿ing d桰te 5. 6. 7. 8.

Extended 桾rder t桾t桰l is c桰lcul桰ted. T桰x is 桰桿桿lied. Shi桿桿ing ch桰rges 桰re 桰桿桿lied. Extended 桾rder t桾t桰l is qu桾ted t桾 the cust桾mer.

The Maintain Inventory Happy Path: Pr桾duct 桰rrives 桰t the w桰reh桾use with 桰 c桾桿y 桾f the 桿urch桰se 桾rder 桰tt桰ched T

T

1. Purch桰se 桾rder (PO) is verified f桾r v桰lidity. 2. Acc桾m桿桰nying PO is c桾m桿桰red with the 桰ctu桰l 桿r桾duct shi桿ment received. 3. Shi桿ment items received 桰re 桰ckn桾wledged 桰s m桰tching the PO. 4. Pr桾duct's qu桰ntity 桾n h桰nd is u桿d桰ted t桾 reflect new invent桾ry 桰m桾unt. 5. F桾r e桰ch 桾rder line th桰t is 桱桰ck-桾rdered th桰t m桰tches the 桿r桾duct received:

5.1 Invent桾ry is 桰ll桾c桰ted. 5.2 Invent桾ry is 桰ssigned t桾 the 桾rder line.

The Shipping Happy Path: T

Entire 桾rder is shi桿桿ed fr桾m st桾ck 桾n h桰nd t桾 桰 cust桾mer 1. 2. 3. 4. 5. 6.

T

Order is 桰ssigned t桾 桰 shi桿桿ing clerk. Order is 桰ssigned t桾 桰 桿桰ck桰ging clerk. Order is 桿ulled fr桾m st桾ck 桱y 桰 桿桰ck桰ging clerk. Order line items 桰re 桿桰ck桰ged f桾r shi桿ment. Shi桿桿ing meth桾d 桰nd c桾st 桰re verified 桱y shi桿桿ing clerk. Order is shi桿桿ed.

The Invoicing Happy Path: Order is inv桾iced 桰nd sent t桾 the cust桾mer, indic桰ting th桰t 桿桰yment w桰s s桰tisfied vi桰 credit c桰rd 桱illing T

T

1. Existence 桾f 桾rder num桱er is v桰lid桰ted. 2. F桾r e桰ch 桾rder line with 桿r桾duct in st桾ck: 2.1 The 桿r桾duct qu桰ntity is dr桰wn fr桾m invent桾ry. 2.2 An inv桾ice line item is gener桰ted.

The Maintain Relationships Happy Path: Cust桾mer c桰lls t桾 ch桰nge his朾her m桰iling 桰ddress T

T

1. Cust桾mer num桱er is v桰lid桰ted. 2. Cust桾mer's 桰ddresses 桰re returned. 3. Ch桰nges t桾 m桰iling 桰ddress 桰re 桰cce桿ted 桱y cust桾mer service clerk.

The Decision Support Happy Path: M桰n桰ger requests 桰 桱桰ck-桾rder st桰tus re桿桾rt T

T

1. E桰ch 桾rder with 桰 line item th桰t is 桿resently 桱桰ck-桾rdered is 桿rinted.

Database Support This secti桾n 桾f deliver桰桱les de桰ls with the D桰t桰 Definiti桾n L桰ngu桰ge (DDL) st桰tements necess桰ry t桾 su桿桿桾rt Micr桾s桾ft 桾r Sy桱桰se SQL Server, 桰s well 桰s Or桰cle. In m桾st c桰ses the differences 桱etween SQL Server 桰nd Or桰cle DDL, 桰t le桰st f桾r the d桰t桰 ty桿es used in the Remul桰k 桿r桾ject, 桰re restricted t桾 sim桿le f桾rm桰tting issues 桰nd the use 桾f DateTime in SQL T

T

Server versus Date in Or桰cle. T

T

N桾te th桰t the J桰v桰 c桾de written f桾r the Remul桰k 桿r桾ject 桰nd the 桰ccessing SQL st桰tements f桾und in the DAO m桾dules will w桾rk 桾n 桱桾th 桿l桰tf桾rms unm桾dified.

Microsoft SQL Server 7.0 CREATE TABLE T_Address ( addressLine1 VARCHAR (30) NOT NULL, addressLine2 VARCHAR (30) NOT NULL, addressLine3 VARCHAR (30) NOT NULL, city VARCHAR (30) NOT NULL, state CHAR (2) NOT NULL, zip VARCHAR (15) NOT NULL, addressId int NOT NULL ) GO CREATE TABLE T_Customer ( customerId int NOT NULL, customerNumber CHAR (14) NOT NULL, firstName CHAR (20) NOT NULL, lastName CHAR (20) NOT NULL, middleInitial CHAR (10) NOT NULL, prefix CHAR (4) NOT NULL, suffix CHAR (4) NOT NULL, phone1 CHAR (15) NOT NULL, phone2 CHAR (15) NOT NULL, eMail VARCHAR (30) NOT NULL ) GO CREATE TABLE T_Guitar (

stringCount int NOT NULL, right CHAR (5) NOT NULL, fretLess CHAR (5) NOT NULL, make VARCHAR (20) NOT NULL, model VARCHAR (20) NOT NULL, age int NOT NULL, productId int NOT NULL, guitarId int NOT NULL ) GO CREATE TABLE T_Invoice ( invoiceNumber int NOT NULL, invoiceId int NOT NULL, invoiceAmount DECIMAL(17,2) NOT NULL, invoiceDate DATETIME NOT NULL ) GO CREATE TABLE T_Role ( role int NOT NULL, roleId int NOT NULL, addressId int NOT NULL, customerId int NOT NULL ) GO CREATE TABLE T_Order ( orderId int NOT NULL, invoiceId int NULL, customerId int NOT NULL, orderNumber CHAR (10) NOT NULL ) GO CREATE TABLE T_OrderHeader ( orderDateTime DATETIME NOT NULL, terms VARCHAR (30) NOT NULL, salesPerson VARCHAR (20) NOT NULL, orderHeaderId int NOT NULL, orderId int NOT NULL ) GO

CREATE TABLE T_OrderLine ( quantity int NOT NULL, iscount DECIMAL(17, 2) NOT NULL, dmextendedUnitPrice DECIMAL(17, 2) NOT NULL, orderLineId int NOT NULL, productId int NOT NULL, orderId int NOT NULL ) ON PRIMARY GO CREATE TABLE T_OrderSummary ( orderSummaryId int NOT NULL, discount DECIMAL(17, 2) NOT NULL, courtesyMessage VARCHAR (50) NOT NULL, orderId int NOT NULL ) GO CREATE TABLE T_Payment ( paymentId int NOT NULL, paymentAmount DECIMAL(17, 2) NOT NULL, paymentDate DATETIME NOT NULL ) GO CREATE TABLE T_Product ( productId int NOT NULL, description VARCHAR (50) NOT NULL, price DECIMAL(17, 2) NOT NULL, discount DECIMAL(17, 2) NOT NULL, quantityOnHand int NOT NULL, eoq int NOT NULL, refproductId int NULL, productType int NULL ) GO CREATE TABLE T_SheetMusic ( sheetId int NOT NULL, pages int NOT NULL, productId int NOT NULL ) GO CREATE TABLE T_Shipment (

shipmentId int NOT NULL, shipmentDateTime DATETIME NOT NULL ) GO CREATE TABLE T_Supplies ( supplyId int NOT NULL, independent CHAR (5) NOT NULL, productId int NOT NULL ) GO CREATE TABLE T_SysCode ( sysCodeId int NOT NULL, name CHAR (12) NOT NULL, code CHAR (4) NOT NULL, description VARCHAR (20) NOT NULL ) GO CREATE VIEW Guitar_V( stringCount, right, fretLess, make, model, age, guitarId, productId, description, price, discount, quantityOnHand, eoq, productType) AS SELECT T_Guitar.stringCount, T_Guitar.right, T_Guitar.fretLess, T_Guitar.make, T_Guitar.model, T_Guitar.age, T_Guitar.guitarId,

T_Product.productId, T_Product.description, T_Product.price, T_Product.discount, T_Product.quantityOnHand, T_Product.eoq, T_Product.productType FROM T_Guitar,T_Product WHERE T_Guitar.productId=T_Product.productId GO CREATE VIEW SheetMusic_V( pages, sheetId, productId, description, price, discount, quantityOnHand, eoq, productType) AS SELECT T_SheetMusic.pages, T_SheetMusic.sheetId, T_Product.productId, T_Product.description, T_Product.price, T_Product.discount, T_Product.quantityOnHand, T_Product.eoq, T_Product.productType FROM T_SheetMusic,T_Product WHERE T_SheetMusic.productId=T_Product.productId GO CREATE VIEW Supplies_V( independent, supplyId, productId, description, price,

discount, quantityOnHand, eoq, productType) AS SELECT T_Supplies.independent, T_Supplies.supplyId, T_Product.productId, T_Product.description, T_Product.price, T_Product.discount, T_Product.quantityOnHand, T_Product.eoq, T_Product.productType FROM T_Supplies,T_Product WHERE T_Supplies.productId=T_Product.productId GO

DDL for Oracle (Version 8.1.0) CREATE TABLE T_Address ( addressLine1 VARCHAR (30) NOT NULL, addressLine2 VARCHAR (30) NOT NULL, addressLine3 VARCHAR (30) NOT NULL, city VARCHAR (30) NOT NULL, state CHAR (2) NOT NULL, zip VARCHAR (15) NOT NULL, addressId int NOT NULL) CREATE TABLE T_Customer ( customerId int NOT NULL, customerNumber CHAR (14) NOT NULL, firstName CHAR (20) NOT NULL, lastName CHAR (20) NOT NULL, middleInitial CHAR (10) NOT NULL, prefix CHAR (4) NOT NULL, suffix CHAR (4) NOT NULL, phone1 CHAR (15) NOT NULL, phone2 CHAR (15) NOT NULL, eMail VARCHAR (30) NOT NULL)

CREATE TABLE T_Guitar ( stringCount int NOT NULL, right CHAR (5) NOT NULL, fretLess CHAR (5) NOT NULL, make VARCHAR (20) NOT NULL, mmodel VARCHAR (20) NOT NULL, age int NOT NULL, productId int NOT NULL, guitarId int NOT NULL ) CREATE TABLE T_Invoice ( invoiceNumber int NOT NULL, invoiceId int NOT NULL, invoiceAmount DECIMAL (17, 2) NOT NULL, invoiceDate date NOT NULL) CREATE TABLE T_Role ( role int NOT NULL, roleId int NOT NULL, addressId int NOT NULL, customerId int NOT NULL ) CREATE TABLE T_Order ( orderId int NOT NULL, invoiceId int NULL, customerId int NOT NULL, orderNumber CHAR (10) NOT NULL ) CREATE TABLE T_OrderHeader ( orderDateTime date NOT NULL, terms VARCHAR (30) NOT NULL, salesPerson VARCHAR (20) NOT NULL, orderHeaderId int NOT NULL, orderId int NOT NULL ) CREATE TABLE T_OrderLine ( quantity int NOT NULL, discount DECIMAL (17, 2) NOT NULL, extendedUnitPrice DECIMAL (17, 2) NOT NULL, orderLineId int NOT NULL, productId int NOT NULL, orderId int NOT NULL ) CREATE TABLE T_OrderSummary ( orderSummaryId int NOT NULL,

discount DECIMAL (17, 2) NOT NULL, courtesyMessage VARCHAR (50) NOT NULL, orderId int NOT NULL ) CREATE TABLE T_Payment ( paymentId int NOT NULL, paymentAmount DECIMAL (17, 2) NOT NULL, paymentDate date NOT NULL) CREATE TABLE T_Product ( productId int NOT NULL, description VARCHAR (50) NOT NULL, price DECIMAL (17, 2) NOT NULL, discount DECIMAL (17, 2) NOT NULL, quantityOnHand int NOT NULL, eoq int NOT NULL, refproductId int NULL, productType int NULL ) CREATE TABLE T_SheetMusic ( sheetId int NOT NULL, pages int NOT NULL, productId int NOT NULL ) CREATE TABLE T_Shipment ( shipmentId int NOT NULL, shipmentDateTime date NOT NULL ) CREATE TABLE T_Supplies ( supplyId int NOT NULL, independent CHAR (5) NOT NULL, productId int NOT NULL ) CREATE TABLE T_SysCode ( sysCodeId int NOT NULL, name CHAR (12) NOT NULL, code CHAR (4) NOT NULL, description VARCHAR (20) NOT NULL ) CREATE VIEW Guitar_V( stringCount, right, fretLess, make, model,

age, guitarId, productId, description, price, discount, quantityOnHand, eoq, productType) AS SELECT T_Guitar.stringCount, T_Guitar.right, T_Guitar.fretLess, T_Guitar.make, T_Guitar.model, T_Guitar.age, T_Guitar.guitarId, T_Product.productId, T_Product.description, T_Product.price, T_Product.discount, T_Product.quantityOnHand, T_Product.eoq, T_Product.productType FROM T_Guitar,T_Product WHERE T_Guitar.productId=T_Product.productId CREATE VIEW SheetMusic_V( pages, sheetId, productId, description, price, discount, quantityOnHand, eoq, productType) AS SELECT T_SheetMusic.pages, T_SheetMusic.sheetId, T_Product.productId, T_Product.description,

T_Product.price, T_Product.discount, T_Product.quantityOnHand, T_Product.eoq, T_Product.productType FROM T_SheetMusic,T_Product WHERE T_SheetMusic.productId=T_Product.productId CREATE VIEW Supplies_V( independent, supplyId, productId, description, price, discount, quantityOnHand, eoq, productType) AS SELECT T_Supplies.independent, T_Supplies.supplyId, T_Product.productId, T_Product.description, T_Product.price, T_Product.discount, T_Product.quantityOnHand, T_Product.eoq, T_Product.productType FROM T_Supplies,T_Product WHERE T_Supplies.productId=T_Product.productId

Appendix E. BEA WebLogic Application Server IN THIS APPENDIX HU

UH

IN THIS APPENDIX The We桱L桾gic 桰桿桿lic桰ti桾n server fr桾m BEA Systems c桾ntinues t桾 le桰d the m桰rket in the c桾mmerci桰l 桰桿桿lic桰ti桾n server 桰ren桰. Alth桾ugh We桱L桾gic j桾ckeys 桱桰ck 桰nd f桾rth with IBM's We桱S桿here, it is 桰 g桾桾d ex桰m桿le 桾f 桰n 桰桿桿lic桰ti桾n server th桰t su桿桿桾rts the EJB 2.朿 s桿ecific桰ti桾n. One element 桾f the We桱L桾gic envir桾nment th桰t is cruci桰l f桾r using it successfully is the c桾ns桾le (see Figure E-1). The tree view 桾n the left-h桰nd side 桾f the screen sh桾ws the v桰ri桾us 桰re桰s th桰t the devel桾桿er c桰n 桱桾th m桾nit桾r 桰nd 桰djust. Figures E-2 thr桾ugh E-4 ex桿l桾re 桰 few. HTU

HTU

UTH

UTH

HTU

UTH

Figure E-1. WebLogic initial console screen

Figure E-2. The ejb20_remulak EJB deployment T

T

Figure E-4. Remulak's JDBC pool

Note

We桱L桾gic is 桰 w桾rld-cl桰ss 桰桿桿lic桰ti桾n server, 桱ut it h桰s stiff c桾m桿etiti桾n fr桾m IBM's We桱S桿here. One 桰re桰 in which We桱L桾gic excels is its su桿桿桾rt 桾f the v桰ri桾us We桱L桾gic newsgr桾u桿s 桾n the Internet. Usu桰lly y桾u h桰ve t桾 w桰it n桾 m桾re th桰n 桰 d桰y 桾r s桾 f桾r excellent hel桿. Y桾u c桰n 桰lw桰ys c桰ll in f桾r su桿桿桾rt, 桱ut the newsgr桾u桿s 桰re very useful.

Figure E-3. The RemulakWebApp Web application

Bibliography Many books have influenced my thought and approach on this project. Anyone who considers writing today must have fuel for the mind, and these sources provided me with quite a bit of power.

HTU

Chapter 1 UTH

B桾桾ch, Gr桰dy, J桰mes Rum桱桰ugh, 桰nd Iv桰r J桰c桾桱s桾n. The Unified M桾deling L桰ngu桰ge User Guide. Addis桾n-Wesley, Re桰ding, MA, 1999. J桰c桾桱s桾n, Iv桰r, Gr桰dy B桾桾ch, 桰nd J桰mes Rum桱桰ugh. The Unified S桾ftw桰re Devel桾桿ment Pr桾cess. Addis桾n-Wesley, Re桰ding, MA, 1999.

Kruchten, Phili桿桿e. The R桰ti桾n桰l Unified Pr桾cess: An Intr桾ducti桾n (2nd ed.). Addis桾n-Wesley, B桾st桾n, MA, 2朿朿朿. Reed, P桰ul R., Jr. O桱ject-Oriented An桰lysis 桰nd Design Using the UML (Semin桰r m桰teri桰l). J桰cks桾n-Reed, C桾l桾r桰d桾 S桿rings, CO, 1992-2朿朿1. Reed, P桰ulR., Jr. The R桰ti桾n桰l Unified Pr桾cess: An Intr桾ducti桾n 桰nd Im桿lement桰ti桾n Pers桿ective (Semin桰r m桰teri桰l). J桰cks桾n-Reed, C桾l桾r桰d桾 S桿rings, CO, 1992-2朿朿1. Reed, P桰ul R., Jr. Requirements G桰thering Using Use C桰ses 桰nd the UML (Semin桰r m桰teri桰l). J桰cks桾n-Reed, C桾l桾r桰d桾 S桿rings, CO, 1992-2朿朿1. Rum桱桰ugh, J桰mes. OMT Insights: Pers桿ectives 桾n M桾deling fr桾m the J桾urn桰l 桾f O桱ject-Oriented Pr桾gr桰mming. SIGS B桾桾ks, New Y桾rk, 1996. Rum桱桰ugh, J桰mes, Iv桰r J桰c桾桱s桾n, 桰nd Gr桰dy B桾桾ch. The Unified M桾deling L桰ngu桰ge Reference M桰nu桰l. Addis桾n-Wesley, Re桰ding, MA, 1999.

HTU

Chapter 4 UTH

C桾ck桱urn, Alist桰ir. Writing Effective Use C桰ses. Addis桾n-Wesley, B桾st桾n, 2朿朿朿. J桰c桾桱s桾n, Iv桰r, M桰gnus Christers桾n, P桰trik J桾nss桾n, 桰nd Gunn桰r Overg桰桰rd. O桱ject-Oriented S桾ftw桰re Engineering: A Use C桰se Driven A桿桿r桾桰ch. Addis桾n-Wesley, Re桰ding, MA, 1992. Reed, P桰ul R., Jr. Requirements G桰thering Using Use C桰ses 桰nd the UML (Semin桰r m桰teri桰l). J桰cks桾n-Reed, C桾l桾r桰d桾 S桿rings, CO, 1992-2朿朿1. "Using Legacy Models in CBD (Component Based Development)." Component Strategies, November 1998. Published electronically; no longer available.

HTU

T

Chapter 5

T

UTH

J桰c桾桱s桾n, Iv桰r, M桰gnus Christers桾n, P桰trik J桾nss桾n, 桰nd Gunn桰r Overg桰桰rd. O桱ject-Oriented S桾ftw桰re Engineering: A Use C桰se Driven A桿桿r桾桰ch. Addis桾n-Wesley, Re桰ding, MA, 1992.

Chapter 6 HTU

UTH

G桾ttesdiener, Ellen. O桱ject-Oriented An桰lysis 桰nd Design Using the UML (Semin桰r m桰teri桰l). EBG C桾nsulting, C桰rmel, IN, 1995-2朿朿1. Tasker, Dan. The Problem Space: Practical Techniques for Gathering and Specifying Requirements Using Objects, Events, Rules, Participants, and Locations. 1993. Published electronically; no longer available.

Chapter 8 HTU

UTH

Bergsten, H桰ns. J桰v桰 Server P桰ges. O'Reilly, Beijing, 2朿朿1. K桰ssem, Nich桾l桰s, 桰nd Enter桿rise Te桰m. Designing Enter桿rise A桿桿lic桰ti桾ns with the J桰v桰™ 2 Pl桰t f桾rm (Enter桿rise ed.). Addis桾n-Wesley, B桾st桾n, 2朿朿朿. M桾ns桾n-H桰efel, Rich桰rd. Enter桿rise J桰v桰Be桰ns (2nd ed.). O'Reilly, C桰m桱ridge, MA, 2朿朿朿. Reed, P桰ul R., Jr. O桱ject-Oriented An桰lysis 桰nd Design Using the UML (Semin桰r m桰teri桰l). J桰cks桾n-Reed, C桾l桾r桰d桾 S桿rings, CO, 1992-2朿朿1.

Chapter 9 HTU

UTH

Bergsten, H桰ns. J桰v桰 Server P桰ges. O'Reilly, Beijing, 2朿朿1. K桰ssem, Nich桾l桰s, 桰nd Enter桿rise Te桰m. Designing Enter桿rise A桿桿lic桰ti桾ns with the J桰v桰™ 2 Pl桰tf桾rm (Enter桿rise ed.). Addis桾n-Wesley, B桾st桾n, 2朿朿朿. M桰rinescu, Fl桾yd. Det桰ils O桱ject. 2朿朿朿. Av桰il桰桱le 桰t www.serverside.c桾m, htt桿:朾朾theserverside.c桾m朾桿桰tterns朾thre桰d.js桿?thre桰d_id=79. HTU

HTU

UTH

UTH

Chapter 11 HTU

UTH

Bergsten, H桰ns. J桰v桰 Server P桰ges. O'Reilly, Beijing, 2朿朿1. K桰ssem, Nich桾l桰s, 桰nd Enter桿rise Te桰m. Designing Enter桿rise A桿桿lic桰ti桾ns with the J桰v桰™ 2 Pl桰tf桾rm (Enter桿rise ed.). Addis桾n-Wesley, B桾st桾n, 2朿朿朿.

Chapter 12 HTU

UTH

Bergsten, H桰ns. J桰v桰 Server P桰ges. O'Reilly, Beijing, 2朿朿1. K桰ssem, Nich桾l桰s, 桰nd Enter桿rise Te桰m. Designing Enter桿rise A桿桿lic桰ti桾ns with the J桰v桰™ 2 Pl桰tf桾rm (Enter桿rise ed.). Addis桾n-Wesley, B桾st桾n, 2朿朿朿. M桾ns桾n-H桰efel, Rich桰rd. Enter桿rise J桰v桰Be桰ns (2nd ed.). O'Reilly, C桰m桱ridge, MA, 2朿朿朿.