Thư viện tri thức trực tuyến
Kho tài liệu với 50,000+ tài liệu học thuật
© 2023 Siêu thị PDF - Kho tài liệu học thuật hàng đầu Việt Nam

Enterprise Java with UML
Nội dung xem thử
Mô tả chi tiết
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 9876543 2
Contents
OMG Press Advisory Board xvii
OMG Press Books in Print xix
About the OMG xxi
Chapter 1 Introduction to Modeling Java with the UML 1
What Is Modeling? 2
Simplification 3
Varying Perspectives 3
Common Notation 4
UML 4
The Basics 4
Modeling Software Systems with the UML 13
The Customer's Perspective 13
The Developer's Perspective 14
Modeling Process 14
Requirements Gathering 15
Analysis 15
Technology Selection 15
Architecture 15
Design and Implementation 16
The Next Step 16
Chapter 2 Gathering Requirements with UML 17
Are You Ready? 18
What Are Good Requirements? 18
Find the Right People 19
Listen to the Stakeholders 20
Develop Accessible Requirements 21
Describe Detailed and Complete Requirements 24
III
iv Contents
Refactor the Use Case Model 27
Guidelines for Gathering Requirements 34
Focus on the Problem 34
Don't Give Up 35
Don't Go Too Far 35
Believe in the Process 36
How to Detect Poor Requirements 37
Path 1: Excessive Schedule Pressure 38
Path 2: No Clear Vision 39
Path 3: Premature Architecture and Design 40
The Next Step 40
Chapter 3 Gathering Requirements for the Timecard Application 41
Listen to the Stakeholders 42
Build a Use Case Diagram 44
Find the Actors 44
Find the Use Cases 45
Determine the Actor-to-Use-Case Relationships 47
Describe the Details 48
Guidelines for Describing the Details 48
Gathering More Requirements 58
Revising the Use Case Model 61
Revise the Use Case Diagram 61
Revising the Use Case Documentation 63
The Next Step 75
Chapter 4 A Brief Introduction to Object-Oriented Analysis
with the UML 77
Are You Ready? 78
Solid Requirements 78
Prioritizing Use Cases 78
What Is Object-Oriented Analysis? 80
The Analysis Model 80
Relationship to Use Case Model SO
Steps for Object-Oriented Analysis 81
Discover Candidate Objects 81
Guidelines for Discovering Objects 81
Process for Discovering Objects 83
Describe Behavior 90
Guidelines for Finding Behavior 90
Contents v
A Process for Describing Behavior 92
Describe the Classes 95
Guidelines for Describing Classes 95
Process for Describing Classes 97
The Next Step 101
Chapter 5 Analysis Model for the Timecard Application 103
Prioritizing the Use Cases 103
The Ranking System 104
Evaluation of the Export Time Entries Use Case 107
Eva uation of the Create Charge Code Use Case 108
Eva uation of the Change Password Use Case 109
Eva uation of the Login Use Case 109
Eva uation of the Record Time Use Case 110
Eva uation of the Create Employee Use Case 111
Select Use Cases for the First Iteration 112
Discover Candidate Objects 112
Discover Entity Objects 113
Discover Boundary Objects 116
Discover Control Classes 118
Discover Lifecycle Classes 118
Describe Object Interactions 118
Add Tentative Behavior for Login 119
Build Sequence Diagrams for Login 119
Validate Sequences for Login 122
Sequence Diagrams and Class Diagrams for the
Remaining Use Cases 124
Describe Classes 126
Find Relationships for Login 127
Find Relationships for Export Time Entries 128
Find Relationships for Record Time 129
The Next Step 131
Chapter 6 Describing the System for Technology Selection 133
Are You Ready? 134
Group Analysis Classes 134
Boundary (User Interface) 134
Boundary (System Interface) 136
Control, Entity, and Lifecycle 136
Describe Each Group 136
User Interface Complexity 137
vi Contents
Deployment Constraints for User Interfaces 138
Number and Type of Users 140
Available Bandwidth 141
Types of System Interfaces 142
Performance and Scalability 143
Technology Requirements for the Timecard Application 144
Find Groups of Analysis Classes 144
User Interface Complexity 144
Deployment Constraints for User Interfaces 146
Number and Type of Users 147
Available Bandwidth 148
Types of System Interfaces 148
Performance and Scalability 148
The Next Step 152
Chapter 7 Evaluating Candidate Technologies for Boundary Classes 153
Technology Template 153
Swing 154
Gory Details 155
Strengths 165
Weaknesses 165
Compatible Technologies 165
Cost of Adoption 166
Suitability 167
Java Servlets 168
Gory Details 170
Strengths 172
Weaknesses 172
Compatible Technologies 172
Cost of Adoption 172
Suitability 173
XML 175
Gory Details 176
Strengths 178
Weaknesses 178
Compatible Technologies 178
Cost of Adoption 178
Suitability 179
Contents vii
Technology Selections for the Timecard System 180
User Interface Classes 180
Conclusion 181
The Next Step 182
Chapter 8 Evaluating Candidate Technologies for Control and
Entity Classes 183
RMI 183
Gory Details 184
Common Uses of RMI 188
Strengths 192
Weaknesses 192
Compatible Technologies 192
Cost of Adoption 192
JDBC 193
Gory Details 193
Strengths 196
Weaknesses 197
Compatible Technologies 198
Cost of Adoption 198
Suitability of RMI and JDBC 198
ETB 1.1 199
Gory Details 202
Strengths 205
Weaknesses 206
Compatible Technologies 206
Cost of Adoption 206
Suitability 207
Sampie Technology Selection 208
Technology Requirements 208
The Next Step 210
Chapter 9 Software Architecture 211
Are You Ready? 212
Clear Understanding of the Problem 212
Clear Understanding of the Technology 212
Goals for Software Architecture 213
Extensibility 213
Maintainability 213
viii Contents
Reliability 214
Scalability 214
UML and Architecture 214
Packages 214
Package Dependency 217
Subsystems 219
Guidelines for Software Architecture 221
Cohesion 222
Coupling 222
Creating a Software Architecture 222
The Architect 222
A Process 223
Sample Architecture for the Timecard System 225
Set Goals 225
Group and Evaluate Classes 226
Show Technologies 233
Extract Subsystems 233
Evaluate against Guidelines and Goals 233
The Next Step 237
Chapter 10 Introduction to Design 239
What Is Design? 239
Are You Ready? 240
The Need for Design 240
Productivity and Morale 240
A Malleable Medium 241
Scheduling and Delegation 241
Design Patterns 241
Benefits 242
Use 243
Planning for Design 243
Establish Goals for the Entire Design 244
Establish Design Guidelines 245
Find Independent Design Efforts 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 IX
Establish Goals for the Effort 250
Performance and Reliability 250
Reuse 250
Extensibility 250
Review Prior Steps 251
Review of the Analysis Model 251
Review Architectural Constraints 257
Design for Goals 258
Apply Design for Each Use Case 262
Design for the Login Use Case 262
Design for the Record Time Use Case 266
Design for the Export Time Entries Use Case 271
Evaluate the Design 273
Implementation 277
User Entity Bean 277
Timecard Entity Bean 283
LoginWorkflow Stateless Session Bean 292
RecordTimeWorkflow Stateful Session Bean 296
Supporting Classes 301
ChargeCodeHome 308
ChargeCodeWrapper.java 319
Node.java 320
The Next Step 321
Chapter 12 Design for HTML Production 323
Design Goals 324
Goal 1: Support Modular Construction of Views 324
Goal 2: Keep HTML Production Simple 324
Goal 3: Support Preferences 326
Goal 4: Extensibility and Encapsulation 326
Design to Goals 327
Design for Goal 1: Support Modular Construction
of Views 327
Design for Goal 2: Keep HTML Production Simple 330
Design for Goal 3: Support Preferences 335
Design for Goal 4: Extensibility and Encapsulation 338
Filling in the Details 339
Implementation 346
IHtmlProducer.java 346
ComboBoxProducer.java 347
X Contents
FormProducer.java 348
PageProducer.java 350
SubmitButtonProducer 351
TableProducer.java 352
TabularlnputFormProducer.java 354
TextFieldProducer.java 356
TextProducer.java 358
IConcreteProducer.java 359
ProducerFactory.java 360
FormProducerGeneric.java 364
PageProducerGeneric.java 366
TableProducerGeneric.java 368
TabularTnputFormProducerGeneric.java 369
The Next Step 371
Chapter 13 Design for the TimecardUl Package 373
Establish Design Goals 373
Extensibility 373
Testability 374
Review Prior Steps 374
Review Architectural Constraints 374
Review Analysis Model 375
Design to Goals 379
Design for Each Use Case 381
Create Design for the Login Use Case 381
Create Design for the Record Time Use Case 383
Implementation 387
LoginServlet.java 387
RecordTimeServlet.java 392
BaskServlet.java 397
The Next Step 399
Chapter 14 Design for Bill! ngSystem Interface 401
Identify Goals 401
Clarity 402
Performance and Reliability 402
Extensibility 402
Reuse Potential 402
Review of Analysis Model 402
Review of Architecture 402
Contents XI
Design 403
Sequence Diagram for Export Specific Users 406
Sequence Diagram for Export All Users 406
Participating Classes 406
Implementation 407
ExportCriteria.java 407
ExportFile.java 412
Exp or tTimeEntr ie s A pplic ation.java 414
Conclusion 417
Appendix A Visual Glossary 419
Appendix B Additional Resources 435
Appendix C The CD-ROM 439
Index 441
Acknowledgments
Thanks to all of my former coworkers and bosses at Number Six Software,
for their support, reviews, and insights. Special thanks are due to the
cofounders, Rob Daly and Brian Lyons, for creating an amazing environment in which to work and to stretch professionally. Special thanks to
Susan Cardinale, Greg Gurley, Kevin Puscas, Hugo Scavino, and Eric
Tavella for their feedback and encouragement.
Thanks to John Haynes for his careful review and commentary.
Thanks to Mike Janiszewski and Jennifer. Horn, for their review, encouragement, and support. Friends in need are friends in deed.
Many thanks to the fine professionals from John Wiley and Sons; Terri Hudson, Kathryn Malm, Angela Smith, Janice Borzendowski, and Brian
Snapp. Kathryn deserves special recognition for her ability to edit technical material while keeping an exhausted author motivated.
Thanks to the Wrights, for their consistent friendship, encouragement, and
lawn advice. We couldn't ask for better neighbors.
Thanks to my parents, for fostering a lifetime obsession with the printed
word.
I will never be able to sufficiently thank my family for permitting me this
most selfish endeavor. How many evenings and weekends did I take
away? How many mornings did T wake bleary eyed and grumpy from too
little sleep and too little progress? This book truly was a once in a lifetime
opportunity for the skinny (formerly) kid who read too much, and you
two made it possible. Thank you!
xiii
About the Author
CT Arlington has spent the last nine years developing client-server software
systems ranging from currency options valuation to barge scheduling to complex corporate intranets. Over the last five years, he has become convinced
that the combination of Object Oriented Analysis and Design and good Software Engineering practices can yield excellent systems in a sane work
environment.
CT's focus over the last few years has been architecting and developing systems in Java. These tended to be 3+ tier server side applications for use in corporate intranets. His favorite technologies for such systems include Servlets,
XML, EJB, and Object to Relational persistence frameworks. He also had the
good fortune to be the lead developer for a slick Java data visualization tool for
barge scheduling. This project used Swing and a commercial 2D graphics
framework and convinced him that Java applications can meet demanding
performance goals.
In these pursuits, CT has depended heavily on books on OO design, design
patterns, software engineering, Java, CORBA, EJB, and XML. While he has
read and enjoyed many great books over the years, he cannot imagine developing software without Grady Booch's OOAD with Applications, the Gang of
Four's Design Patterns, Steve McConnell's Rapid Development and of course,
Patrick Chan's The Java Class Libraries.
CT is an architect and development manager with Capital One in Northern
Virginia.
CT is a former Rational Software certified instructor and a Sun certified Java
Programmer, Developer, and Architect. He holds a Bachelor's in Applied
Mathematics from the University of Maryland at Baltimore County.
xv
OMG Press Advisory Board
Karen D. Boucher
Executive Vice President
The Standish Group
Carol C. Hurt
President and Chief Executive Officer
2AB, Inc.
Ian Foster
Business Director
Concept Five Technologies
Michael Gurevich
Chief Architect
724 Solutions
V. "Juggy" Jagannathan, Ph.D.
Senior Vice President of Research and Development
and Chief Technology Officer
CareFlow! Net, Inc.
Cris Kobryn
Chief Scientist and Senior Director
Inline Software
Nilo Mitra, Ph.D.
Principal System Engineer
Ericsson
Richard Mark Soley, Ph.D.
Chairman and Chief Executive Officer
Object Management Group, Inc.
xvii
Introduction to Modeling
Java with the UML
As Java completes its move from a novelty language to the language of choice for Webenabled enterprise computing, Java developers are faced with many opportunities as
well as many challenges. We must produce systems that scale as the underlying business grows and evolves at Web speed. Our customers' appetite for functionality, scalability, usability, extensibility, and reliability rises each year.
Fortunately, Java provides a lot of support as we struggle to meet these demands.
First and perhaps foremost, Java is a small, tightly written object-oriented language
with excellent support for exception handling and concurrency built in. Of course, this
language runs on a pi a tform-independent virtual machine that allows Java systems to
run on everything from a PalmPilot to a Web browser to an AS400, with about a dozen
operating systems in between. From this solid foundation. Sun built and evolved one
of the most impressive class libraries you could ever ask for, including support for
internationalization, calendar management, database access, image manipulation, networking, user interfaces, 2D and 3D graphics, and more. Finally, Enterprise JavaBeans
and Java 2 Enterprise Edition provide specifications for true cross-platform enterprise
computing. Many of the problems that have plagued enterprise developers for decades,
such as object-to-relational persistence, object caching, data integrity, and resource
management are being addressed with newfound vigor. These specifications, and the
application servers that implement them, allow us to leverage a wealth of academic
research and practical experience. We are better equipped to develop enterprise systems than ever before.
1