Accelerating Java Development Using the UML: An Application Development Tutorial Chattanooga JAVA User Group
Jeffrey H Bush
Software Consultant Embarcadero Technologies,Inc.
© 2001 Embarcadero Technologies, Inc.
Tutorial Outline • Part 1: Overview of the UML • Part 2: Building a sample Java application • Appendix: UML diagrams reviewed
Part One
© 2000 Embarcadero Technologies, Inc.
UML Overview
What is the UML? • Unified Modeling Language • An industry standard design notation for: • Expressing software architecture • Expressing software dynamics and behavior • Documenting software deployment
• OMG standard • The de-facto industry standard today • The UML supports both Process and Architecture
UML Architecture Support 4 + 1 View Model of Architecture Design View
Implementation View Component Diagram Interaction Diagrams Statechart Diagram Activity Diagram
Class & Object Diagrams Interaction Diagrams Statechart Diagram Activity Diagram
Use Case View Use Case Diagram Interaction Diagrams Statechart Diagram Activity Diagram Class & Object Diagrams Interaction Diagrams Statechart Diagram Activity Diagram
Deployment Diagram Interaction Diagrams Statechart Diagram Activity Diagram
Process View
Deployment View Reprinted from The Unified Modeling Language Users Guide
Architecture • Use Case View – encompasses the use cases that describe the behavior of the system – does not specify the organization of the software system – does specify the forces that shape the system’s architecture – static aspects are captured in Use Case diagrams – dynamic aspects are captured in Interaction (Sequence and Collaboration), Statechart and Activity diagrams
Architecture • Design View – classes, interfaces and collaborations that form the vocabulary of the problem and its solution – supports the functional requirements of the system – static aspects are captured in Class and Object diagrams – dynamic aspects are captured in Interaction, Statechart and Activity diagrams
Architecture • Process View – threads and processes that form the system’s concurrency and synchronization mechanisms – addresses performance, reliability, scalability and throughput of the system – static and dynamic aspects are captured as with the Design View with a focus on active classes that represent the processes and threads
Architecture • Implementation View – the components and files used to assemble the system – primarily addresses the configuration management of the system’s releases – static aspects are captured in Component diagrams – dynamic aspects are captured in Interaction, Statechart and Activity diagrams
Architecture • Deployment View – the nodes that form the system’s hardware topology – addresses the distribution, delivery and installation of the system – static aspects captured in Deployment diagrams – dynamic aspects captured in Interaction, Statechart and Activity diagrams
The UML and Software Process • The UML is a standard notation only • It does not specify process at all • UML is most effective when combined with an effective software process
Lifecycle Phases
Test & Delivery Analysis Implement Requirements Requirements
Inception
Design Design
Elaboration
Construction
Transition
UML and the Software Process The The Unified Unified Process Process
The The Software Software Development Development Plan Plan
Inception Inception Elaboration Elaboration Construction Construction Transition Transition
Software Software Development Development Team Team
Software Software Development Development Tools Tools
Software Development Life Cycle
Inception
Elaboration
Construction
Transition
Requirements Analysis Design Implementation Test Iter. 1
Iter. 2
---
---
---
---
---
Iter. n-1
Iter. n
Reprinted from The Unified Modeling Language Users Guide
Inception Phase
Inception Inception
Elaboration Elaboration
Construction Construction
Transition Transition
Inception Phase • Major Activities – Capture all user requirements
• Deliverables – – – –
Use Case database Use Case / Sequence / Activity / Collaboration diagrams Requirements document User interface prototypes
• Completion Criteria – Domain experts and requirements team have recorded all Use Cases – User sign-off on requirements
Inception: Use-Case Diagram
Inception: Development Use-Case Database
FIELD OSE Case Name Identifier Identifier of Underlying Userlevel Use Case Description Owner Date
USE CASE 1
USE CASE 2
USE CASE 3
…
Inception: Sequence Diagram
Elaboration Phase
Inception Inception
Elaboration Elaboration
Construction Construction
Transition Transition
Elaboration • Major Activities – Detailed System Design – Preparation for Construction
• Deliverables – Development Use Cases – Package Diagrams / Class Diagrams / Sequence Diagrams – Initial Test Matrix
• Completion Criteria – Design is complete - all Use Cases have been accounted for – Complete dynamic and static view of system has been designed
Package Diagram
Class Diagram
Sequence Diagram
Construction Phase
Inception Inception
Elaboration Elaboration
Construction Construction
Transition Transition
Construction • Major Activities – System coding – System integration – Alpha testing
• Deliverables – Completed initial release of system – User and internal system documentation – Beta release plan
• Completion Criteria – Stable release exists that meets all agreed upon requirements – Complete documentation is ready to release with initial system
Construction: Models guide Code
Java Source Code
Transition Phase
Inception Inception
Elaboration Elaboration
Construction Construction
Transition Transition
Transition • Major Activities – Refining system performance – Correcting bugs – Clarification of documentation
• Deliverables – Updated builds of system – Updated user and internal documentation
• Completion Criteria – Improved builds address specific identified issues – New release is ready for next iteration
Transition: Document As-Built
Code
Java Source Code
Part Two
© 2001 Embarcadero Technologies, Inc.
Sample Java Application
Network Monitor Program Login
Sample application to track a user’s portfolio of stock and provide real-time updated values.
User DB Create/Edit Portfolio
Yahoo Quote Server
User Get Quotes
Get News
CNN Financial News
Export Portfolio
Application Use Case
Login
Primary Scenario Use Case 1. Login to the server 2. Create or Edit a stock portfolio 3. Get updated quotes for all stocks in the portfolio 4. Get current news for stocks in the portfolio 5. Export portfolio for use in other applications
User DB Create/Edit Portfolio
Yahoo Quote Server
User Get Quotes
Get News
CNN Financial News
Export Portfolio
Hands-On Example Building a Stock Tracker with the Support of the UML
© 2001 Embarcadero Technologies, Inc.
UML References Recommended Books
© 2001 Embarcadero Technologies, Inc.
Recommended UML Guides •SAMS Teach Yourself UML in 24 Hours Schmuller, Joseph. 1999.. Indianapolis: SAMS: A Division of Macmillan Computer Publishing.
•Instant UML Miller, Pierre-Alain, 1997. Paris: Wrox Press Ltd.
•The Unified Modeling Language User Guide Booch, Grady, J. Rumbaugh, and I. Jacobson. 1999. Reading: Addison-Wesley.
Appendix UML Models Reviewed
© 2001 Embarcadero Technologies, Inc.
Activity Diagram
36
What is an Activity Diagram • Describes activities and flows of data or decisions between activities • Provides a very broad view of business processes • Can be used to break out the activities that occur within a use case • Commonly show many different activities that will be handled by lots of different objects • Good for showing parallel threads
When to use an Activity Diagram • When describing work flow across many use cases • When analyzing a use case, and before methods are assigned to objects • When dealing with multi-threaded applications 37
Activity Diagrams • Special case of State Diagram – where all/most states are action states – where all/most transitions triggered by completion of the action
• Good for workflow where parallel processing is prevalent
Interaction Diagrams
•Show interaction between object instances •Two types –Sequence Diagrams –Collaboration Diagrams
Sequence Diagram
40
What is a Sequence Diagram z
This diagram is a model describing how groups of objects collaborate in some behavior in a time sequence
z
The diagram captures the behavior of a single use case
z
It shows objects and the messages that are passed between these objects in the use case
When to use a Sequence Diagram z
A good design can have lots of small methods in different classes. Because of this it can be difficult to figure out the overall sequence of behavior. This diagram is simple and visually logical, so it is easy to see the sequence of the flow of control
z
A sequence diagram also clearly shows concurrent processes and activations 41
Sequence Diagrams •Interaction between objects arranged in a time sequence •The time is the life of the object •There are no associations described •Explicit sequence of messages •Best for real-time specifications
Collaboration Diagram
43
What is a Collaboration Diagram •
Cross between an object diagram and a sequence diagram
•
Describes a specific scenario
•
Numbered arrows show the movement of messages during the course of a scenario
When to use a Collaboration Diagram • When you prefer to show a spatial organization of objects and interaction rather than concentrating on the sequence of the interaction
44
Collaboration Diagrams •Shows relationships between the objects •Does not show time sequence •Uses sequence numbering to display path of interaction •Best used to understand the effects on a particular object and procedural design
Class Diagram
46
What is a Class Diagram • Diagram that shows classes, their relationships with other classes and, in some cases, relationships between objects • Can be a high level view of a system or a specific subsection of the overall model • Shows the static structure of a system
When to use a Class Diagram • Class diagrams exist for every system and are usually the central diagram of a system
47
Package Diagram
48
What is a Package Diagram • Diagram that is just a form of the class diagram • Shows how classes can be divided into modules and high-level relationships between packages • Can be a high level view of a system or a specific subsection of the overall model
When to use a Package Diagram • Used strictly for logical modularization • When the application is very large • Usually done in the design phase of a project
49
State Diagram
50
What is a State Diagram • Provides a very detailed picture of how a specific object changes states • A state refers to the value associated with a specific attribute of an object and to any actions or side effects that occur when the attribute’s value changes
When to use a State Diagram • Used when you are working on real-time process control applications or systems that involve concurrent processing • When you want to show the behavior of a class over several use cases
51
State Diagram • Describes all possible states of an object • Shows state changes based on events • Good at describing behavior of an object across several use cases • Most likely to refine user interface and controller objects
Implementation Diagrams • Shows implementation aspects and structure – Component Diagram – Deployment Diagram
Component Diagram
54
What is a Component Diagram z
Simple, high-level diagram
z
Refers to physical components in a design
z
Used to show how code is actually divided into modules
z
There is usually a one-to-one relationship between package diagrams and component diagrams
When to use a Component Diagram z
Package diagrams show the logical divisions and the component diagram shows that you actually implemented it as you proposed in the package diagram
55
Component Diagrams •Shows dependencies among software components –source –binary –executables
•Has only a Type form not an Instance form •Instance form would be a Deployment diagram
Deployment Diagram
57
What is a Deployment Diagram z
Developer can model the physical platforms and network connections to be used in their application
z
Nodes usually represent hardware platforms
When to use a Deployment Diagram z
Developers place component diagrams on top of deployment diagrams to indicate which modules of code will go on which hardware platform
58
Deployment Diagrams • Shows how components and objects are routed through a distributed system • Show the configuration of run-time elements