#112

Get More Refcardz! Visit refcardz.com

CONTENTS INCLUDE:
n n

n

n

n

About UML Structural Diagrams Behavioral Diagrams Interaction Diagrams Hot Tips and more...

Getting Started with
Hot Tip
Relationship
Dependency “...uses a…”

UML
 

By James Sugrue
ABOUT UML
The Unified Modeling Language is a set of rules and notations for the specification of a software system, managed and created by the Object Management Group. The notation provides a set of graphical elements to model the parts of the system. This Refcard outlines the key elements of UML to provide you with a useful desktop reference when designing software.

Interfaces Interface names and operations are usually represented in italics.
Description

A weak, usually transient, relationship that illustrates that a class uses another class at some point.

Hot Tip

UML Tools There are a number of UML tools available, both commercial and open source, to help you document your designs. Standalone tools, plug-ins and UML editors are available for most IDEs.

Figure 2: ClassA has dependency on ClassB Association “…has a...” Stronger than dependency, the solid line relationship indicates that the class retains a reference to another class over time.

Diagram Types

www.dzone.com

UML 2 is composed of 13 different types of diagrams as defined by the specification in the following taxonomy.

STRUCTURAL DIAGRAMS

Figure 3: ClassA associated with ClassB Aggregation “…owns a…” More specific than association, this indicates that a class is a container or collection of other classes. The contained classes do not have a life cycle dependency on the container, so when the container is destroyed, the contents are not. This is depicted using a hollow diamond.

Class Diagrams
Class diagrams describe the static structure of the classes in your system and illustrate attributes, operations and relationships between the classes. Modeling Classes The representation of a class has three compartments.

Figure 4: Company contains Employees

Getting Started with UML

Figure 1: Class representation

From top to bottom this includes: • Name which contains the class name as well as the stereotype, which provides information about this class. Examples of stereotypes include <<interface>>, <<abstract>> or <<controller>>. • Attributes lists the class attributes in the format name:type, with the possibility to provide initial values using the format name:type=value • Operations lists the methods for the class in the format method( parameters):return type. Operations and attributes can have their visibility annotated as follows: + public, # protected, - private, ~ package
DZone, Inc.
|

 

Get over 90 DZone Refcardz FREE from Refcardz.com!

www.dzone.com

such as explanations or code samples. with an alias given to the link. Figure 10: UML representation of a single component Assembly Connectors The assembly connector can be used when one component needs to use the services provided by another. The object element may also have extra information to model the state of the attributes at a particular time.   Figure 12: Required and provided interface notation Port Connectors Ports allow you to model the functionality that is exposed to the outside world. as well as an annotation for the relationship. | Composite Structure Diagrams   Composite structure diagrams show the internal structure of a class and the collaborations that are made possible.   Figure 11: AccountManagement depends on the CreditChecker services Using the ball and socket notation. as well as classifiers.   Hot Tip Notes Notes or comments are used across all UML diagrams. an object instance is modeled using a simple rectangle without compartments. using {} (e.g. this indicates a strong life cycle dependency between classes. {ordered}).. A component could be modeled by one or more classes. and with underlined text of the format InstanceName:Class DZone. so when the container is destroyed. connectors. This is depicted using a hollow triangle at the general side of the relationship. Inc. This is depicted using a filled diamond.   Component Diagrams Component diagrams are used to illustrate how components of a system are wired together at a higher level of abstraction than class diagrams. They used to hold useful information for the diagram. between ClassA and ClassB. Figure 9: A simple object diagram Figure 5: StatusBar is part of a Window Generalization “…is a…” Also known as inheritance. Typically. www. as in the case of myAccount in the above example. A component is modeled in a rectangle with the <<component>> classifier and an optional component icon: Figure 6: Ford is a more specific type of Car Association Classes Sometimes more complex relationships exist between classes. and can   be linked to entities in the diagram. grouping together required and provided interfaces for a particular piece of functionality. The following example shows a multiple association. ports.. this indicates that the subtype is a more specific type of the super type. where a third class contains the association information. Direction is expressed using arrows.   Figure 7: Account associates the Bank with a Person Annotating relationships For all the above relationships.com . so are the contents.2 Getting Started with UML Composition “…is part of. collaborations. As you would expect. required or provided interfaces are illustrated as follows   Figure 8: Annotating class relationships Relationships can also be annotated with constraints to illustrate rules. this diagram uses some elements from class diagrams. direction and multiplicity can be expressed. This is particularly useful when showing nested components. Figure 13: Nested component diagram showing use of ports Object Diagrams Object diagrams provide information about the relationships between instances of classes at a particular point in time. which may be bi-directional.dzone.” More specific than aggregation. The main entities in a composite structure diagram are parts.

As in component diagrams. Figure 15: A connector between two parts Collaborations Represents a set of roles that can be used together to achieve some particular functionality. They are shown as named rectangles at the boundary of the owning structure. Unlabeled dependencies are considered imports. Both are depicted using the standard dashed line dependency with the appropriate stereotype (import or merge). Inc. which is depicted using a simple rectangle. Artifact An artifact is any product of software development. allowing them to interact at runtime. Actors are drawn using a stick figure. DZone.   Figure 16: Collaboration between a number of entities Hot Tip Modeling Patterns Using Collaborations Sometimes a collaboration will be an implementation of a pattern. As well as standard dependencies.dzone. including source code. • Package Merge Used to indicate that the contents of both packages are combined in a similar way to the generalization relationship. The name and type information is added to the connector using a name:classname format. This indicates that the package can access elements within another package.   Package Diagrams   Package diagrams show the organization of packages and the elements inside provide a visualization of the namespaces that will be applied to classes. It is depicted using a document icon in the top right hand corner. A use case represents a unit of functionality that can interact with external actors or related to other use cases. a port can specify the required and provided services. hardware or other systems. which implies that the included use case behavior is inserted into the behavior of the base use case. • Package Import Used to indicate that the importing namespace adds the names of the members of the package to its own namespace. Association links between these entities represent communication between nodes and can include multiplicity.   Figure 18: Package merge example   BEHAVIORAL DIAGRAMS Use Case Diagrams Use case diagrams are a useful. Collaborations are modeled using a dashed ellipse. External entities must not be placed within the system boundary Use Case Description Either a hardware or software element shown as a 3D box shape. Connectors Connectors bind entities together. Nodes can have many stereotypes. They show how software entities are deployed onto physical hardware nodes and devices. | www. The diagram shows the interaction of users and other external entities with the system that is being developed. In such cases a collaboration is labeled with the   pattern and each part is linked with a description of its role in the problem. high level communication tool to represent the requirements of the system. Entity Node Description Actors represent external entities in the system and can be human. Use cases are represented with a ellipse with the use case name inside. Generalization relationships can be used to represent more specific types of actors. as in the example. Figure 17: Deployment diagram example Figure 14: Diagram class with a Square and Line as part of its structure Ports Represent externally visible parts of the structure. indicated by an appropriate icon on the top right hand corner. This is illustrated using simple rectangles within the owning class or component. binary files or documentation. Graphical Elements Entity Actor Deployment Diagrams Deployment diagrams model the runtime architecture of the system in a real world setting. there are two specific types of relationships used for package diagrams. An instance is made different to a node by providing an underlined “name:node type” notation. class diagrams. Relationships between parts may also be modeled. Package diagrams are commonly used to organize.3 Getting Started with UML Parts Represent one or more instances owned by the containing instance. Use cases are contained within a system boundary. Boundary Graphical Elements Notation Includes Description Illustrates that a base use case may include another. A solid line is typically drawn between parts. Multiplicity may also be annotated on the connector.com . and provide a high level overview of.

These diagrams are useful for documenting business processes. a fork node illustrates the start of concurrent threads. Action constraints are linked to an action in a note with text of the format <<stereotype>>{constraint} The start node is used to represent where the flow begins. illustrated using a rounded rectangle. Represented using a circle containing a black dot. Represents the end of the state machine execution. This is illustrated using a single back spot. Illustrated using a circle with a X. Illustrated using a filled circle. Control Flow Represents the flow of control from one action to the next as a solid line with an arrowhead. including major actions and decision points. Regions are illustrated using a dotted rounded rectangle. all use case relationships can include multiplicity annotations. Activity Diagrams Activity diagrams capture the flow of a program. State Machine Diagrams State machine diagrams are used to describe the state transitions of a single object’s lifetime in response to events.4 Getting Started with UML Extends Illustrates that a particular use case provides additional functionality to the base use case.dzone. It is illustrated using a rounded rectangle. If an object is passed between activities. in some alternative flows. This can also be used to merge flows. Entity State Description States model a moment in time for the behavior of a classifier. Swimlanes can be used in activity diagrams to illustrate activities performed by different actors. and have a brief description. This can be read to mean that it’s not required to complete the goal of the base use case. A decision node will have a condition documented that needs to be met before that path can be taken. An annotated diamond shape is used to represent decisions in the control flow. Generalization Constraints Hot Tip Multiplicity Like normal relationships. Typically this starts with one positive path.com . Start Node Activity Final Node Flow Final Node Represents the end of a single flow. A stereotype is applied to the region to identify whether it is iterative or parallel. In cases when it is possible to enter the state machine at a later stage than the initial state this can be used. The pre and post conditions that apply to this use case’s execution. Represents the end of all control flows within the activity. Graphical Elements Section Action Description Represents one step in the program flow. Inc. This could be a link to an external formal specification. Used when there is a common use case that provides basic functionality that can be used by a more specialized use case. It is also possible represent object flow by adding a square representing the object on either side of the control flow. Figure 19: A simple use case diagram Documenting Use Cases Behind each use case there should be some text describing it. or an internal listing of the requirements that this use case will fulfill. with a number of alternative flows referenced. a representation of the object can be added in between the activities.   Exit Point Represents alternative end points to the final state. State machine diagrams are modeled in a similar way to activity diagrams. | www. The flow of events that occur during the execution of the use case. of the state machine. Initial Post Represents the beginning of the execution of this state machine. Illustrated using an empty circle. Regions are used to group certain activities together. Entry Point Final State Figure 20: Activity diagram DZone. The following are typical sections in a use case definition: Section Name and Description Requirements Constraints Scenarios   Object Flow Decision Node Description Use cases are should have verb names. Region Partition Fork Node Represented using a horizontal or vertical bar. The same notation can be used for the joining of concurrent threads.

General Lifeline Represents an individual entity in the sequence diagram. Transitions illustrate movement between states. The unknown part is modeled as a black dot. A swimlane can contain any number of lifelines. Messages The core of sequence diagrams are the messages that are passed between the objects modeled. with the final three the being most specific. State Choice A decision is illustrated using a diamond. illustrated using an X Hot Tip Swimlanes Swimlanes can be used to break up a sequence diagram into logical layers. or from an object that is not modeled in the diagram. Sequence Diagrams Sequence diagrams describe how entities interact. which is usually a change in condition. sequence diagrams are the most used diagrams for modeling software systems. Forks and merges (see activity diagram) are used to split/ merge transitions. Managing Object Lifecycle Objects don’t need to all appear along the top of the sequence diagram. The element is modeled at the top of the column and the lifeline is continued with a dashed line. or model objects. A junction is illustrated using a filled circle. with a number of transitions leaving from the choice element. Behavior and business rules are typically managed by such objects. such as user interface. A lost message is one that gets sent to an unintended receiver. A state can have multiple substates executing concurrently. They can be thought of as beans. Lifeline Objects A sequence diagram is made up of a number of lifelines. If the message is a return message it appears as a dashed line rather than solid. Each entity gets its own column.com . Effects Triggers cause the transition. A found message is one that arrives from an unknown sender. States may also have self transitions. A message with a line arrowhead at the end. Entities are usually elements that are responsible for holding data or information. Guards. Entity Actor Found Self Message Hot Tip Description Actors represent external entities in the system. A guard is a condition that must evaluate to true before the transition can execute. Actors are drawn using a stick figure. The destination for this message is a black dot. and may skip past other lifelines on the way to the recipient. which is modeled using a dashed line to separate the parallel tracks. displayed as a rectangle. Control Controller elements manage the flow of information for a scenario. They can be human. They can be annotated with a Trigger[Guard]/Effect notation. Entity Synchronous Concurrent Region Hot Tip Transitions: Triggers. the element’s lifeline can begin at the end of that message. All messages are described in the order of execution. Terminate State Indicates that the flow of the state machine has ended. If the message is a return message it appears as a dashed line rather than solid. hardware or other systems. or back-end logic that deals with external systems. A self message is usually a recursive call. where the state resumes from where it was last time. useful for iterative behavior. A thin rectangle along the lifeline illustrates the execution lifetime for the object’s messages. When a message is sent to create an object. State Boundary Nested States States can themselves contain internal state machine diagrams. Messages can be sent in both directions. Inc. Effect is an action that will be invoked on that object. This is drawn using a circle with a H inside. Description A message with a solid arrowhead at the end. stereotype or could be an instance (using instance:class) Boundary elements are usually at the edge of the system. Asynchronous INTERACTION DIAGRAMS Lost Interaction diagrams are a subset of behavioral diagrams that deal with the flow of control across the modeled system. simply use an X at the end of the dashed line. A state can also be annotated with any number of trigger/effect pairs. which is useful when the state has a number of transitions. including what messages are used for the interactions. or to an object that is not modeled in the diagram. | www. Messages will usually be of the form messagename(parameter). Along with class and use case.5 Getting Started with UML Transition Represented as a line with an arrowhead. Entity State junction Junctions are used to merge a number of transitions from different states.   To terminate the lifeline. It can have a name. History State History states can be used to model state memory.dzone. or a call to another method belonging to the same object. The following are the options for lifeline objects. Fragments Fragments are sections of logic that are executed given a DZone.

0300 $7. They first describe what patterns are and how they can help you design object-oriented software. use target enviro ated s (i.co Re fca relying on a cloud computing platform’s technology. ce pre-in blem with ymen (i. Ralph Johnson.g. ed to CSS pag Brow individual operating system s Whi y HTM has expand because . e HTM dards HTM r. ation Having the capability to support one time events. photocopying. Inc. DZone offers something for everyone. without prior written permission of the publisher. Entity alt opt break par seg strict neg critical ignore consider assert loop Description Models if then else blocks Models switch statements For alternative sequence of events Concurrent blocks Set of messages to be processed in any order before continuing Set of messages to be processed in strict order before continuing Invalid set of messages Critical section Messages of no interest The opposite to ignore.. with an softw riente loping ine task-o e Deve Mainl es you emphasis oncodelines providers.nt team Perfo opme ed resu tion d Builds sitory Build to devel Repo Stage adverse unintend Integra bandwidth. The web pag s alte Nested es like was onc use HTML ble. except that they   Figure 23: Interaction Overview Diagram   ABOUT THE AUTHORS RECOMMENDED BOOK Designers Erich Gamma. These fragments can be of many different types.. Earl to be. and John M. Tags l.6 Getting Started with UML particular condition.com Sponsorship Opportunities sales@dzone. but can toInteg late fi Centr Binar most phone services: plans with alloted resources. brough Platform Management and more. architects and decision makers. cheatsheets. and loves every minute of it. 9 781934 238752 rev. ality has allocated exclusively to expecte irably. WAR es al Depe ge t a few explain text) and to “fi x” the are solu duc Web application deployment untillibrari yearsenvironmen similar t ago was packa Minim be nden ns to pro all targe rity all depe used CI can ticular con le that alize y i-patter they tend es. temp s. Inc. HTM essentia came is proc lly plai supp L files assigned essor an operating system in the same wayain on all hosting as elements ort. cloud Useful Open computing platforms also facilitate the gradual growth curves Page Source Stru Tools faced by web applications. control and entity types. bandwidth. Each pattern discussed is from a real system and is based on a real-world example. The focus of this diagram is object relationships between boundary. The late a lack of stan up with clev y competi n text should ng stan st web in dar er wor not be dar kar standar cr HTM L BAS Network Security Hadoop UML Subversion DZone. Manage s and mor Build tice d Prac Buil ■ ■ ■ ■ to isolat space n e Work riptio itory a Desc These companies have Privat deployed webmanage applications are in long trol repos to n-con lop softw ing and Deve a versio that adapt and scale to large user bases. Duvall A ul nuou ontiPatterns and By Pa C ABOUT CLOUD COMPUTING dz. this the pat builds h as Build Send soon ration Integra al use of ion with ts suc ors as Integ entat and test concep tinuous vention docum oper Con “build include the con s to the rate devel Gene CI to While efer ion of the not s on expand Vis it Ge t Mo re www. Messages between the participants are numbered to provide sequencing information. s cloud e Work knowledgeable in a mainline Privat that utilize lop on Deve code lines a system sitory of work rdz . HTML ent instances. rm a The various resources consumed by webperiodically. memory. in any form or by means electronic. communication diagrams are similar to sequence diagrams. web service APIs.) All are ML shar limit than rs add elopers As a user of Amazon’s EC2 cloud computing platform. applications (e. d. While working on desktop technologies such as Eclipse RCP and Swing.com Ge t Mo re E: INC LUD gration NTS ous Inte Change CO NTE Continu at Every ns About Software i-patter Build and Ant Patterns Control ment Version e. Redu Autom ory. Fort foundation commo nd for unately they (e. especially with the entrance of service providers like Amazon.678. 1. but L or XHT arent. Then they cover how patterns fit into the development process and how they can be leveraged to efficiently solve design problems.e. Colla #6 Cloud 4Computing By Daniel Rubio also minimizes the need to make design changes to support CON TEN TS one time events. so <a>< tly are) nest become virtualization HTM a> is s has fine. or proces . te.com/books/design-patterns-elements #82 Get More Refcardz! Visit refcardz. etc.e. “DZone is a developer’s dream. load balancers and clusters) are all but abstracted away by ■ Vis it #84 on: gratiterns s Inte nti-PatM. Will not be shown if the assertion is invalid Loop fragment are defined in free form instead of lifelines. b></ ed insid bec heavily based on very little L more Amazon’s cloud computing ose the curr you cho platform isome a></ importa e b> is more ent stan to writ not lega each othe app nt. with an ts etimes . blogs. Richard Helm. rdz ! m However.n elem CPU) to be mov memory. Server-s the ima alt attribute ribes whe output likew ge is describe re the ima mechan from CLOUD COMPUTING PLATFORMS AND ide languag t-side ise unavaila ge file ism. you are result anybody es cert ed man ed layout n. CPU) areIntegration on from CI server basis tallied a per-unit e e Build rm an tinuous ack ard produc Privat Con feedb Refc on (starting from zero) by Perfomajor cloud computing platforms. ated occur based tion autom as they the term” cycle. This provides a useful way to give high level overviews or indexes of the key diagrams in your system..dzone. e chang Elem al Elem ents ents and Large scale growth scenarios involving specialized equipment more. Com bora ■ ■ ■ Aldon Chan ge. mechanical.dzone. Tags standard a very loos g Ajax HTML ML as is disp can tech ely-defi thei ization.com CONTENTS INCLUDE: ■ ■ ■ About Cloud Computing Usage Scenarios Underlying Concepts Cost by. is used ML are the prog etc. so by Commit better understand these softwar chang Level can e code ding Task what it is a cloud computingaplatform can offer your web trol ut line Policy nize sourc es as of buil NT Orga Code e witho it chang cess ion con e name sourc T CO applications. Figure 22: Simple communication diagram Interaction Overview Diagrams   An interaction overview diagram is a form of activity diagram where each node is a link to another type of interaction diagram. b></ Amazon EC2: ther stanstandard software and uage with whe Industry dard . in the end bad pra enting Mana targe Creat cy nt es rties are rily nden implem approac ed with the cial. d deploEAR) each lar pro pattern tterns Pay only what you consume in tagge or cies reposit particu tions that e ed via t nden anti-pa For each (e. several cloud computing platforms support data HTM tier technologies that L and the precedent set by Relational exceed XHT HTML Database Systems (RDBMS): Map Reduce. ive data pt. James Sugrue has been editor at both Javalobby and Eclipse Zone for over two years. making them rn les to ize merg Patte it all fi to minim space Comm many aspects related tomultiple computing. or otherwise. NC 27513 888. No part of this publication may be reproduced. Vlissides put together this excellent guide to offer simple solutions to common design problems. By day. feature articles.g.0399 919. James is a software architect at Pilz Ireland. Figure 21: Sequence Diagram Fragment Communication Diagrams Also known as a collaboration diagram. This allows resources function job adm been arou ler than ing.com ISBN-13: 978-1-934238-75-2 ISBN-10: 1-934238-75-9 50795 DZone communities deliver over 6 million pages each month to more than 3..g. support as the grap foundation The src of all hical and Java ten attribute and the also recein JavaScri user interfac web develop desc as the e in clien ment. 140 Preston Executive Dr. tutorials. (e. com ref car Web applications have always been deployed on servers connected to what is now deemed the ‘cloud’. rnate can be emergin es and use UNDERLYING CONCEPTS and XHT PHP text that e tags found. BUY NOW books. cture Key ■ ■ HTML Automated growth & scalable technologies vs XHT ■ ■ HTML Basics LUD E: Valid ML Structur ICS In addition. INC ■ Getting Started with Browse our collection of over 100 Free Cheat Sheets Upcoming Refcardz Core HTML By An dy Ha rris ref ca ■ ■ Cloud Computing active Repo are within units This Refcard will introduce to you to clouddcomputing. the demands and technology used on such servers has changed substantially in recent years. ® Data Tier Technologies t to you ply... that some used Every job time. James also likes meddling with up and coming technologies such as Eclipse e4. all tern.678. including news.g.3 million software developers. His current obsession is developing for the iPhone and iPad. All rights reserved. Reg the will help L VS <a>< and XHT simplify all ardless XHTM b></ ML.. Google and es Microsoft.. developing killer desktop software using Java and Eclipse all the way. Some platforms rams writ large scale RDBMS deployments. but chang prope Depe into differe itting er necessa pared to efi te builds e comm late Verifi associat to be ben befor are not Cloud computing asRun remo it’s known etoday has changed this. you ML physical r othe you prov to L Virtualization allows aare actu piece of hardware idebe understand of HTML much a solid of the ing has ally simp r web cod utilized by multiple operating systems. that will industry standard software and virtualization technology. They Privat contin lts whe appear effects.” says PC Magazine. and subm it the pro ject’s vers are from with uniqu ABOU softw (CI) is um the build evel Comm build a pro minim Label Task-L ies to gration ed to activit blem the bare ion ate all cies to t ous Inte committ USAGE SCENARIOS to a pro Autom configurat nden ymen Build depe al tion deplo t Continu ry change ive manu Label d tool nmen the same stalle . ineffect ) Build eve t. Suite 100 Cary. a solu .001 10/08/09 Copyright © 2010 DZone. source code and more. Ant nt nmen ctic in a par hes som geme t enviro e a single based on incurred cost whether such resources were consumedto thenot.com S INUOU INTEG RATION Re fca rd z! e. stored in a retrieval system. layed cannot be (and freq need ned lang r visual eng nologies if but as for overlap uen it has ine. . Temp n com Build ually.95 Refcardz Feedback Welcome refcardz@dzone. ser common e (HTML ed far le it has don or XHT web dev manufacture L had very more e its extensio . or transmitted. having convinced himself that it’s a turning point for the software industry.

Sign up to vote on this title
UsefulNot useful