Enterprise Java™ with UML

10158-0012, (212) 850-6011, fax (212) 850-6008, E-Mail: PERMREQ @ WILEY.COM. This publication is designed to provide accurate and authoritative ...
181KB taille 40 téléchargements 144 vues
Enterprise Java™ with UML™

CT Arlington

Wiley Computer Publishing

John Wiley & Sons, Inc. NEW YORK • CHICHESTER • WEINHEIM • BRISBANE • SINGAPORE • TORONTO

To my beautiful wife Anne, you were sooo worth the wait! Always and forever, To Bethany Carleen, our precious daughter, and my personal trainer. To Anne Burzawa, my best friend from cradle to grave.

Publisher: Robert Ipsen Editor: Theresa Hudson Developmental Editor: Kathryn A. Malm Managing Editor: Angela Smith Text Design & Composition: Publishers' Design and Production Services, Inc. Designations used by companies to distinguish their products are often claimed as trademarks. In all instances where John Wiley & Sons, Inc., is aware of a claim, the product names appear in initial capital or ALL CAPITAL LETTERS. Readers, however, should contact the appropriate companies for more complete information regarding trademarks and registration. This book is printed on acid-free paper. © Copyright © 2001 by CT Arrington. All rights reserved. Published by John Wiley & Sons, Inc. Published simultaneously in Canada. No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by any means, electronic, mechanical, photocopying, recording, scanning or otherwise, except as permitted under Sections 107 or 108 of the 1976 United States Copyright Act, without either the prior written permission of the Publisher, or authorization through payment of the appropriate per-copy fee to the Copyright Clearance Center, 222 Rosewood Drive, Danvers, MA 01923, (978) 750-8400, fax (978) 750-4744. Requests to the Publisher for permission should be addressed to the Permissions Department, John Wiley & Sons, Inc., 605 Third Avenue, New York, NY 10158-0012, (212) 850-6011, fax (212) 850-6008, E-Mail: PERMREQ @ WILEY.COM. This publication is designed to provide accurate and authoritative information in regard to the subject matter covered. It is sold with the understanding that the publisher is not engaged in professional services. If professional advice or other expert assistance is required, the services of a competent professional person should be soughtLibrary of Congress Cataloging-in-Publication Data: ISBN: 0-471-38680-4 Printed in the United States of America. 10 9 8 7 6 5 4 3 2

Contents OMG Press Advisory Board

xvii

OMG Press Books in Print

xix

About the OMG

xxi

Chapter 1

Chapter 2

Introduction to Modeling Java with the UML

1

What Is Modeling? Simplification Varying Perspectives Common Notation UML The Basics Modeling Software Systems with the UML The Customer's Perspective The Developer's Perspective Modeling Process Requirements Gathering Analysis Technology Selection Architecture Design and Implementation The Next Step

2 3 3 4 4 4 13 13 14 14 15 15 15 15 16 16

Gathering Requirements with UML

17

Are You Ready? What Are Good Requirements? Find the Right People Listen to the Stakeholders Develop Accessible Requirements Describe Detailed and Complete Requirements

18 18 19 20 21 24 III

iv

Contents

Refactor the Use Case Model

Chapter 3

Chapter 4

27

Guidelines for Gathering Requirements Focus on the Problem Don't Give Up Don't Go Too Far Believe in the Process

34 34 35 35 36

How to Detect Poor Requirements Path 1: Excessive Schedule Pressure Path 2: No Clear Vision Path 3: Premature Architecture and Design

37 38 39 40

The Next Step

40

Gathering Requirements for the Timecard Application

41

Listen to the Stakeholders

42

Build a Use Case Diagram Find the Actors Find the Use Cases Determine the Actor-to-Use-Case Relationships

44 44 45 47

Describe the Details Guidelines for Describing the Details

48 48

Gathering More Requirements

58

Revising the Use Case Model Revise the Use Case Diagram Revising the Use Case Documentation

61 61 63

The Next Step

75

A Brief Introduction to Object-Oriented Analysis with the UML

77

Are You Ready? Solid Requirements Prioritizing Use Cases

78 78 78

What Is Object-Oriented Analysis? The Analysis Model Relationship to Use Case Model Steps for Object-Oriented Analysis

80 80 SO 81

Discover Candidate Objects Guidelines for Discovering Objects Process for Discovering Objects

81 81 83

Describe Behavior Guidelines for Finding Behavior

90 90

Contents

Chapter 5

Chapter 6

A Process for Describing Behavior

92

Describe the Classes Guidelines for Describing Classes Process for Describing Classes

95 95 97

The Next Step

101

Analysis Model for the Timecard Application

103

Prioritizing the Use Cases The Ranking System Evaluation of the Export Time Entries Use Case Eva uation of the Create Charge Code Use Case Eva uation of the Change Password Use Case Eva uation of the Login Use Case Eva uation of the Record Time Use Case Eva uation of the Create Employee Use Case Select Use Cases for the First Iteration

103 104 107 108 109 109 110 111 112

Discover Candidate Objects Discover Entity Objects Discover Boundary Objects Discover Control Classes Discover Lifecycle Classes

112 113 116 118 118

Describe Object Interactions Add Tentative Behavior for Login Build Sequence Diagrams for Login Validate Sequences for Login Sequence Diagrams and Class Diagrams for the Remaining Use Cases

118 119 119 122 124

Describe Classes Find Relationships for Login Find Relationships for Export Time Entries Find Relationships for Record Time

126 127 128 129

The Next Step

131

Describing the System for Technology Selection

133

Are You Ready?

134

Group Analysis Classes Boundary (User Interface) Boundary (System Interface) Control, Entity, and Lifecycle

134 134 136 136

Describe Each Group User Interface Complexity

136 137

v

vi

Contents

Deployment Constraints for User Interfaces Number and Type of Users Available Bandwidth Types of System Interfaces Performance and Scalability

Chapter 7

138 140 141 142 143

Technology Requirements for the Timecard Application Find Groups of Analysis Classes User Interface Complexity Deployment Constraints for User Interfaces Number and Type of Users Available Bandwidth Types of System Interfaces Performance and Scalability

144 144 144 146 147 148 148 148

The Next Step

152

Evaluating Candidate Technologies for Boundary Classes 153 Technology Template

153

Swing Gory Details Strengths Weaknesses Compatible Technologies Cost of Adoption Suitability

154 155 165 165 165 166 167

Java Servlets Gory Details Strengths Weaknesses Compatible Technologies Cost of Adoption Suitability

168 170 172 172 172 172 173

XML

175

Gory Details Strengths Weaknesses Compatible Technologies Cost of Adoption Suitability

176 178 178 178 178 179

Contents Technology Selections for the Timecard System User Interface Classes

Chapter 8

Conclusion

181

The Next Step

182

Evaluating Candidate Technologies for Control and Entity Classes

183

RMI

183

Gory Details Common Uses of RMI Strengths Weaknesses Compatible Technologies Cost of Adoption

184 188 192 192 192 192

JDBC Gory Details Strengths Weaknesses Compatible Technologies Cost of Adoption Suitability of RMI and JDBC

193 193 196 197 198 198 198

ETB 1.1

Chapter 9

180 180

199

Gory Details Strengths Weaknesses Compatible Technologies Cost of Adoption Suitability

202 205 206 206 206 207

Sampie Technology Selection Technology Requirements

208 208

The Next Step

210

Software Architecture

211

Are You Ready? Clear Understanding of the Problem Clear Understanding of the Technology

212 212 212

Goals for Software Architecture Extensibility Maintainability

213 213 213

vii

viii

Contents

Reliability Scalability

214 214

UML and Architecture Packages Package Dependency Subsystems

214 214 217 219

Guidelines for Software Architecture Cohesion Coupling

221 222 222

Creating a Software Architecture The Architect A Process

222 222 223

Sample Architecture for the Timecard System Set Goals Group and Evaluate Classes Show Technologies Extract Subsystems Evaluate against Guidelines and Goals

225 225 226 233 233 233

The Next Step

237

Chapter 10 Introduction to Design What Is Design?

239 239

Are You Ready?

240

The Need for Design Productivity and Morale A Malleable Medium Scheduling and Delegation

240 240 241 241

Design Patterns Benefits

241 242

Use

243

Planning for Design Establish Goals for the Entire Design Establish Design Guidelines Find Independent Design Efforts

243 244 245 246

Designing Packages or Subsystems

246

Design Efforts for the Timecard Application

247

The Next Step

248

Chapter 11 Design for the TimecardDomain and TimecardWorkflow

249

Contents

Establish Goals for the Effort Performance and Reliability Reuse Extensibility

250 250 250 250

Review Prior Steps Review of the Analysis Model Review Architectural Constraints Design for Goals

251 251 257 258

Apply Design for Each Use Case Design for the Login Use Case Design for the Record Time Use Case Design for the Export Time Entries Use Case

262 262 266 271

Evaluate the Design

273

Implementation User Entity Bean Timecard Entity Bean LoginWorkflow Stateless Session Bean RecordTimeWorkflow Stateful Session Bean Supporting Classes ChargeCodeHome ChargeCodeWrapper.java Node.java

277 277 283 292 296 301 308 319 320

The Next Step

321

Chapter 12 Design for HTML Production

323

Design Goals Goal 1: Support Modular Construction of Views Goal 2: Keep HTML Production Simple Goal 3: Support Preferences Goal 4: Extensibility and Encapsulation

324 324 324 326 326

Design to Goals Design for Goal 1: Support Modular Construction of Views Design for Goal 2: Keep HTML Production Simple Design for Goal 3: Support Preferences Design for Goal 4: Extensibility and Encapsulation

327 330 335 338

Filling in the Details

339

Implementation IHtmlProducer.java ComboBoxProducer.java

327

346 346 347

IX

X

Contents

FormProducer.java PageProducer.java SubmitButtonProducer TableProducer.java TabularlnputFormProducer.java TextFieldProducer.java TextProducer.java IConcreteProducer.java ProducerFactory.java FormProducerGeneric.java PageProducerGeneric.java TableProducerGeneric.java TabularTnputFormProducerGeneric.java The Next Step Chapter 13 Design for the TimecardUl Package

348 350 351 352 354 356 358 359 360 364 366 368 369 371 373

Establish Design Goals Extensibility Testability

373 373 374

Review Prior Steps Review Architectural Constraints Review Analysis Model

374 374 375

Design to Goals

379

Design for Each Use Case Create Design for the Login Use Case Create Design for the Record Time Use Case

381 381 383

Implementation LoginServlet.java RecordTimeServlet.java BaskServlet.java The Next Step Chapter 14 Design for Bill! ngSystem Interface Identify Goals Clarity Performance and Reliability Extensibility Reuse Potential

387 387 392 397 399 401 401 402 402 402 402

Review of Analysis Model

402

Review of Architecture

402

Contents Design Sequence Diagram for Export Specific Users Sequence Diagram for Export All Users Participating Classes Implementation ExportCriteria.java ExportFile.java Exp or tTimeEntr Conclusion

ie

s

A

pplic

403 406 406 406 407 407 412 ation.java 414 417

Appendix A Visual Glossary

419

Appendix B Additional Resources

435

Appendix C The CD-ROM

439

Index

441

XI