Contents •Index Aspect-Oriented Software Development with Use Cases By Ivar Jacobson, Pan-Wei Ng Publisher : Addison Wesley Professional Pub Date : December 30, 2004 ISBN : 0-321-26888-1
Trang 1Contents
•Index
Aspect-Oriented Software Development with Use Cases
By Ivar Jacobson, Pan-Wei Ng
Publisher : Addison Wesley Professional Pub Date : December 30, 2004
ISBN : 0-321-26888-1 Pages : 464
Aspect-oriented programming (AOP) is a revolutionary new way to think about software engineering AOP was introduced to address crosscutting concerns such as security, logging, persistence, debugging, tracing, distribution, performance monitoring, and exception handling in a more effective manner Unlike conventional development techniques, which scatter the implementation of each concern into multiple classes, aspect-oriented programming localizes them.
Aspect-oriented software development (AOSD) uses this approach to create
a better modularity for functional and nonfunctional requirements, platform specifics, and more, allowing you to build more understandable systems that are easier to configure and extend to meet the evolving needs of
stakeholders.
In this highly anticipated new book, Ivar Jacobson and Pan-Wei Ng demonstrate how to apply use casesa mature and systematic approach to focusing on stakeholder concernsand aspect-orientation in building robust and extensible systems Throughout the book, the authors employ a single, real-world example of a hotel management information system to make the described theories and practices concrete and understandable.
case modules, as well as extend them They also demonstrate how to design use-case modules with the Unified Modeling Language (UML)emphasizing enhancements made in UML 2.0and how to achieve use-case modularity using aspect technologies, notably AspectJ.
Trang 2Whatever your level of experience with aspect-oriented programming, Aspect-Oriented Software Development with Use Cases will teach you how to develop better software by
embracing the paradigm shift to AOSD.
Trang 3Contents
•Index
Aspect-Oriented Software Development with Use Cases
ByIvar Jacobson, Pan-Wei Ng
Publisher : Addison Wesley Professional Pub Date : December 30, 2004
ISBN : 0-321-26888-1 Pages : 464
Trang 4
Keeping Peers Separate with Aspects Section 2.3.
Keeping Extensions Separate with Aspects Section 2.4.
Need for Methodological Guidance
Chapter 3.
Today with Use Cases
Section 3.1.
Trang 6Use-Case Modeling
Section 5.2.
Use-Case Instances and Flows of Events Section 5.3.
Trang 16The authors and publisher have taken care in the preparation of this
book, but make no expressed or implied warranty of any kind and
assume no responsibility for errors or omissions No liability is assumedfor incidental or consequential damages in connection with or arising out
of the use of the information or programs contained herein
The publisher offers excellent discounts on this book when ordered inquantity for bulk purchases or special sales, which may include electronicversions and/or custom covers and content particular to your business,training goals, marketing focus, and branding interests For more
Trang 18Upper Saddle River, NJ 07458
Text printed in the United States on recycled paper at Courier inStoughton, Massachusetts First printing, December 2004
Trang 19boundaries Now that aspect-oriented programming (AOP) canexpress crosscutting concerns directly in code, the man who
developed use cases has proposed step-by-step methods for
recognizing crosscutting concerns in use cases and writing thecode in separate modules If these methods are at all fruitful inyour design and development practice, they will make a big
difference in software quality for developers and users alike."
WES ISBERG
AspectJ team member
oriented software development is but how it can be utilized in areal development project."
"This book not only provides ideas and examples of what aspect-MICHAEL WARD
ThoughtWorks, Inc.
"No system has ever been designed from scratch perfectly; everysystem is composed of features layered in top of features thataccumulate over time Conventional design techniques do nothandle this well, and over time the integrity of most systems
Trang 20to be defined in terms of layered functionality but composition is atthe very heart of the approach This book is an important advance
in modern methodology and is certain to influence the direction of
software engineering in the next decade, just as Object-Oriented Software Engineering influenced the last."
KURT BITTNER
IBM Corporation
"Use cases are an excellent means to capture system
requirements and drive a user-centric view of system developmentand testing This book offers a comprehensive guide on explicituse-case-driven development from early requirements modeling todesign and implementation It provides a simple yet rich set ofguidelines to realize use-case models using aspect-oriented
design and programming It is a valuable resource to researchersand practitioners alike."
DR AWAIS RASHID
Lancaster University, U.K., and author of
Aspect-Oriented Database Systems
"AOSD is important technology that will help developers producebetter systems Unfortunately, it has not been obvious how to
integrate AOSD across a project's lifecycle This book shatters thatbarrier, providing concrete examples on how to use AOSD fromrequirements analysis through testing."
CHARLES B HALEY
research fellow, The Open University, U.K.
Trang 21Arlow/Neustadt, Enterprise Patterns and MDA: Building Better Software with Archetype Patterns and UML
Arlow/Neustadt, UML and the Unified Process: Practical Object-Oriented Analysis and Design Armour/Miller, Advanced Use Case Modeling:
Software Systems
Bellin/Simone, The CRC Card Book
Bergström/Råberg, Adopting the Rational Unified Process: Success with the RUP
Binder, Testing Object-Oriented Systems: Models, Patterns, and Tools Bittner/Spence, Use Case Modeling
Trang 22Conallen, Building Web Applications with UML, 2E
D'Souza/Wills, Objects, Components, and Frameworks with UML: The Catalysis(SM) Approach Douglass, Doing Hard Time: Developing Real- Time Systems with UML, Objects, Frameworks, and Patterns Douglass, Real-Time Design Patterns: Robust Scalable Architecture for Real-Time Systems Douglass, Real Time UML, 3E: Advances in The UML for Real- Time Systems Eelesetal., Building J2EE ™ Applications with the Rational Unified Process Fontoura/Pree/Rumpe, The UML Profile for Framework Architectures
Fowler, Analysis Patterns: Reusable Object Models
Fowler et al., Refactoring: Improving the Design of Existing Code
Fowler, UML Distilled, 3E: A Brief Guide to the Standard Object Modeling Language Gomaa, Designing Concurrent, Distributed, and Real-Time Applications with UML
Gomaa, Designing Software Product Lines with UML
Graham, Object-Oriented Methods, 3E: Principles and Practice
Heinckiens, Building Scalable Database Applications: Object-Oriented Design, Architectures, and Implementations Hofmeister/Nord/Dilip,
Applied Software Architecture
Jacobson/Booch/Rumbaugh, The Unified Software Development Process Jordan, C++ Object Databases: Programming with the ODMG Standard
Kleppe/Warmer/Bast, MDA Explained: The Model Driven Architecture™: Practice and Promise Kroll/Kruchten, The Rational Unified Process Made Easy: A Practitioner's Guide to the RUP
Kruchten, The Rational Unified Process, 3E: An Introduction
Trang 23Leffingwell/Widrig, Managing Software Requirements, 2E: A Use Case Approach Manassis, Practical Software Engineering: Analysis and
Design for the NET Platform Marshall, Enterprise Modeling with UML: Designing Successful Software through Business Analysis
McGregor/Sykes, A Practical Guide to Testing Object-Oriented Software Mellor/Balcer, Executable UML: A Foundation for Model-Driven
Architecture Mellor et al., MDA Distilled: Principles of Model-Driven
Architecture Naiburg/Maksimchuk, UML for Database Design
Oestereich, Developing Software with UML, 2E: Object-Oriented Analysis and Design in Practice Page-Jones, Fundamentals of Object-Oriented Design in UML
Pohl, Object-Oriented Programming Using C++, 2E
Pollice et al Software Development for Small Teams: A RUP-Centric Approach Quatrani, Visual Modeling with Rational Rose 2002 and UML Rector/Sells, ATL Internals
Reed, Developing Applications with Visual Basic and UML
Rosenberg/Scott, Applying Use Case Driven Object Modeling with UML:
An Annotated e-Commerce Example Rosenberg/Scott, Use Case Driven Object Modeling with UML: A Practical Approach Royce, Software
Project Management: A Unified Framework
Rumbaugh/Jacobson/Booch, The Unified Modeling Language Reference Manual Schneider/Winters, Applying Use Cases, 2E: A Practical Guide
Smith/Williams, Performance Solutions: A Practical Guide to Creating Responsive, Scalable Software Stevens/Pooley, Using UML, Updated Edition: Software Engineering with Objects and Components Unhelkar, Process Quality Assurance for UML-Based Projects
van Harmelen, Object Modeling and User Interface Design: Designing Interactive Systems Wake, Refactoring Workbook
Trang 24Warmer/Kleppe, The Object Constraint Language, 2E: Getting Your Models Ready for MDA White, Software Configuration Management Strategies and Rational ClearCase ® : APractical Introduction
Trang 25Cheesman/Daniels, UML Components: A Simple Process for Specifying Component-Based Software Szyperski, Component Software, 2E:
Beyond Object-Oriented Programming
Whitehead, Component-Based Development: Principles and Planning for Business Systems
Trang 27That you have picked up this book tells us that you are a member of thesoftware development community: a tester, a developer, a project leader,
a project manager, an architect, an analyst, or a member involved in one
of the many other aspects of developing We also know that you are
someone who wants to improve the way you develop software You wantyour system to be more maintainable, more extensible, more reusable,and if you are a project leader, you want your team to be more
productive You know that these goals are not always easy to achieve
Why is software development so difficult? One reason is that there aremany things to watch out for On the human side, you have to watch outfor time, budget, resources, skills, and so forth Frequently, as a teammember, you have many taskssome of them beyond what you are paidfor You report to two different people and each expects 100 percent fromyou, so you must give 200 percent to your work As the developer, youmust understand the application, the domain, and the idiosyncrasies ofthe platform When you design the system, you need to deal with andbalance many difficult concerns: how the system meets its intended
functionality, how it achieves performance and reliability, how it deals withplatform specifics, and so forth You may find that your codeyour classes,your operations, your proceduresmust perform many functions, whichmay lead to spaghetti code, an indication of poor design So, you need toimprove designimprove modularity and provide better separation of
concerns Just as each team member must be clearly focused on his orher work, each component, each class, each operation must be focused
on what is its specific purpose
But there is a limit to what you can do with existing techniques No matterhow far you go, you find that many parts of your system have code
fragments that have to do with logging, authorization, persistence,
debugging, tracing, distribution, exception handling, and other such
tasks Sometimes, a sizeable portion of an operation or class has nothing
to do with what it is supposed to do Aspect-oriented programming (AOP)refers to such redundancy as crosscutting concerns because you find
Trang 28cut across operations and classes Crosscutting concerns are not limited
to the technical concerns such as authorization and persistence Theyinclude system and application functionality, and you find that a change infunctionality often results in changes in many classes too
AOP gives you the means to separate code that implements crosscuttingconcerns and modularize it into aspects Aspect-orientation provides themechanism to compose crosscutting behaviors into the desired
operations and classes during compile time and even during execution.The source code for your operations and classes can be free of
crosscutting concerns and therefore easier to understand and maintain
Trang 29Development?
In order to progress beyond AOP, you need a holistic approach to
developing software systems with aspects from requirements, to analysisand design, to implementation and test This is aspect-oriented softwaredevelopment (AOSD)
AOSD is about better modularity for the entire system, encompassingconcerns of many different kindsbetter modularity for functional
requirements, nonfunctional requirements, platform specifics, and soonand keeping them separate from each other Keeping all concernsseparate allows you to construct systems that have a more
understandable structure and are easily configured and extended to meetthe evolving needs of stakeholders
AOSD is not just AOP It encompasses a whole range of techniques tohelp you achieve better modularity These techniques include object
oriented frameworks such as J2EE and NET, and more AOSD does notcompete with existing techniques but is built on top of them
Trang 30How do you conduct AOSD? How do you identify aspects? When do youuse classes as opposed to aspects? How do you specify aspects? Youneed a sound and systematic approach to help you conduct AOSD Thedevelopment community is crying out for this kind of systematic approach
to software development
In fact, there is such a systematic approachand a mature one too It iscalled the use-case-driven approach It provides a sound method fordeveloping applications by focusing on realizing stakeholder concernsand delivering value to the user
It is well known that aspect orientation helps modularize crosscuttingconcerns during implementation, but there is a need to modularize
transition from expressing requirements of stakeholder concerns withuse-cases to implementing them with aspects
Briefly, you conduct AOSD with use-cases as follows: You model
crosscutting concerns with use-cases You design use-cases in terms ofoverlays on top of classesoverlays called use-case slices and use-casemodules You use aspect technology to compose use-cases slices anduse-case modules to form the complete model for the system
We use a home-construction analogy to explain the approach further.Let's say you have a new house, but it is just an empty house with nofixturesno lights, no phone lines, no wiring, no gas, and no Internet! Eachmissing fixture or service is a distinct concern, evidenced by the fact that
Trang 31fixtures and services are crosscutting concernsthey cut across different
rooms (i.e., objects) They are analogous to use-cases To determinehow he or she will go about his or her job, each specialist must design aplan, often in terms of a diagram based on the floor plan The floor planshows where the rooms and the walls are The electrician makes a
photocopy of the floor plan and draws how she intends to install electricwiring; the plumber sketches out how he plans to run water pipes aroundthe house; and so on Each specialist can work separately, but all of thembase their work on the same floor plan The overall work to be done is thesum of all these diagrams
If each specialist were to draw his or her diagram on a transparency, thetransparencies could be merged by overlaying them on a projector
case modules As long as the overlays are based on the same
These overlays are analogous to what we call use-case slices and use-dimensions of the floor plan, you can get a perfect image on the screen
showing all the work to be done If there is a need to change the laying of
Internet lines, you just rework the overlay that describes that plan andupdate the merged model When you project it with the other overlays,you get the updated image of the house You can easily stack more
overlays on the picture or swap in and out overlays You get a coherentimage provided that the dimensions correspond to each other This
represents the architectural work involved
Systems developed using use-case slices and use-case modules have aclear separation of crosscutting concerns You can evolve them and
extend them It is easier to make each slice reusable You can
automatically generate certain slices because they do not interfere withother slices You get better maintainability, better extensibility, and greaterproductivity with this approach
The development community can gain even more from conducting AOSDwith use-cases We believe that the adoption of aspect orientation willaccelerate significantly by basing it on the use-case-driven approachbecause this approach has already been widely accepted as a means todrive system development, testing, and delivery Much literature on theuse-case-driven approach is readily available for the development
Trang 32attractive and even natural to base AOSD on the use-case-drivenapproach
Trang 33This book systematically outlines how to conduct AOSD with use-cases
We cover requirements, analysis, design, implementation, and test Wedemonstrate how to model crosscutting concerns and aspects with UMLand how to establish a resilient architecture that is based on use-casesand aspects We highlight key changes in practice and the paradigmshifts that you must note when applying AOSD We give pointers on howyou can quickly reap the benefits of AOSD in your projects
We demonstrate how you conduct AOSD in a mixed environment of
object-oriented frameworks such as J2EE, object-oriented design
patterns, AOP, and so on, because we recognize that these are the
challenges you face in practice We show you how to map aspect anduse-case analysis to different design and implementation technologies
We spend a great deal of time in this book describing how to establish afirm architecture based on use-cases and aspectsan architecture that isresilient to changes
Some of you may be familiar with earlier works by Ivar Jacobson, such as
Object-Oriented Software Engineering: A Use-Case Driven Approach (Addison-Wesley, 1992) and The Unified Software Development Process
(Addison-Wesley, 1999) This book should be read in conjunction withthose books
Some of you may have read books on aspect orientation and wonderedabout its implications for software development as a whole This is thebook for you Newcomers to aspect orientation will learn its principles andapplication If you are familiar with the use-case-driven approach, youshould readily recognize the benefits and implications of aspect
orientation This book will help you to appreciate the larger context ofaspectsnot just AOP, but AOSD
In this book, we use a single example of a Hotel Management System,which you become familiar with as we progress through the book By
Trang 34building upon a single example, we keep our discussion of aspectorientation and use-cases focused and concrete.
Trang 35This book is not a programming book We do not go into details aboutAOP languages or aspect-oriented frameworks that are currently
available For those details, refer to guide books and tutorials This book
is about aspect-oriented software development (not just programming).
The emphasis is on a software development approach from requirements
to code, applying a number of techniques in a balanced and iterativemanner to help you succeed in building your software systems
This book does not attempt to be an aspect-oriented design cookbook
We do not attempt to discuss all conceivable crosscutting concerns
(synchronization, transaction management, caching, etc.) Nevertheless,
we believe that the breadth of this book provides the principles and thebasis for you to deal with many kinds of crosscutting concerns that youwill encounter in practice
Trang 36There are several prerequisites to getting the most out of this book Youmust have at least some understanding of the Unified Modeling
Language (UML) We include some explanation of UML in this book, but
we largely expect you to know the basics We expect you to know whatclasses are and that you can read use-case diagrams, class diagrams,sequence diagrams, and collaboration diagrams Incidentally, the last two
are called interaction diagrams and communication diagrams in UML 2.0.
If you have ever applied use-case-driven development in a project, thenyou will really benefit from this bookeven if you do not have any
background in aspect orientation We had you in mind when we wrotethis book and spent some time to ground you in the basics of AOP
If you are knowledgeable about aspect orientation and have little ideaabout use-case-driven development, do not fret We have you in mind,too Part II is devoted to acquainting you with use cases and use-caserealizations
some knowledge of J2EE is useful If you have ever heard about servletsand EJBs, you should have sufficient background If you know the J2EEcore patterns, better still
So, welcomeand read this book
Trang 37We organized this book into five parts:
Part I is basically an expansion of this preface The goal is to help youunderstand what AOSD with use cases is all about We highlight somebasic cases of crosscuttingpeers and extensionsand how aspects solvethem Through some simple code examples, we introduce AspectJ,
which is currently the most popular AOP technology We provide an
overview of use-case-driven development as it is todaywhat use casesare, how use cases are realized, and how they are mapped to
classesand what we expect it to be like tomorrowwith aspects, use caseslices and use case modules
Part II, Modeling and Capturing Concerns with Use Cases
Whether you are familiar with use cases or not, you should read Part II Itgives you an overview of the use-case technique and clarifies commonmisconceptions about use cases Part II also enhances the use-casemodeling technique to provide a seamless transition from use-case
modeling to aspect-oriented analysis and design In particular, we showhow pointcuts are modeled within use cases Part II culminates by
walking through a rich example of applying use-case modeling to
different crosscutting concernsboth functional and nonfunctional Theyare modeled with use cases of different kindsapplication use cases andinfrastructure use cases Subsequent parts of the book demonstrate how
to drive these different kinds of use cases all the way to implementation
Trang 38Case Modules
Part III goes deeper into the concept of use-case slices and use-casemodules Use-case slices help you keep the specifics of a use case
separate in the design model They are the overlays we mentioned tokeep crosscutting concerns separate We show you how to model use-case slices and aspects with UML and how our extensions to the UMLnotation map to AOP We use this notation and the underlying concepts
in Part IV, and the notation is summarized in Appendix B
Part IV, Establishing an Architecture Based on Use Cases and Aspects
The most important determinant to the success of a project lies in itsarchitecture Part IV demonstrates how to get good architecture, step bystep Among other things, a good architecture keeps concerns of differentkinds separate It separates the use-case-specific from the use-case-generic, the application-specific from the application-generic; the
platform-specific from the platform-independent; and so on This
separation not only makes your system more understandable and
maintainable, it also makes your system extensible It makes parts ofyour system reusable without causing those parts to be entangled It alsoprovides room for significant automation when implementing the system
In Part IV, there are plenty of useful tips and guidelines to such an
architecture You might need to refer to Appendix B on the notations used
in the book as you read Part IV
Part V, Applying Use Cases and Aspects in a
Project
Trang 39different project scenarios We also show you how to effectively manage
a project that is based on use cases and aspects
Trang 40Research papers often have many authors, and you may wonder whateach author contributed to the work Here, we reminisce about how thisbook came about and explain our individual contributions to the conceptsand pragmatics described in this book
In the Beginning By Ivar
The first time I heard the term aspect-oriented programming was back in
1997 I immediately saw it as an interesting technology, but at the time, Icouldn't take a serious look at I was working on the first version of UML,and on getting Rational Unified Process (RUP) right, and I was initiating
Pointer When I finally had time to take a good look at aspects, it was inSeptember 2002 I downloaded a lot of papers and studied them for acouple of days Then I contacted Harold Ossher at IBM Research andKarl Lieberherr at Northeastern University in Boston They are two of theleaders in this space The most well-known person on aspects is GregorKizcales I tried to get his attention as well, but he was too busy at thattime However, he contributed to this book by reviewing it extensively,and we benefited significantly from his comments
an effort on active software processesactually what is now Jaczone Way-In November 2002, I visited the IBM folks and spent a day with themlearning about their work After the meeting, I was very impressed andexcited about what they had done I left their office and rushed to Newarkairport; I had to run to the gate This is normal I was on my way to
Stockholm When I was seated in the plane, I ordered some champagneand began to relax and think a little Suddenly, it struck me Didn't I dosomething similar before? Didn't I write a paper on the same subject forOOPSLA '86the very first OOPSLA conference?
When I got to Stockholm, I hunted for the paper It was a paper that
discussed a topic that I mentioned as future work in my Ph.D thesis from