Home

UML 2.0 In A Nutshell

image

Contents

1. Occurence B checkForSpam message s nE i e ee eee T While not officially part of the specification it was a common practice in UML 1 x to show messages starting from an execution occurrence on a lifeline to indicate that an object will send messages to other objects as part of processing a received message With UML 2 0 it may be more appropriate to show a set of messages as an interaction fragment Using interaction fragments an appropriate interaction operator and a reasonable name you have much greater flexibility in expressing exactly how a piece of the system executes and how it fits into the bigger picture See Combined Fragments for more information on interaction fragments and the various ways you can organize messages to increase your diagram s readability This page was created by the unregistered version of CHM To POF Converter by Theta Sottware PREY NEXT 10 5 State Invariants UML allows you to place labels along a lifeline to convey conditions that must be true for the remainder of the interaction to be valid These conditions are called state invariants State invariants are typically boolean expressions though they may be full UML states see Chapter 8 For example you may have a series of messages that initialize a participant After the messages have completed the participant must be in a well known state for the remainder of the interaction to complete successfully You can enforce that by pla
2. J a Oe ee eee ee al opt curl ser access Admin i enableAdmin Credentials ine i credentials 10 8 2 4 Parallel Parallel indicates that the associated interaction fragments may be merged and executed in parallel The interaction operator is par UML specifies that the actual interleaving of the event occurrences of the operands must be done in such a way that the ordering in the original operand is maintained For example if the first operand consists of Stepl Step2 Step3 This page was created by the unregistered version of CHMI To POF Converter by Theta Sottware and the second consists of otepA StepB JLepG they can be merged into Stepl otepA oCepB Step2 oh 1618 Step3 but not into Stepl StepB Step2 otepA Step3 oLepU because stepA and steps would be executed out of order Figure 10 21 shows an example of the parallel operator to model a desktop login sequence Figure 10 21 Example parallel operator This page was created by the unregistered version of CHM To POF Converter by Theta Sottware d Desktop Startup Sequence par showLoginSplashScreent a laadGolorPrets sOriicomegp 8 O Wa mm ess mmm hideLoginSplashScream la ewibe neces abe m ApplicationService cals will be executed in parallel during login StartF inewallService startSyatemLoginAppat startSystern TrayApps starlUserLoginApps ryryry If you need to convey that
3. Setup ioe Space A af E You show an exception handler as a regular node with a small square on its boundary Draw a lightning bolt style edge from the protected node to the small square Finally label the edge with the type of the exception caught by this handler Figure 9 30 shows an example exception handler If an exception occurs while an action is executing the execution is abandoned and there is no output from the action If the action has an exception handler the handler is executed with the exception information When the exception handler executes its output is available to the next action after the protected node as though the protected node had finished execution If the action doesn t have an exception handler the exception propagates to outer nodes until it encounters an exception handler As the exception leaves a node an action structured activity node or activity all processing in the node is terminated It is unspecified what happens if the exception makes it to the top level of a system without being caught UML 2 0 profiles can define specific behavior to handle this Figure 9 30 Activity diagram with an exception handler This page was created by the unregistered version of CHM To POF Converter by Theta Sottware O SS ae Hs Resize Images n n i _ Save Image with _ ge Load Image Resize Image g k 9 T New Filename J oy Oe ae i My al i SC Create Dumm
4. PREY NEXT 9 2 4 Methods Amethod is an implementation of an operation Each class typically provides an implementation for its operations or inherits them from its superclass see Generalization If a class doesn t provide an implementation for an operation and one isn t provided by its superclass the operation is considered abstract See Abstract Classes for more information Because methods are implementations of operations there is no notation for a method Simply show an operation on a class Fa PREY NEXT W This page was created by the unregistered version of CHM To POF Converter by Theta Sottware PREV NEXT 1 2 5 Abstract Classes Anabstract class is typically a class that provides an operation signature but no implementation however you can have an abstract class that has no operations at all An abstract class is useful for identifying common functionality across several types of objects For example you can have an abstract class named Movable A Movable object has a current position and the ability to move somewhere else using an operation named move There can be several specializations of this abstract classa Car a Grasshopper and a Person each of which provides a different implementation of move Because the base class Movable doesn t have an implementation for move the class is said to be abstract You show a class is abstract by writing its name in italics Show each abstract operation i
5. Returns the owning object casted to Type If the object isn t a descendant of t the operati is undefined Here are some examples of the built in properties test that the instructor is an instance of Teacher context Course inv self instructor oclisTypeOf Teacher cast a Date class to a java sql Date to verify the minutes it s very unlikely the foundationDate would be a jJava sql Date so this invariant would be undefined but this is an example OF using oclAsType context School inv self foundationDate oclAsType java sql Date getMinutes 0 This page was created by the unregistered version of CHM To POF Converter by Theta Sottware B 3 5 Collections OCL defines several types of collections that represent several instances of a classifier The basi type iS Collection which is the base class for the other OCL collection classes Quite a few operations are defined for collection see the OCL specification for the complete list All collections support a way to select or reject elements using the operations select and reject respectively To invoke an operation on a collection you use an arrow gt rather the dot a dot accesses a property The result of select or reject is another collection containir the appropriate elements Remember that since OCL can t modify a system in any way the orig collection is unchanged The notation for a select is collection gt select boolean expression
6. So to select students with GPAs higher than 3 0 you can use the expression context Course getHonorsStudents Student body self students gt select GPA gt 3 0 Or to eliminate honor students that haven t paid their tuition context Course getHonorsStudents Student body self students gt select GPA gt 3 0 gt reject tuitionPaid false In the previous examples the context for the select and reject statements was implied You c explicitly name the element you want to use in the boolean expression by prefixing the expressi with a label and a pipe symbol So a rewrite of the GPA example using a label to identify ea student looks like this context Course getHonorsStudents Student body self students gt select curStudent curStudent GPA gt 3 0 Finally you can specify the type of the element you want to evaluate You indicate the type by placing a colon and the classifier type after the label Each element of the collection you are evaluating must be of the specified type or else the expression is undefined You can rewrite th GPA example to be even more specific and require that it evaluate only Students context Course getHonorsStudents Student body self students gt select curStudent Student curStudent GPA gt 3 0 Often you will need to express a constraint across an entire collection of objects so OCL provide theforAll operation that returns true if a given Boolean expre
7. This page was created by the unregistered version of CHM To POF Converter by Theta Sottware PREY NEXT 1 10 8 Combined Fragments Often there are times when a particular sequence of event occurrences has special constraints or properties For example you may have a critical region within your interaction where a set of method calls must execute atomically or a loop that iterates over a collection UML calls these smaller pieces interaction fragments Interaction fragments by themselves aren t terribly interesting however UML allows you to place them in a container called a combined fragment it s called a combined fragment even if you have only one interaction fragment in there Once they are placed in such a container UML allows you to specify additional detail for each fragment or how several fragments relate to each other Each combined fragment is made up of an interaction operator and one or more interaction fragments which are the interaction operands An interaction operator specifies how the interaction operands should be interpreted The various interaction operators are described in detail later in this chapter As you do with full interactions you show a combined fragment as a rectangle with the interaction operator in a pentagon in the upper left and the interaction operands inside the rectangle Figure 10 17 shows a combined fragment representing a critical section of code The code must be executed atomically becaus
8. i i amp Ou Candy amour entered do display Maka Selector salari onndk dapanas drink Espen rely ull aur Go bees eham Pund din pernai Refunding change C change ralumad A Pull aturi gain kivel rebu fuels i a n o A state machine is often associated with a classifier in the larger UML modelfor example a class or subsystem However UML doesn t define a specific notation to show this relationship One possible notation is to use a note labeled with the name of the state machine and linked to the classifier Figure 8 2 shows an example that uses a note to link a state machine to a classifier Figure 8 2 Example of linking a state machine to a classifier This page was created by the unregistered version of CHM To POF Converter by Theta Sottware k is ba a A See UserAuthenticationSM for behavioral details lt lt subsystem gt gt UserAuthentication You can model the behavior of the classifier using states pseudostates activities and transitions If a state machine is used to model the behavior of an operation see Operations inChapter 2 the state machine must have parameters that match the operation s parameters These can be used in any transition or state as needed Transitions between states occur when events are dispatched see Dispatch As the state machine executes activities are run based upon the transition entry into a state and so on see Activities Each
9. interface Sortable comesBefore object Sortable boolean fy Alphabetizer __ _ j Toi cm e O e E O E E o E e o e o eee comesBefore since it realizes the interface Also note that Alphabetizer has no direct dependency on Person it can simply l 4 refer to it as a Sortable I Providing an implementation of an operation is straightforward You must provide an implementation on a realizing classifier with the same signature as the operation on the interface Typically there are semantic constraints associated with an operation that must be honored by any implementation Realizing a property is more subtle A property on an interface states that any class that realizes the interface must store the data specified by the propertyin some way A property on an interface doesn t necessarily mean there will be an associated property on a realizing classifier However the classifier must be able to store the data represented by the property and provide a means to manipulate it This page was created by the unregistered version of CHM To POF Converter by Theta Sottware PREY NEXT 1 2 8 Templates Just as interfaces allow you to provide specifications for objects your class will interact with UML allows you to provide abstractions for the type of class your class may interact with For example you can write a List class that can hold any type of obje
10. 3 shows destroying a helper class after it has finished its work Figure 10 3 The destruction of a participant sd Storing an item in a HashMap auf hoheacala tempUtils Object i put key value create I hashString key asd Cah j2s5 J destroy SC a To help make your sequence diagram accurately capture the behavior you are trying to model you can introduce local variables Local variables can hold return values loop information or just data you need for later processing You show the values of local attributes relevant to the interaction using the same attribute syntax used inside of classifiers see Chapter 2 Place their name and values in the upper left of the diagram or in a note attached to the diagram Figure 10 4 shows a more detailed version of the HashMap interaction using local variables Figure 10 4 A more complete HashMap interaction using local variables This page was created by the unregistered version of CHM To POF Converter by Theta Sottware ed Storing an Hem in a HashMap The kial varias are daciated using i a hashedkay String l Ue nama albibuke syerbace k i buzke Clissea They can be nelerenced l anpahana in your daram i mL puh key wake i i eon bts 1 eg hastndkiny hashStengl hey l E neearcys at a bucket Amir eaka hk ay Fo X pul hashediey alie In addition to loc
11. Earlier in Figures 12 2 and 12 3 we separated structure from inheritance Each diagram contains fewer elements than the all encompassing diagram shown in Figure 12 1 or even the more modest one shown in Figure 12 2 so they are easier to understand Figure 12 7 shows package dependencies The diagram records both the import graph and code generation directives The superimposition of these two roles results in a diagram with pairs of opposing dependencies between elements Don t worry if you don t quite understand its meaning we ll clean it up in a moment Figure 12 7 fails as a diagram for several reasons Most strikingly you don t know where to start the diagram has no center of gravity This leads to a lack of flow or direction do you read the diagram left to right top to bottom or inside out The apparently cyclic dependencies confound any sense of direction Although opaque to the initiated the problem withFigure 12 7 stems from trying to use one diagram for two related but different ends controlling imports and directing code generation Figure 12 7 Package diagram controlling imports and code generation directives impl from statement FT ecimpat gt gt s pa ge mpl r sept P CARRANNA a a from model E i L__ E g a a fo Or gt a tao model Os ere ek a from data DAlineplementation a Tete ea Wi A amp R iI gt statemachinme Fi k w ae from businessa ri hs
12. The lineMembers attribute will be stored sequentially which in this case probably lineMembers Person 0 ordered means alphabetically LineOrganizer 2 2 4 2 Uniqueness In addition to being ordered an attribute with multiplicity greater than 1 may be required to beunique If an attribute is required to be unique each element of this attribute must be unique By default attributes with multiplicity greater than 1 are unique meaning there can be no duplicates in the elements this attribute holds For example if a class held a list of voters and each person was allowed to vote only once each element in the list would be unique To make an attribute unique place the keyword unique after the attribute in braces as shown in Figure 2 9 To allow an attribute to hold duplicates of an object simply use the propertynotunique Figure 2 9 Unique multiplicity This page was created by the unregistered version of CHM To POF Converter by Theta Sottware msl E l E l E ll U E E E O E l VoterRegistrar As mentioned in the text attributes with I ae a multiplicity greater than 1 are unique by voters Person 0 unique default Strictly speaking the unique canstraint here is unnecessary 2 2 4 3 Collection types The UML specification specifies a set of mappings from the various ordered and uniqueness properties to UML collection types Table 2 1 shows the mappings from attribute p
13. The second representation of an interface is the ball and socket notation This representation shows less detail for the interface but is more convenient for showing relationships to classes The interface is simply shown as a ball with the name of the interface written below it Classes dependent on this interface are shown attached to a socket matching the interface Figure 2 32 shows the Sortable interface using the ball and socket notation Figure 2 32 Examples of providing and requiring interfaces This page was created by the unregistered version of CHM To POF Converter by Theta Sottware r Person Sortable Sortable Alphabetizer i pm coe The Person class offers realizes the Sortable interface and the Alphabetizer class requires Sortable elements Because an interface specifies the contract only for a set of features you can t instantiate an interface directly Instead a class is said to realize an interface if it provides an implementation for the operations and properties You show realization using a dashed line starting at the realizing classifier and leading to the interface with a closed arrowhead at the end Classes that are dependent on the interface are shown using a dashed line with an open arrow dependency Figure 2 33 shows a class that realizes the Sortable interface and a class that is dependent on it Figure 2 33 Person realizes the Sortable interface and Alphabetizer depends on it
14. This page was created by the unregistered version of CHM To POF Converter by Theta Sottware NEXT UML 2 0 in a Nutshell ByDan Pilone Neil Pitman Publisher O Reilly Pub Date June 2005 ISBN 0 596 00795 7 Pages 234 Table of Contents Index Overview System developers have used modeling languages for decades to specify visualize construct and document systems The Unified Modeling Language UML is one of those languages UML makes it possible for team members to collaborate by providing a common language that applies to a multitude of different systems Essentially it enables you to communicate solutions in a consistent tool supported language Today UML has become the standard method for modeling software systems which means you re probably confronting this rich and expressive language more than ever before And even though you may not write UML diagrams yourself you ll still need to interpret diagrams written by others UML 2 0 in a Nutshell from O Reilly feels your pain It s been crafted for professionals like you who must read create and understand system artifacts expressed using UML Furthermore it s been fully revised to cover version 2 0 of the language This comprehensive new edition not only provides a quick reference to all UML 2 0 diagram types it also explains key concepts in a way that appeals to readers already familiar with UML or object oriented programming concepts Topics include e The role and
15. artifact collaboration collaboration occurrences as collections and composite structures and connectors and defined 2nd interactions and lifelines and multiple operations and relative times This page was created by the unregistered version of CHMI To POF Converter by Theta Sottware representation XML documents as instantiation integer datatype interaction diagrams alternate notations combined fragments continuations decomposition deployment view and event occurrences example execution occurrences implementation view and interaction occurrences 2nd interactions 2nd messages participants process view and sequence timing state invariants traces use case view and use cases and interaction fragments communication diagrams and defined event occurrences and gates and guard conditions and 2nd messages and 2nd 3rd 4th options and parallel execution interaction occurrences 2nd interaction operands breaks Critical defined parallel execution weak sequencing interaction operators defined guard conditions messages and interaction overview diagrams 2nd 3rd interaction points 2nd interactions alternate notations copying overview 2nd participants sequence diagrams and interfaces as classifiers black box view collaborations and connection points and dependencies This page was created by the unregistered version of CHMI To POF Converter by Theta Sottware port
16. C ota Recount Sex 5 ah z ft Add Joint N lt lt ceaxtend gt gt eens Holder f pe This page was created by the unregistered version of CAMA To POF Converter by Theta Sottware When the system encounters an extension point in a use case any conditions associated with extension use cases are evaluated If a condition is met the corresponding extension functionality is executed Once all appropriate extension use cases have been executed the base use case continues with the next step in the original flow A PREY NEXT W This page was created by the unregistered version of CHM To POF Converter by Theta Sottware PREY NEXT 1 7 4 Use Case Scope As mentioned previously a use case is a distinct piece of functionality meaning it is of sufficient granularity that the user has accomplished his desired goal Proper scoping of use cases is an art but UML sets several requirements to make the job a little easier e A use case must be initiated by an actor e When a use case is considered complete there are no further inputs or outputs the desired functionality has been performed or an error has occurred e After a use case has completed the system is in a state where the use case can be started again or the system is in an error state One popular rule of thumb is to ask yourself if the user can go to lunch after completing the use case meaning that a reasonably sized goal has been achieved by the initiator For exa
17. DBTableName BILL CURRENCY isCachedBetweentTransitions True TransactionAttribute Required EJBEntityBean BillCurrency EJBPimaryKey VersionLock False SequenceName EJB DBColurnnName BILL CURRENCY ID AutoGenerated True EJBPrimaryKey ido EJBCmpField effectiveFrom EJBCmpFields VersionLock False DBColumnName EFFECTIVE FROM Figure 11 8 The partial specification UML profile showing model elements applying it UML Claas aA Lees E i ee lt i MyBilling App 1 Ingeaton of the j same alemani typa Sees Spore a EEA aes sEJBEntityGeans i EAE 7 L A BiliCurrency MyE JE Profile processes Fi 2 Claas using ne lt EJ6Entity Beans ERRA oO ee InFlendOnly Fatso DataSource EJBEntitygean apply isAieadinhy Boolean DB TatieName BILL CURRENCY iptlaeciied Beans rare Tru DatoSouros String D6 TabeNane String heCachedEebwwenTraersitions Boolean TrarsachonAtiniiuge Sting Us Required p Jj Uses EJBEntityBean q taped Valles SE Aw M __ e Profile Modal The UML from the profile and the model is shown in Figure 11 8 This illustrates the relationships between the declarations of the profile and a conforming model The stereotypes in the profile extend the concept of an element In this case the stereotype EUJBEntityBean extends ordinary classes as shown 1 by the implication of the same element type metaclass class In t
18. Dependency between classes means that one class uses or has knowledge of another class It is typically a transient relationship meaning a dependent class briefly interacts with the target class but typically doesn t retain a relationship with it for any real length of time Dependencies are typically read as uses a For example if you have a class named window that sends out a class named windowClosingEvent when it is about to be closed you would say Window uses a windowClosingEvent You show a dependency between classes using a dashed line with an arrow pointing from the dependent class to the class that is used Figure 2 21 shows a dependency between a class namedwindow and a class named windowClosingEvent Figure 2 21 Window s dependency on WindowClosingEvent Window WindowClosing Event You can likely assume from Figure 2 21 that Window doesn t retain a relationship with a WindowClosingEvent for any real length of time It simply uses them when needed and then forgets about them 2 6 2 Association Associations are stronger than dependencies and typically indicate that one class retains a This page was created by the unregistered version of CHM To POF Converter by Theta Sottware relationship to another class over an extended period of time The lifelines of two objects linked by associations are probably not tied together meaning one can be destroyed without necessarily destroying the other Associatio
19. Sorter SortedList _____ si fe wists ypa cee ENOS elements ElementType elementSorter SorterType Specifying restrictions on a type that may be used is functionally similar to specifying an interface for a templated member except that the user may be able to further restrict an instance of your class by specifying a subclass of your type When a user creates an instance of a List she needs to specify the actual type to use in place of ElementType This is called binding a type to a template You show binding with the keyword bind followed by a type specification using the following syntax lt TemplatedType gt RealType gt You can use the binding syntax whenever you refer to a templated class to indicate you want to use a bound version of that class This is called explicit binding For example Figure 2 36 shows a subclass of List called EmployeeList that binds the ElementType of List to a class namedEmployee Figure 2 36 Explicit template binding ElementT e List re elements ElementType T t i 1 Land bind lt ElementType gt Employee gt EmployeeList Thebind keyword also indicates what types should be used with an instance of a template This is called implicit binding and is shown in Figure 2 37 Figure 2 37 Implicit template binding This page was created by the unregistered version of CHM To POF Converter by Theta Sottware A PREY NEXT W This page was created
20. UML is a set of specifications from the OMG UML 2 0 is distributed as four specifications the Diagram Interchange Specification the UML Infrastructure the UML Superstructure and the Object Constraint Language OCL All of these specifications are available from the OMG web site http www omg org The Diagram Interchange Specification was written to provide a way to share UML models between different modeling tools Previous versions of UML defined an XML schema for capturing what elements were used in a UML diagram but did not capture any information about how a diagram was laid out To address this the Diagram Interchange Specification was developed along with a mapping from a new XML schema to a Scalable Vector Graphics SVG representation Typically the Diagram Interchange Specification is used only by tool vendors though the OMG makes an effort to include whiteboard tools The UML Infrastructure defines the fundamental low level core bottom most concepts in UML the infrastructure is a metamodel that is used to produce the rest of UML The infrastructure isn t typically used by an end user but it provides the foundation for the UML Superstructure The UML Superstructure is the formal definition of the elements of UML and it weighs in at over 600 pages This is the authority on all that is UML at least as far as the OMG is concerned The superstructure documentation is typically used by tool vendors and those writing books on U
21. Yearly Performance Review Review Employee ta a EF Adjust Salary can be invoked with an Employee object and a New Hire Document or an Employee object and a Yearly Performance Review ea Figure 9 11 Equivalent activity diagrams one with a connector and one without Perform Automobile Checkup Record Odometer Reading Check Oil Level Ther name of a connector iiy l has no notational meaning Check Air Pressure the names are only to link l the first half with the second i 4 hall OEE ie i es ee ee ee ee l x j Perform Automobile Checkup F Record Odometer Reading Check Oil Level Me a x gt Check Air Pressure 5 This page was created by the unregistered version of CHM To POF Converter by Theta Sottware PREY NEXT 1 9 2 Tokens Conceptually UML models information moving along an edge as a token A token may represent real data an object or the focus of control An action typically has a set of required inputs and doesn t begin executing until the inputs are met Likewise when an action completes it typically generates outputs that may trigger other actions to start The inputs and outputs of an action are represented as tokens Each edge may have a weight associated with it that indicates how many tokens must be available before the tokens are presented to the target action You show a weight by placing the keyword weight in curly brackets equa
22. You can use the keywords parallel iterative Or stream to indicate if the executions of the expansion region can occur concurrently parallel sequentially iterative or continuously stream Place the keyword in the upper left of the expansion region Figure 9 32 shows a video encoder that streams the frames through the various stages of encoding as This page was created by the unregistered version of CHMI To POF Converter by Theta Sottware soon as they are available Figure 9 32 Activity dialog with a streaming region Encode Video Si Gaal m a Attach Aria Capiure Frame p Extract Audio Enoode Video Frame Sani Save Encoded Video The activity region in this diagram is labeled with the keyword stream meaning there is only one instance of the activity magnon and i processes inpul dala as i s available As Soon as data moves from the first action it Can begi processing ihe nest available data 9 4 4 Looping UML 2 0 defines a construct to model looping in activity diagrams A Joop node has three Subregions setup body and test The test subregion may be evaluated before or after the body subregion The setup subregion executes only once when first entering the loop the test and body sections execute each time through the loop until the test subregion evaluates tofalse The specification gives no suggested notation for loop nodes however you can improvise one using activity regions Concept
23. creata tille Siring i acrealas ee ere re eee a windowTitle tithe Mote that arguments to the af width 100 Application constructor are y height used to initialize the text Cancel i MainWindow ttle This page was created by the unregistered version of CHMI To POF Converter by Theta Sottware a PREY NEKT W This page was created by the unregistered version of CHM To POF Converter by Theta Sottware PREY NEXT 1 4 2 Collaborations One of the primary purposes for composite structures is to document how a particular piece of functionality is implemented within a system This organization of elements to realize behavior is called a collaboration A collaboration is a collection of instances wired together using connectors to show the communication flow Because the purpose of collaborations is to describe how a particular piece of functionality works details outside the scope of the desired functionality are typically left off a diagram Instead a collaboration diagram shows the required links between instances and the attributes involved in the collaboration You may have multiple collaborations involving the same instances but showing different views of each based on the functionality expressed One effective way of showing different views of a classifier is to use interfaces to collect related functionality A single class may realize multiple interfaces but each collaboration can focus
24. each diagram represents a particular interest or view of the thing being modeled 1 6 1 Diagrams UML 2 0 divides diagrams into two categories structural diagrams and behavioral diagrams Structural diagrams are used to capture the physical organization of the things in your systemi e how one object relates to another There are several structural diagrams in UML 2 0 Class diagrams Class diagrams use classes and interfaces to capture details about the entities that make up your system and the static relationships between them Class diagrams are one of the most commonly used UML diagrams and they vary in detail from fully fleshed out and able to generate source code to quick sketches on whiteboards and napkins Class diagrams are discussed in Chapter 2 Component diagrams Component diagrams show the organization and dependencies involved in the implementation of a system They can group smaller elements such as classes into larger deployable pieces How much detail you use in component diagrams varies depending on what you are trying to show Some people simply show the final deployable version of a system and others show what functionality is provided by a particular component and how it realizes its functionality internally Component diagrams are discussed in Chapter 5 Composite structure diagrams Composite structure diagrams are new to UML 2 0 As systems become more complex the relationships between elements grow in
25. gt lt xs attribute name lang use required gt lt xs simpleType gt lt xs restriction base xs NMTOKEN gt This page was created by the unregistered version of CHMI To POF Converter by Theta Sottware lt xs enumeration value en gt lt xs enumeration value fr gt lt xXS Fes triclion gt lt xs simpleType gt lt xs attribute gt lt xs extension gt lt xs simpleContent gt lt xs complexType gt lt l Class Sshorinane rere sinew er wr re em a lt xs element name shortname type shortname gt lt xs complexType name Shortname gt lt xSs sequence gt lt xs element ref langstring minOccurs 1 maxOccurs unbounded gt lt xs sequence gt lt xs complexType gt fle eClass tLechnicalcontact HK aHennemr ew HA eRe gt lt xs element name technicalcontact type technicalcontact gt lt xs complexType name technicalcontact gt lt xSs sequence gt lt xs element ref contact minOccurs 1 maxOccurs unbounded gt lt xs sequence gt lt xs complexType gt flee Class Lrainingconlacl tere wne enh ewan ee gt lt xs element name trainingcontact type trainingcontact gt lt xs complexType name trainingcontact gt lt xs sequence gt lt xs element ref contact minOccurs 1 maxOccurs unbounded gt lt xs sequence gt lt xs complexType gt lt xs schema gt Figure 2 38 is a UML representation of the schema Elements are represented as classes with
26. iaten accent ag Lite ng ort it par sacku where This page was created by the unregistered version of CHM To POF Converter by Theta Sottware Sequence number name Is the index of the message with 1 being the index of the first message in the diagram You show nested message calls by appending the original message number with a decimal and then starting a new sequence For example if the listen call in Figure 10 38 makes a nested call to startTimer number startTimer aS 3 1 You can show concurrent messages using letters in the sequencing For example if the ListentingPort instance can support multiple parallel listening calls the MainWindow instance can call the listen call twice labeling the first call as 3a and the second as 3b Both calls can execute concurrently Is the name of the message being sent or method call recurrence or guard Is an optional part of the syntax that allows you to specify a boolean condition that must be true for the message to occur or a range of integer values for looping Guard conditions are represented as normal boolean expressions for example password Valid true UML doesn t provide a syntax for specifying looping constraints but does say they must begin with an asterisk For example you can represent a loop that executes from O to 10 aS i 0 10 10 13 2 Interaction Overview Diagrams Interaction overview diagrams represent interactions using a simplifi
27. mParent Object not null mVWVidth int mWidth gt 0 logBase10 value int double value gt 0 beginCalculation boolean precondition parameters have been validated sortElements elements Object Object a se s k i elements null 2 2 7 Static Attributes Static attributes are attributes of the class rather than of an instance of the class For example you can initialize constant values for a class and share them between all instances of the class You represent static attributes by underlining their specification in both inlined and relationship based presentations as shown in Figure 2 12 Figure 2 12 Static attribute singleton This page was created by the unregistered version of CHM To POF Converter by Theta Sottware PREY NEXT 1 2 3 Operations Operations are features of classes that specify how to invoke a particular behavior For example a class may offer an operation to draw a rectangle on the screen or count the number of items selected in a list UML makes a clear distinction between the specification of how to invoke a behavior an operation and the actual implementation of that behavior a method See Methods for more information You place operations in a separate compartment with the following syntax visibility name parameters return type properties where parameters are written as direc
28. one exception the contact definition includes a choice option Figure 2 38 represents this using another class stereotyped as xSDchoice and the options are represented as attributes of the class So while UML simplifies a schema by representing the information graphically details such as sequencing and type information can be lost without using a UML extension mechanism such as constraints or stereotypes 2 9 2 Database Schemas By mapping database tables to classes and table rows to attributes you can capture a database schema fairly well using UML Additional information such as primary keys foreign keys and constraints can be captured using UML constraints or stereotypes You can show relationships between tables using associations between classes usually composition relationships but that is just by convention Figure 2 39 shows a sample database schema represented using a UML class diagram As with XML schemas few professional database administrators model databases using class diagrams UML class diagrams are useful for conveying schema information in a common This page was created by the unregistered version of CHM To POF Converter by Theta Sottware language but they lack the expressive and custom capabilities of the more standard database notation Entity Relation Diagrams ERDs Figure 2 38 A class diagram representation of Example 2 2 equipmentList hia Mf equipment XSDattibutes equipmentid stri
29. operations dispatching events 2nd do activity 2nd documentation diagrams and use Cases dot 2nd 3rd Doxygen tool DTDs PREY NEXT gt This page was created by the unregistered version of CHM To POF Converter by Theta Sottware PREV NEXT Index SYMBOL A B C D E F G H H J K M N O P Q R S CO U M W X EAI Enterprise Application Integration edges activity effect activity transition 2nd elements collections and interaction diagrams and naming overview profiles and stereotypes and 2nd 3rd encapsulation Enterprise Application Integration EAI entity component Entity Relation Diagrams ERDs entry activity protocol state machines and 2nd transitions and triggers for Entry pseudostate 2nd equals sign 2nd ERDs Entity Relation Diagrams event occurrences assertions and critical regions 2nd general ordering looping 2nd negative overview parallel execution sequence timing strict sequencing traces weak sequencing events as triggers 2nd completion mapping parameters processing transitions and exception handlers activity diagrams and modeling mechanism exception pins exceptions operations and execution environment 2nd execution occurrences This page was created by the unregistered version of CHMI To POF Converter by Theta Sottware execution occurrences expansion regions and overview streaming exists opera
30. timing diagrams and lifelines keyword local variables logical operators loop interaction operator 2nd 3rd loop nodes looping activity diagrams constraints and event occurrences 2nd interaction overview diagram lost messages 2nd A PREY ET This page was created by the unregistered version of CHM To POF Converter by Theta Sottware a PREY NEXT I Index SYMBOL A B C D E F G H H J K M N O P Q R S CO U M W X MO model 2nd M1 model 2nd 3rd M2 model 2nd 3rd M3 model manifest keyword manifestation mapping model marking model marks 2nd MDA Model Driven Architecture design decisions formal transformation language functionality models overview 2nd UML and merge nodes 2nd merging packages 2nd messages as gates considering destroy event occurrences execution occurrences ignoring 2nd interaction diagrams and interaction fragments nested calls overview timing of metamodels 2nd method calls 2nd methods 2nd minus sign 2nd model elaboration modeling activity 2nd adornments behavioral classifiers defined Diagram Interchange Specification models connecting diagrams versus MDA This page was created by the unregistered version of CHMI To POF Converter by Theta Sottware OCL 2nd transforming MOF Meta Object Facility CIM and example functionality OCL and multicasting multidimensional partitions multiplicity aggregati
31. transformations can t understand just any model Each model requires a specialized model as shown in Figure A 5 UML profiles provide one vehicle to constrain each model alternative MOF based metamodels provide another Explicit UML profiles enforce constraints so that only models considered valid by the transformers can be processed Considering the leverage of expression between the PIM and each PSM and again between each PSM and its derivative Figure A 5 Each model and transformation definition conforms to a language Meta anguage UML MOF NIN IN EN AS AS EN Instance of W EET T i z Titer ft tr itt ttt eee whee T UML profile PIM oe i or Marking 3 MOF based Language F metamodel F 3 See ee fk Be E LE TE EI er rr Ce eee EE EE L G code models slightly invalid source models would produce rubbish UML profiles provide the discipline needed to keep such a complex system running This page was created by the unregistered version of CHM To POF Converter by Theta Sottware MDA systems need not have such a formal definition as the one we described Certainly architects who extend the transformations with custom scripting will not back it with a formal transformation language The languages act much as DTDs or schemas do for an XML document languages assure that the consumers will understand the model This page was created by the unregistered version of CHM To POF Converte
32. 3rd states and 2nd transitions and operations asterisk loop operator looping constraints multiplicity value 2nd OCL operator 2nd asynchronous messages 2nd attribute notation attributes activities and association classes and class diagram and classifiers and compartments and constraints on 2nd defined derived 2nd events and extending inlined mapping mapping table rows to multiplicity of This page was created by the unregistered version of CHMI To POF Converter by Theta Sottware parameters and partitions and postconditions of preconditions of properties of 2nd return values and static tagged values and attributes by relationship inlined attributes and overview 2nd AWT Abstract Windowing Toolkit A PREY NEXT W This page was created by the unregistered version of CHM To POF Converter by Theta Sottware 4 PREV NEXT Index SYMBOL A B C D E E G H U J K M N O P Q R S L Y M W X ball and socket lollipop notation assembly connectors 2nd interfaces 2nd port typing behavior decision input object flows and of activities of classifiers 2nd pseudostates and real time selection transformation behavioral diagrams 2nd behavioral modeling behavioral ports behavioral state machines 2nd bidirectional ports binding black box view components body conditions body keyword body subregion boolean datatype 2nd boolean
33. 4 PREV NEXT Index SYMBOL A B C D E F G H H J K M N O P Q R S CO U M W X qualifiers association 2nd query constraint query method query operations 2nd query only languages 4 PREY NEXT W This page was created by the unregistered version of CHM To POF Converter by Theta Sottware 4 PREV NEXT Index SYMBOL A B C D E F G H H J K M N O P Q R S CO U M W X Rational Unified Process RUP readOnly property 2nd 3rd real datatype real time behavior realization compartment realization component redefines property attributes ref interaction _diagram_name regions composite states and critical 2nd expansion 2nd final state interruptible activity representation 2nd state machine extensions reject _ operation relationship notation 2nd relationships actors and use cases aggregation artifacts and nodes association 2nd association classes 2nd association qualifiers 2nd attributes by 2nd 3rd class diagram and classes and composition 2nd dependency generalization properties pseudostates state machines UML modeling required hardware node required interfaces assembly connector and compartments components and ports and 2nd required software node result keyword OCL return values interactions and 2nd local variables This page was created by the unregistered version of CHM To POF Converter
34. 9 Preface About This Book How to Use This Book Typographic Conventions Safari Enabled Comments and Questions Acknowledgments A PREY NEKT W This page was created by the unregistered version of CHM To POF Converter by Theta Sottware PREY NEXT 1 About This Book Welcome to UML 2 0 in a Nutshell The Unified Modeling Language UML has expanded quite a bit since its inception and can be applied to many different domains however it still has its roots in software development We have tried to make this book applicable to as broad an audience as possible but it s helpful to have at least a cursory knowledge of Object Oriented Programming OOP because UML draws much of its terminology from that domain Before going any further we d like to clarify how this book refers to the Unified Modeling Language Grammatically speaking the UML is correct However it sounds weird This book uses the more colloquial UML UML 2 0 in a Nutshell is a detailed reference for the UML 2 0 Superstructure from a user s perspective Whenever it would be helpful to clarify a UML concept with a concrete example we will present Java code In general we assume that you are familiar with OOP and the type of constructs that go with it classes methods inheritance etc However we make no assumptions about what you know about UML Each chapter starts with a top to bottom discussion of the chapter s topic This will be fast paced and th
35. Converter by Theta Sottware PREY NEXT 1 7 1 Use Cases Use cases represent distinct pieces of functionality for a system a component or even a class Each use case must have a name that is typically a few words describing the required functionality such aS View Error Log UML provides two ways to draw a use case The first is an oval with the name of the use case in the center Figure 7 1 shows a basic use case Figure 7 1 A simple use case You can divide a use case s oval into compartments to provide more detail about the use case such as extension points see Use Case Extension included use cases see Use Case Inclusion or the modeling of specific constraints Figure 7 2 shows a use case oval with a compartment listing extension points However the oval representation of use cases doesn t hold up well with detailed compartments UML recommends you use the classifier notation if you want to provide details about a use case Show the use case as a rectangle with the use case oval in the top right corner Now place the name of the use case in the top in bold You can then divide the classifier into compartments as needed Typical Figure 7 2 Use case with a compartment showing extension points View Error Log Ee Th ie lt lt extension points gt gt Show Detailed Log at compartment names are extension points and included use cases Figure 7 3 shows the Same use case as in Figure 7 2 but in classifie
36. Converter by Theta Sottware KI NEXT W Index SYMBOL A B C D E F G H H J K M N O P Q R S CO U M W X object diagrams defined design view and unnamed objects in object flows object nodes Object Oriented Analysis and Design OOAD 2nd objects abstract classes and actions and built in properties casting constraints and defined 2nd displaying multiple execution occurrences gates and lifelines and method calls between representation 2nd 3rd tokens OCL Object Constraint Language advanced modeling as UML specification 2nd basic types defined overview syntax oclAsType property OCL oclInState property OCL ocllsKindOf property OCL ocllsNew property OCL ocllsTypeOf property OCL OMG Object Management Group MDA and 2nd OCL and SPEM and UML and 2nd OOAD Object Oriented Analysis and Design 2nd operations activities and class diagram and collaboration occurrence Collection class compartments and constraints on 2nd 3rd 4th This page was created by the unregistered version of CHMI To POF Converter by Theta Sottware methods and OCL properties and static syntax elements transitions and opt interaction operator options or logical operator logic rules OCL and 2nd order of precedence ordered property attributes 2nd operations ordering asynchronous messages and general guard conditions representation orthogonal com
37. Index SYMBOL A B C D E F G H H J K M N O P Q R S CO U M W X dash arguments and comments and messages visibility 2nd data store nodes database modeling database schemas database testing decision input behavior decision nodes 2nd decomposition decomposition compartment deep history pseudostate def keyword default entry default_value element operations defer keyword deferred events 2nd dependency relationship classifiers components 2nd defined interfaces representation 2nd stereotypes and dependency relationships class diagram and depicting depicting multiple deployed artifact deployment code model and deployment deployment view and nodes and overview variations on 2nd deployment diagrams artifacts and defined deployment specifications 2nd 3rd deployment target deployment view derive keyword This page was created by the unregistered version of CHMI To POF Converter by Theta Sottware derived attributes 2nd derived property attributes design decisions design view devices nodes and 2nd Diagram Interchange Specification diagrams abstraction and 2nd as building blocks defined diagrams exception handling missing compartments and modeling and models versus notes notes and overview 2nd sprawling scope Static UML and use Cases views 2nd wallpaper direct substates directed dependency graphs direction element
38. a particular event occurrence must come before another event occurrence UML has an explicit notation called a general ordering You can show a general ordering anywhere in an interaction diagram but it must connect two event occurrences You simply draw a dotted line between the two event occurrences with a solid arrow in the middle of the line pointing toward the occurrence that must happen second For example if you don t want the login splash screen in Figure 10 21 to be hidden until all the applications are started you can indicate that the startUserLoginApps call must occur before the hideLoginSplashScreen call Figure 10 22 shows how to use a general ordering to indicate that the application startup must complete first Figure 10 22 Example general ordering This page was created by the unregistered version of CHMI To POF Converter by Theta Sottware sd Desktop Startup Sequence par i showLoginSplashScreen E l loadColorPrefta m sonlconsi hideLoginSplashScreen 1 EE a F f stanFrewallSenice paeen ee e m i P The general ordering indicates startSystemLoginApnpat gtartUserLoqinAnpsl must occur a4 F B before hideLoginSplashScreen ee startSystemTrayAppst ifthe calls are intermingled i E l during execubor l hrs slartJserLoginAppst si me ge ee ee ee ee eee ee ee ee ee ee ee 10 8 2 5 Weak sequencing Weak sequencing indicates that the event occurrences in e
39. anywhere in UML and is typically associated with a classifier using a note When an OCL expression is evaluated it is considered to be instantaneous meaning the associated classifier can t change state during the evaluation of an expression B 1 1 Basic Types OCL has several built in types that can be used in OCL expressions Boolean Must be either true or false Supports the logical operatorSand or xor not implies andif then else Integer Any integer value e g 100 12345 5211976 etc Supports the operators andabs Real Any decimal value e g 2 222003 67 76 etc Supports the operators and Pigg J a String A series of letters numbers or symbols interpreted as a string e g All writing and no play make Dan Supports the operators concat size and substring In addition to the built in types any classifier used in your UML model is recognized as a type by OCL Because OCL is a strongly typed language you can t compare values of one type directly with values of another type B 1 2 Casting OCL does support casting objects from one type to another as long as they are related through a generalization relationship To cast from one type to another use the operation This page was created by the unregistered version of CAMA To POF Converter by Theta Sottware oldType oclAsType newType For example to cast a Java List to an ArrayList to call the size operation
40. approach to technical topics breathing personality and life into potentially dry subjects The animal on the cover of UML 2 0 in a Nutshell is a chimpanzee Pan troglodytes Chimpanzees use a vast array of facial expressions postures and gestures to communicate with each other in addition to at least 32 different sounds There is some evidence to suggest that chimpanzees can learn symbolic languages The natural habitat of the chimpanzee is western Africa from Sierra Leone to the Great Lakes east of the Congo Living primarily in forested areas chimpanzees spend 50 to 70 percent of their time in trees They are omnivores eating primarily fruits and vegetables but they will also hunt and eat small animals They live in family groups that consist of about twice as many females as males While adult chimpanzees aren t monogamous there s a close bond between a young chimp and its parents and this bond remains unbroken for life Chimpanzees are very sociable and affectionate animals and frequently hug kiss stroke each other or hold hands Violent fights often break out within a social group The loser of the fight makes up to the winner by displaying submissive behavior and conciliatory gestures In this way they maintain the social harmony Though able to the chimpanzee rarely walks erect on both feet Short arm muscles prevent simultaneous extension of the wrists and fingers Because of this chimpanzees can t walk with their hands flat
41. be extended You can informally extend UML by adding constraints stereotypes tagged values and notes to your models or you can use the formal UML extension and define a full UML profile A UML profile is a collection of stereotypes and constraints on elements that map the otherwise generic UML to a specific problem domain or implementation For example there are profiles for CORBA Enterprise Application Integration EAI fault tolerance database modeling and testing See Chapter 11 for more information on UML 2 0 Profiles PREV NEXT 9 This page was created by the unregistered version of CHM To POF Converter by Theta Sottware PREY NEXT W 1 6 Modeling It should go without saying that the focus of UML is modeling However what that means exactly can be an open ended question Modeling is a means to capture ideas relationships decisions and requirements in a well defined notation that can be applied to many different domains Modeling not only means different things to different people but also it can use different pieces of UML depending on what you are trying to convey In general a UML model is made up of one or more diagrams A diagram graphically represents things and the relationships between these things These things can be representations of real world objects pure software constructs or a description of the behavior of some other object It is common for an individual thing to show up on multiple diagrams
42. behavioral diagrams are Activity diagrams Activity diagrams capture the flow from one behavior or activity to the next They are Similar in concept to a classic flowchart but are much more expressive Activity diagrams are discussed in Chapter 9 Communication diagrams Communication diagrams are a type of interaction diagram that focuses on the elements involved in a particular behavior and what messages they pass back and forth Communication diagrams emphasize the objects involved more than the order and nature of the messages exchanged Communication diagrams are discussed as part of interaction diagrams in Chapter 10 Interaction overview diagrams Interaction overview diagrams are simplified versions of activity diagrams Instead of emphasizing the activity at each step interaction overview diagrams emphasize which element or elements are involved in performing that activity The UML specification describes interaction diagrams as emphasizing who has the focus of contro throughout the execution of a system Interaction overview diagrams are discussed as part of interaction diagrams in Chapter 10 Sequence diagrams Sequence diagrams are a type of interaction diagram that emphasize the type and order of messages passed between elements during execution Sequence diagrams are This page was created by the unregistered version of CHM To POF Converter by Theta Sottware the most common type of interaction diagram and are very i
43. by Theta Sottware messages of operations representation return type element operations reverse engineering clutter and MDA and 2nd tagged values and round trip engineering run to completion RUP Rational Unified Process Fa PREY NEKT W This page was created by the unregistered version of CHM To POF Converter by Theta Sottware 4 PREV NEXT Index SYMBOL A B C D E F G H H J K M N O P Q R S COU M W X Scalable Vector Graphics SVG schemas 2nd scope diagramming system boundaries use cases select operation 2nd selection behavior self keyword seq interaction operator sequence diagrams communication diagrams and defined design view and interaction overview diagrams interactions and 2nd local variables messages and SPEM and sprawling scope sequence timing service component sets associations as setup subregion shallow history pseudostate signal symbols 2nd signals lifelines and Simple Mail Transport Protocol SMTP simple states size operation SMTP Simple Mail Transport Protocol Software Process Engineering Metamodel SPEM specification component specifications deployment 2nd 3rd join UML 2nd 3rd 4th SPEM Software Process Engineering Metamodel state configuration state machine diagrams 2nd 3rd state machines behavioral 2nd connection points extension protocol 2nd 3rd representation This page was created by t
44. by the unregistered version of CHM To POF Converter by Theta Sottware PREY NEXT 1 2 9 Variations on Class Diagrams Because class diagrams model structures well they can be used to capture well defined hierarchical information Class diagrams have been used to capture XML and database schemas with some degree of success In the interest of full disclosure people who deal with XML and database schemas extensively have reservations about using class diagrams to capture the information specifically because class diagrams are so generic Each domain has its own notation that may be better suited to capturing complex relationships or domain specific information However UML has the benefit of being a common language that is understood by those outside the XML and database domains 2 9 1 XML Schemas The structural design of an XML document can be captured in an XML schema XML schemas are to XML documents as classes are to objects XML documents are instances of a schema Therefore it s not a giant leap to realize that class diagrams can be used to model XML schemas XML schemas are described using the XML Structure Definition Language XSDL XSDL is a text language as opposed to the graphical nature of UML and can be verbose mapping XSDL to UML can make it much easier to digest a schema document The fundamental elements of XSDL are XML elements which are connected in sequences choices and complex structures Each element may have
45. by the unregistered version of CHM To POF Converter by Theta Sottware Comprises those editing features scheduled for release 2 x editing Comprises editing features requested by a specific client These features to be withdrawn or delayed depending on that client Risk is independent of the other features Figure 3 8 doesn t show the complete set of packages in the system It is merely enough for management to track and control the project Programmers create lower level packages as needed for correct code design Managers however allocate resources and track progress on the relatively large grains of the project shown in Figure 3 8 without getting disturbed by the addition or refactoring of internal packages and contents 3 5 2 Use Case Packages Use case packages organize the functional behavior of a system during analysis Figure 3 9 shows the major functional areas of a content management system The packages provide understandable terms for team members outside the analyst team Managers can discuss the project at an appropriate level of detail without getting bogged down in details The CMS system shown in Figure 3 9 comprises packages created for the following reasons e The complex editing packages separate the preliminary delivery and the advanced delivery from the client based delivery e The simple interactions view and feedback contain basic low risk functions e The reporting has more sophisticated functions e The search
46. can expect toolmakers to extend the graphics differently including coloring or shading at their discretion Avoid graphical symbols for interchange of models between different tools However within the controlled environment of a compatible set of tools specialized graphics and or colors will likely have more visual impact This page was created by the unregistered version of CHMI To POF Converter by Theta Sottware While stereotypes have been around since the initial beta versions of UML UML 2 0 has introduced significant changes to the 1 x versions e Elements may have zero one or more than one stereotype The use and usefulness of stereotypes have become more and more evident More toolmakers have incorporated them into their products Modelers found it impossible to use otherwise complimentary tools because an element can have only one stereotype Stereotypes may be nested A specialized stereotype can build on the structure of a general stereotype In the example provided later in this chapter the EJBPrimaryKey stereotype extends the EJBCmpField stereotype because all primary keys are ordinary fields as well Tagged values are related through a stereotype rather than directly to the element This avoids the possibility of name clashes with the introduction of multiple stereotypes per element You can tag an item in a UML model with more than one stereotype Figure 11 4 shows multiple stereotypes as a list with each stere
47. common representation of interactions is with sequence diagrams you use the notation that s common with such diagrams See the specifics about other notations in Alternate Interaction Notations When using sequence diagram notation you show a message as a Solid line pointing from the sender s lifeline to the receiver s lifeline If the message is an asynchronous message meaning the caller doesn t block waiting for the receiver to process the message you place an open arrowhead on the receiver s end of the line Figure 10 5 shows an example of an asynchronous message Figure 10 5 An asynchronous message between objects sd Return a book to the library ass sain ih aca eh ear age FD la i An asynchronous call is shown with an open arrowhead Average Joe Mendall Ep re Aneel erence mete Pat CirouwlalionDesk F a retumnBook book _ be a rs E j i e When returning a book to the library you typically don t wait around for the librarian to return the book to the shelves Instead you drop the book off at the Circulation Desk and continue on your way The open arrowhead indicates that the caller AverageJoe doesn t wait for any response from the CirculationDesk Because asynchronous messages don t require the sender to wait for a message to be delivered depending on the transport mechanism asynchronous messages can arrive out of order For example two network packets can take different routes to the same destination with
48. deployment using a dashed line with an open arrow dependency pointing from the artifact to the deployment target You should stereotype this line with the keyword deploy Figure 6 14 shows the same deployment relationship as Figure 6 13 but uses the dependency notation Finally you may show deployment by simply listing deployed artifacts in a compartment in the deployment target s classifier This notation is particularly useful if you have a lot of artifacts deployed to a single node Figure 6 15 shows an execution environment with several deployed artifacts Figure 6 13 An artifact deployed to a device F device AppServeri i ccvalidator jar Figure 6 14 Artifact deployment using a dependency relationship This page was created by the unregistered version of CHM To POF Converter by Theta Sottware b device AppServer1 deploy EAN ccvalidator jar Figure 6 15 An execution environment with a list of the deployed artifacts J2EE Co ntainer JBoss ccvalidator jar orderprocessing jar htmlfrontend jar postgresqlbridge jar UML 2 0 introduced the term deployed artifact for artifacts that have been associated with nodes There is no new notation UML 2 0 just added a formal recognition of the concept 6 3 2 Deployment Specifications Adeployment specification is a collection of properties that specify how an artifact is to be deployed on a deployment target For example you can speci
49. effect of emphasizing the relationships of the classifiers making up the component and it encourages component encapsulation Figure 5 11 shows the detailed realization of a component If the internals of a component are sufficiently complex it is common to use a separate class diagram to model the details You can link the new class diagram back to its component using a note Figure 5 11 Detailed realization of AccountManagement This page was created by the unregistered version of CHM To POF Converter by Theta Sottware AccountManageament kianiity arier Account OrderHistory madee semang pebOnders Order linjart findrderidateStart Date dateEnd Date Order anes z getrdetorderNumber int Onder e Lisarharned taide concer aar vice AccouniSendgas adi boris cheaieOrderl Order F j mOran a I Onder 1 anlama Vector TaactonLoggei rOnderDale Date areOncieetarmioer int against lt itemi epeiiderDa j Daw pelOrdarNuribert int 5 2 2 3 Ports and connectors UML 2 0 introduces the concept of ports to allow you to explicitly identify functionality that is exposed to the outside world A port groups together related provided and required interfaces and uses connectors to map them to a classifier that realizes the functionality If a port has both provided and required interfaces it is called a bidirectional port A port is shown as a small rectangle on one of the sides of a classif
50. expressions constraints and exists operation forAll operation naming elements in state invariants brackets 2nd break interaction operator breaks bridges build scripts This page was created by the unregistered version of CHM To POF Converter by Theta Sottware 4 PREV NEXT Index SYMBOL A B C D E F G H H J K M N O P Q R S CO U M W X C language cancel event casting 2nd central buffer nodes choice pseudostate CIM computational independent model class diagrams attributes classes considerations database schemas defined design view and interfaces methods operations purpose relationships SPEM and tagged values and templates wallpaper diagrams white box view and XML schemas classes abstract 2nd 3rd association 2nd attributes class diagram and compartments and connectors and defined exceptions and extending 2nd instances mapping tables to methods and objects and operations and overview package merging and 2nd parameterized partitions and relationships structure and interrelationships structured This page was created by the unregistered version of CHMI To POF Converter by Theta Sottware templates white box view and classifier notation actors extension points use cases 2nd classifiers behavior of Classes as collaboration occurrence collections and compartments constraints on dependencies e
51. in Figure 4 11 Figure 4 11 The Application Window Button relationship Application ye Window ay Button When used in composite structure diagrams relationships between properties are shown in the owning classifier s rectangle This allows you to further restrict the association between parts of the composite classifier For example Figure 4 11 shows that Buttons can be associated with any window Using a composite structure diagram you can restrict the window to be associated only with a Button owned by the same application When you draw the composite structure diagram properties that are associated with the composite structure through composition are shown with solid rectangles and properties that are shared with other structures are shown using a dashed rectangle You may place multiplicity information for a property in its rectangle in the upper right corner or after the name of the property in brackets Figure 4 12 shows the composite structure diagram of application window and button relationships In addition to simply specifying how properties fit together you can use composite structures to specify how instances are instantiated As in Chapter 3 instances are shown by underlining the name and type of the classifier You may specify initial values for each attribute of a classifier by specifying the name of the attribute followed by an equals sign and the value of the attribute When used as instances you can specify the ro
52. initial node can have no incoming edges You can have multiple initial nodes for a single activity to indicate that the activity starts with multiple flows of execution You show an initial node as a solid black dot as shown in Figure 9 4 9 3 4 2 Decision and merge nodes Adecision node is a control node that chooses different output flows based on boolean expressions Each decision node has one input edge and multiple outgoing edges When data arrives at the decision node a single outgoing edge is selected and the data is sent along that edge A decision node usually selects an edge by evaluating each outgoing edge s guard condition A guard condition is a boolean expression that tests some value visible to the activity typically an attribute of the owning classifier or the data token itself You show a decision node as a diamond with the flows coming into or out of the sides You show guard conditions by putting a boolean expression in brackets near the activity edge Figure 9 19 is an activity diagram showing a decision made while wrapping presents Guard conditions aren t guaranteed to be evaluated in any particular order and a decision node allows only one outgoing edge to be selected You should take care to design your models so that only one guard condition ever evaluates to true for a given set of data to prevent race conditions You can specify functionality that executes whenever data arrives at the decision node Called d
53. interaction fragment and can be safely ignored This typically implies that the ignored messages are irrelevant for the purpose of the diagram however they may still occur during actual execution The interaction operator iS ignore and the syntax is This page was created by the unregistered version of CHM To POF Converter by Theta Sottware ignore messagename messagename Figure 10 26 shows an example of the ignore operator that models a simple mail transmission protocol In this sequence ping and status messages are explicitly ignored This means they can occur anywhere during this sequence and should be handled by the system but are irrelevant to the flow of execution we re trying to model Figure 10 26 Example of an ignore operator sd Mail transmission sequence ignore ping status Workstation Workstation authenticateUser Dan nOm41 i gt sendEnvelope headers oe _ sendBody bodyText l disconnect l Consider specifies a set of messages that are explicitly relevant to the diagram so you can safely ignore any other message The interaction operator is consider and the syntax is consider messagename messagename Figure 10 27 shows the same mail transmission sequence as that shown in Figure 10 26 but explicitly considers authenticateUser sendEnvelope sendBody disconnect shutdown and reset Because shutdown and reset aren t shown on the sequence diagram it s invalid for either
54. map closely to code Pick a program or domain you know well and try to capture the entities involved using classes Once you re convinced you ve modeled the relationships between your entities correctly pick a piece of functionality and try to model that using a sequence diagram and your classes If you re more of a process person business or otherwise you may be more comfortable starting with an activity diagram Chapter 9 shows examples of modeling business processes with different groups Human Resources IT etc and progresses to modeling parallel processes over different geographic regions a PREY NEKT W This page was created by the unregistered version of CHM To POF Converter by Theta Sottware PREY NEXT 1 1 2 Background UML has become the de facto standard for modeling software applications and is growing in popularity in modeling other domains Its roots go back to three distinct methods the Booch Method by Grady Booch the Object Modeling Technique coauthored by James Rumbaugh and Objectory by Ivar Jacobson Known as the Three Amigos Booch Rumbaugh and Jacobson kicked off what became the first version of UML in 1994 In 1997 UML was accepted by the Object Management Group OMG and released as UML v1 1 Since then UML has gone through several revisions and refinements leading up to the current 2 0 release Each revision has tried to address problems and shortcomings identified in the previous versions leadin
55. may be declared as a query operation if the implementation of the operation doesn t modify the owning class in any way In practice modelers often use the query property to indicate a method that doesn t change any meaningful attribute of an object For example there may be internal cache attributes that are updated as a result of a query The important thing is that the state of the system from an external perspective isn t changed by the query method there can be no side effects to calling the method You indicate a query method by placing the query constraint after the operation signature For example an operation named getAge that simply returns an integer without changing any internal value of the owning class would be considered a query method In C this typically maps to a const method Figure 2 17 shows several query methods on a class Figure 2 17 Example query operations Person The query constraint guarantees thal getName uii and getAge won t modify the object ER a ge a a ee a ea getName String query getAge int query 2 3 1 5 Exceptions While they re technically not constraints you may express exceptions thrown by an operation using similar notation Exceptions are typically other classes often stereotyped with the keyword exception though this is simply by convention that are thrown by an operation in the event of an error You can list thrown exceptions in a note atta
56. model You ve been warned a PREY NEXT This page was created by the unregistered version of CHM To POF Converter by Theta Sottware PREY NEXT 9 11 2 Stereotypes Stereotypes modify the intent of the elements to which they apply They allow the differentiation of roles of an element within the model For example you can quickly differentiate classes stereotyped as Controller as having a different role in the system than those stereotyped as View Visually UML allows graphical and textual representation of a stereotype Graphics and text can be combined in various ways for node type elements as shown in Figure 11 3 The four elements that you see going across the top of the figure all represent the same combination OfForm and key stereotypes but in different ways Edge type elements have only a textual representation and thus you see depends on the dependency between Billing and Inventory Figure 11 3 Various representations of stereotypes naraka mipi Carkegistration CarRegistrati akey id He key id lt 3 id arRegistration 9 id Billing achapangdya inventen When displayed as text a stereotype is enclosed in guillemots as iN MyStereotype Because the guillemots require an extended character set to display correctly you may also use double angle brackets to show a stereotype in 7 bit ASCII as in lt lt MyStereotype gt gt Graphical icons are neither defined nor standardized by UML You
57. modeling guidelines it helps novice users get up to speed quicker and helps experienced users really think about how they represent something and consider a potentially better notation UML is intended to be extended UML includes several mechanisms to allow customization and refinement of the language Such mechanisms as adornments constraints and stereotypes provide ways to capture specific details that aren t easily expressed using classifiers and relationships Typically these are grouped into what are known as UML profiles For This page was created by the unregistered version of CHMI To POF Converter by Theta Sottware example you can put together a Java 2 Enterprise Edition J2EE profile that includes stereotypes for sessionbean Or javadataobject If you are modeling a complex domain consider putting together a UML profile that lets you easily identify elements as concepts in your domain such aS mutualfund OF securitymonitor A PREY NEXT W This page was created by the unregistered version of CHM To POF Converter by Theta Sottware PREY NEXT Chapter 2 Class Diagrams Class diagrams are one of the most fundamental diagram types in UML They are used to capture the static relationships of your software in other words how things are put together When writing software you are constantly making design decisions what classes hold references to other classes which class owns some other class and so on Class d
58. plus sign before the element name You show private visibility using a minus sign Figure 3 4 shows the utility package with some private helper classes Figure 3 4 The Utilities package with public and private members Utilities a aueue T l in this package LinkedList Timer Queue LinkedList is a helper class for i Queue so itis private TimeCallbackHandler Semaphore a PREY NEXT This page was created by the unregistered version of CHM To POF Converter by Theta Sottware PREV NEXT 1 3 3 Importing and Accessing Packages When accessing elements in one package from a different package you must qualify the name of the element you are accessing For example if Car is a class in the transportation package and you are trying to access it from a package named RoutePlanning you need to qualifycar aS transportation Car To simplify accessing elements in a different package UML allows a package to import another package Elements of the imported package are available without qualification in the importing package So if the RoutePlanning package imported the transportation package you can refer to car without any qualifications from within the RoutePlanning package To show a package import you draw a dashed line with an open arrow from the importing package to the imported package Label this line with the import keyword Figure 3 5 shows theRoutePlanning package importing the transporta
59. processing and tokens inside the region are terminated The token leaving the region is unaffected Typically the source of an interruption is the receipt of a signal from an external entity You show receipt of a signal as a concave pentagon with the name of the signal inside Figure 9 37 shows an example of a long running database query being interrupted by user input 9 4 7 Central Buffer Nodes UML 2 0 introduced a new type of activity node called the central buffer node that provides a place to specify queuing functionality for data passing between object nodes A central buffer node takes inputs from several object node sources and offers them along several object node outputs For example there may be two car manufacturing plants feeding a car dealer supply line A central buffer node can be placed between the manufacturing plants and the dealers to specify prioritization of deliveries or sorting of the manufactured cars You show a central buffer node as a rectangle with the keyword centralBuffer at the top and the Figure 9 37 Activity diagram with an interruptible region This page was created by the unregistered version of CHM To POF Converter by Theta Sottware 4 Retrieve Past Orders __ Retrieve Customer ss ie ia Niner gt Search Order Archives j Display Results e Cancel Search pee Display Cancellation Request ar Message type of object written in the center Figure 9 38 shows a
60. represents a business concept An entity component typically passes information in and out of interfaces and is often persisted as a whole Entities don t typically have any functionality or service capabilities associated with them they are usually just for data storage and retrieval Process A component that can fulfill functional requests as opposed to an entity component A process component is transaction based and typically has some type of state associated with it as opposed to stateless service components Realization A component that doesn t have its own specification Rather it is a realization of a specification component as shown in Figure 5 13 Figure 5 13 A specification component associated with a realization component specification UDDI Registry k PM pate ace ah cl op fue heed gt The UDDI Registry component A provides the required interfaces for the UDDI specification The iT MyCoUDDI component actually implements those interfaces fi arealizations 7 MyCoUDDI Service A stateless component that can fulfill functional requests Service components are rarely persisted because they contain no state Specification A component that has provided and required interfaces but no implementation realizing classifiers A specification component shown in Figure 5 13 should be paired with a realization component or implement component Subsystem This page was created by
61. showing a few elements that are out of scope the diagram allows you to see the context of the application within the greater framework and that s often useful when selecting an architecture Similarly drilling down into the base libraries exposes thread or performance issues These are exceptional needs there is no call to complicate the description of an application with these exploratory needs From the readers point of view nonapplication elements just cloud understanding of the business This page was created by the unregistered version of CHM To POF Converter by Theta Sottware logic the only thing over which the developer exerts control Figure 12 6 shows the processing for another HTML form It gets to the point It is concise enough for one page And it focuses on interactions between the application classes the interactions are under control of the development team Figure 12 6 Sequence diagram with scope restricted to programmer defined classes sd Form Validation rawToken RawToken token SesstonToken hash TokenHash errors ActionErrors WValidate ActionMapping HttpServietRequest ee l I token getToken 1 i l l l i I hash getHash token null amp amp hash null I errors getValidator walidate i PREY NEXT This page was created by the unregistered version of CHM To POF Converter by Theta Sottware PREY NEXT 12 3 One Diagram One Abstraction
62. state machine has a set of connection points that define the external interface to the state machine These connection points must be either Entry or Exit pseudostates A PREY NEKT W This page was created by the unregistered version of CHM To POF Converter by Theta Sottware PREY NEXT W 8 2 States States model a specific moment in the behavior of a classifier This moment in time is defined by some condition being true in the classifier States model a situation in the behavior of a classifier when an invariant condition holds true Put more simply a state is a condition of being for the state machine and by association the classifier that s being modeled For example a coffee machine could be Grinding Beans Brewing Warming Coffee Dispensing etc A state can represent a static situation such as Waiting for Username or a dynamic situation where the state is actively processing data such as Encrypting Message A state is shown as a rectangle with rounded corners The name of the state is written inside the rectangle Figure 8 3 shows a simple state Figure 8 3 A simple state e Dispensing A state name may be placed outside of the rectangle in a tab notation when showing composite or submachine states see Composite States and Submachine States You Should either use the tab notation or place the name inside the state don t do both Figure 8 4 shows a state using a tab for the sta
63. the message with the keyword create as in Figure 10 3 If there are arguments you show them as parameters to a create message If there is a particular reason to show the creation message using a different label such as a factory method you should use that Figure 10 8 shows an example that creates an instance of the class UserAccount Figure 10 7 A method call and the resulting return value This page was created by the unregistered version of CHMI To POF Converter by Theta Sottware sd Order a book Customer User orderltem UML 2 0 in a Nutshell confirmationNumber l Figure 10 8 Showing object instantiation sd Create a new user Servlet UserAccount _ addNewUser accountinfo m H create accountinfo newUser j i Although this technique isn t mentioned in the specification some modelers prefer to lower the rectangle representing the object to the end of the message line to clearly indicate the object didn t exist before this creation event The advantage of this notation is that it clearly shows when the object comes into existence the disadvantage is that you can t skim the top row and view the participants Figure 10 9 shows the same diagram but lowers the newly created object UML defines two special types of messages Jost messages and found messages Lost messages are messages that are sent but never reach their desti
64. the unregistered version of CHM To POF Converter by Theta Sottware Shallow Used inside a state region a transition to this history pseudostate from outside the region indicates the state machine should resume the last substate it was in Q within the given region however the substate must be at the same level as the history pseudostate You may specify a default previous state by showing a single transition from the shallow history pseudostate to an internal substate This is used only if the region has never been entered Terminate node w Causes the state machine to terminate A PREY NEXT W This page was created by the unregistered version of CHM To POF Converter by Theta Sottware PREY NEXT W 8 6 Event Processing Information within a state machine is conveyed via events Events can be triggered by things outside of the state machine or as part of an activity executing within a state An event can have parameters and attributes you can use when processing the event 8 6 1 Dispatch As events are triggered they are added to an event pool Once added to the event pool events are sent out for processing by the state machine or are dispatched The order of event dispatch and processing isn t specified by UML This allows state machines to impose their own prioritization schemes on events if desired When dispatching events a new event is dispatched and processed only after the previous event has been fully proc
65. this message is stored in the specified attribute The attribute must be an attribute of the lifeline sending the message a global attribute of the interaction or an attribute of the class owning the interaction signal or operation name Specifies the name of the operation to invoke or the signal being emitted arguments A comma separated list of arguments to pass to the operation or signal The arguments may be values or parameter names If only argument values are used arguments are matched against the operation or signal signature in order If you want to skip an argument place a dash where the argument would be Skipped arguments have This page was created by the unregistered version of CHM To POF Converter by Theta Sottware unknown values You can explicitly identify a parameter name by following the text name with a colon and then the value If you use parameter names you can omit arguments not relevant to the interaction As with a dash skipped arguments have unknown values You can prefix an argument with the keyword out or inout to indicate the argument is used to return a value If the argument is used as an out argument a value after the colon in the argument specification is interpreted to be the return value return value Explicitly states what the return value from this message will be Message notation varies based on the specific notation you use to show the details of the interaction Because the most
66. to be explicit with the context use the OCL keyword context followed by the classifier name If you use this notation you should say what the expression represents In the following case we re showing an invariant so we use the keyword inv Other types of expressions are explained in later sections context Student inv sel f GPA gt 2 0 Instead of using the keyword self you can assign a name to a classifier that you can use in the expression Write the name you want to use followed by a colon and then the classifier name For example you can name the instance of Student aS s context s Student inv S GPA gt 2 0 Finally you can name an expression by placing a label after the expression type but before the colon The label is purely decorative it serves no OCL function context s Student inv minimumGPARule s GPA gt 2 0 B 2 2 Constraints on Operations Beyond basic classifiers OCL expressions can be associated with operations to capture This page was created by the unregistered version of CHM To POF Converter by Theta Sottware preconditions and postconditions Place the signature of the target operation classifier operation name parameters etc after the context keyword Instead of the invariant keyword use either pre or post for preconditions and postconditions respectively The following expression ensures that any student who will be registered for a course has paid their tuition context C
67. use the expression List oclAsType ArrayList size _ If the actual object isn t an instance of the new type the expression is considered undefined A PREY NEXT W This page was created by the unregistered version of CHM To POF Converter by Theta Sottware PREY NEXT B 2 OCL Syntax The remainder of this chapter uses examples from the class diagram shown in Figure B 1 B 2 1 Constraints on Classifiers Each OCL expression must have some sense of context that an expression relates to Often the context can be determined by where the expression is written For example you can link a constraint to an element using a note You can refer to an instance of the context classifier using the keyword self For example if you had a constraint on Student that their GPA must always be higher than 2 0 you can attach an OCL expression to Student using a note and refer to the GPA as follows self GPA gt 2 0 Figure B 1 Example class diagram used in this chapter rae title String par ami roomAssiqnment String foundationDate Date textBook String cournseLewel im registerStudent s Student boolean getHonoritudents Student 0 name String GPA float salary float dateOfBirth Date year Graduation int tuitionPaid boolean It s important to realize that this OCL expression is an invariant meaning the system would be in an invalid state if a student s GPA dropped to less than 2 0 If you want to al
68. when walking on all fours only the knuckles of their hands touch the ground Unlike human feet chimpanzee feet also have an opposing toe but it s used mainly for climbing and for walking on precarious footing The foot is rarely used for picking up objects Mary Anne Weeks Mayo was the production editor and proofreader and Audrey Doyle was the copyeditor for UML 2 0 in a Nutshell Phil Dangler and Colleen Gorman provided quality control Peter Ryan provided production assistance Lucie Haskins wrote the index Ellie Volckhausen designed the cover of this book based on a series design by Edie Freedman The cover image is a 19th century engraving from the Dover Pictorial Archive Karen Montgomery produced the cover layout with Adobe InDesign CS using Adobe s ITC Garamond font David Futato designed the interior layout This book was converted by Keith Fahlgren to FrameMaker 5 5 6 with a format conversion tool created by Erik Ray Jason McIntosh Neil Walls and Mike Sierra that uses Perl and XML technologies The text font is Linotype Birka the heading font is Adobe Myriad Condensed and the code font is LucasFont s TheSans Mono Condensed The illustrations that appear in the book were produced by Robert Romano Jessamyn Read and Lesley Borash using Macromedia FreeHand MX and Adobe Photoshop CS The tip and warning icons were drawn by Christopher Bing This colophon was written by Clairemarie Fisher O Leary This page was created by the un
69. without any special understanding Profiles are the standard mechanism to extend UML The profile mechanism exists within UML so models applying a profile are fully UML compatible This contrasts sharply with implementors extensions in loosely specified languages such as C in which the specification allows inline assembler and pragma statements making it virtually impossible to port C programs between processors or between different compilers A UML model applying a profile is UML and any UML tool can process it Although a plethora of dialects can fragment the universality of UML a dialect makes UML more useful And isn t that what it s all about A PREY NEKT W This page was created by the unregistered version of CHM To POF Converter by Theta Sottware PREY NEXT 1 11 1 Modeling and UML in Context Throughout the evolution of modeling practitioners implementors academics and other interested parties have found new and innovative ways to model and new disciplines to model It soon became apparent that the generality of the canonical UML was not concise enough for practitioners working full time in a particular language technology or platform such as ANSII C Struts or Net Moreover practitioners in similar disciplines such as process engineering with different fundamental structures and constraints found UML interesting but not quite appropriate They can better benefit from a UML like language other than UML i
70. 12 shows an example communication path linked to a component diagram This page was created by the unregistered version of CHM To POF Converter by Theta Sottware Figure 6 12 A communication path with a note attached See ImageRender Subsystem i Detailed Design for renderer interface WebServer ImageRenderer 7 VE While not officially part of the specification linking to l a diagram that explains the protocol spoken overa communication path can add clarity to your model A PREY NEKT W This page was created by the unregistered version of CHM To POF Converter by Theta Sottware PREY NEXT 1 6 3 Deployment The most important aspect of deployment diagrams is conveying the relationship between artifacts and the node s they execute on When you associate an artifact with a deployment target anything that can host an artifact such as a device or execution environment you deploy that artifact For example you may have an artifact named ccvalidator jar that represents the credit card validation subsystem of an application When you say ccvalidator jar executes on the node Appserver1 you have deployed the artifact 6 3 1 Deployment Representation UML provides several ways to show deployment You may show artifact deployment by simply drawing an artifact in the hosting node s cube Figure 6 13 shows an artifact named ccvalidator jar deployed to the device Appserver1 UML also allows you to show
71. 15 shows example postconditions linked to an operation Figure 2 15 Postconditions for operations RenderingEngine Fostcondition all normals are 1 updated and material properties updateLighting void have been cached franderFrame void posteandition nenvisible objects will be marked as culled 2 3 1 3 Body conditions An operation may have a bodyCondition that constrains the return value The bodyCondition is separate from the postcondition because the bodyCondition may be replaced by methods of subclasses of the owning class See Generalization for more information on subclasses For example a class named window may specify a body condition for a method named getSize that requires the length and width of a window be nonzero A subclass named squareWindow may provide its own body condition stating that the width must equal the height The bodyCondition is similar to the pre and postconditions in that the constraint may be expressed in natural language or in OCL See Constraints for more information Figure 2 16 shows an example of a bodyCondition on an operation Figure 2 16 Body conditions for operations Window bodyCondition Ls Rectangle width gt 0 amp amp Rectangle height gt 0 i ew i w SquareWindow bodyConditian IN SSS Rectangle width This page was created by the unregistered version of CHM To POF Converter by Theta Sottware 2 3 1 4 Query operations An operation
72. Administrator is the generic base actor and the lower three are specializations i Example System Mot A mag ee Startup System en A Ten ge J Shutdown 7 Database Administrator wa ra Replicate 5 a Databases i ee ne N r Backup User Data i Fi Deploy Web S Lu E Application ff Deployment Administrator Figure 7 12 Use case generalization zaa E The general use case is abstract it doesn t describe a particular _ functionality so the title is in italics Verity ie A sc aes 1g oie cave st ca os Ep La hk Passenger Identity _ al vo Check S A Verify 5 _ Passenger _ Passenger RFID Fingerprint Tag This page was created by the unregistered version of CHMI To POF Converter by Theta Sottware Include or Includes Often there is disagreement between UML modelers as to whether the proper keywords are include and extend Or includes and extends One would think the UML specification would put this to rest However as of the UML 2 0 specification the use case section states that the keywords are include and extend and then proceeds to show examples using includes and extends We think it s safe to say that either is acceptable Figure 7 13 Use case inclusion van a Order Item 5 lt lt include gt gt y i a J en _ _ ee a r Track Packages amp lt include gt gt f ee fai eect hs neh oem te ean The included u
73. CHM To POF Converter by Theta Sottware PREY NEXT 1 12 2 Sprawling Scope Figure 12 5 shows an example of a poorly focused sequence diagram Sequence diagrams risk taking on too many interactions at once This one shows the Struts interactions the application interactions and then the detailed workings of the Java libraries Figure 12 5 Sequence diagram of HTTP form processing spanning Struts application and java lang sd MultipleAbstractions I 1 l l l i doger 1 I 1 1 1 I 1 1 I 1 1 i processo l l ag ces aliden l i l process Valiaate i i i i i i ETE r D F k i i jralidate ActionMapping HitpServietHequest I Htolippertase l l l i 1 1 i getDefault I i new Locale l l l anguage country varient l l 1 am a I I l 1 i i i rollppert ase I L e And so on in excruciating detail i Elements at the high and low end of this diagram are clearly out of scope of the application One rarely cares how Struts as an off the shelf framework works It calls the application logic at the appropriate time Similarly just how the internals of the standard libraries carry out their obligations normally doesn t matter in terms of understanding the application Both the structure of HTTP request processing and the workings of Strings are God given as far as the application developer is concerned However by
74. DAnte laot ee a sy campai iF Me z eT Ma Pee Te ed a e E T M a Apt B Py 1 aii eaea gt i wo cepet T piam es A oar amam i TI ecim businessagent fy SS i alee aia n from ct a KAPTA F lt lt imolementetion gt gt a ee oN i i um cimpert gt gt e impl from businessa lt lt ompeaRT e a gt nay impl from entity Figure 12 8 addresses the issue of imports only Elements higher in the diagram depend on elements below No cycles exist You can absorb the meaning of the diagram quickly This page was created by the unregistered version of CHM To POF Converter by Theta Sottware Removing the imports from Figure 12 7 simplifies it more than you might imagine Instead of forming a graph like the imports the directives as shown in Figure 12 9 just link separate elements with target packages The noise of the import graph complicated a simple picture The complicated large diagram becomes a small diagram of four separate sections A PREY NEXT W This page was created by the unregistered version of CHM To POF Converter by Theta Sottware PREY NEXT 1 12 4 Besides UML UML provides description that s difficult to match with plain text Its formalism allows a few lines and boxes to unequivocally and immediately convey what would require time to assimilate from text The text replaced by diagrams would be at best dull and legalistic and at worst vague ambiguous and o
75. F Converter by Theta Sottware ad Account authentication Atheanhes MMainvtindow Aooounit oircdier i i i tees r ants E i mual Dan sfourd The deiak of ihe state are Ey petal y i s i expredeed in a separale slate i i diagram i i worfaC rad eniinsaocacrl i FR hah ce Serial esha ta eared esl E i e I pe I PE E pen Pri i Authenticated m I saPhoncHurmber 867 5307 p Figure 10 15 A state invariant using a note authenticated must be true when setPhoneNumber is called sd Account authentication creale Dan s3cur3 verifyCredentials account setPhoneNumber 867 5309 account Authenticated true PREY NEXT 1 This page was created by the unregistered version of CHM To POF Converter by Theta Sottware PREV NEXT 1 10 6 Event Occurrences Event occurrences are the smallest building blocks of interaction diagrams they represent moments in time when something happens Sending and receiving a message are the most common types of event occurrences though technically they can be any action associated with an object For example if object1 sends a message to object2 there are two event occurrences a message send and a message receive UML carefully defines interaction fragments as a set of event occurrences where ordering is significant because they represent events over time Each type of interaction diagram notation sequence communica
76. Figure 4 10 shows an explicitly typed port Figure 4 10 A port explicitly typed as a PacketPrioritizer Wireless Transceiver INetworklQ SG 80211Encoder Transmitter PacketPrioritizer In this diagram the port Transmitter is explicitly typed as a PacketPrioritizer The PacketPrioritizer class could do things like order high prionty messages before normal traffic Note that the PacketPrioritizer class must realize the INetworklO interface since that is a provided interface 4 1 3 Structured Classes and Properties This page was created by the unregistered version of CHM To POF Converter by Theta Sottware As described in Chapter 3 classifiers with whole part relationships typically use composition arrows to show their relationships In the context of composite structures UML 2 0 has defined the term property to describe the part piece of the whole part relationship For example in a graphical operating system an application may be made up of a main window and several buttons The buttons are a part of the application so that the whole part relationship between the application and the buttons can be shown using composition However the main window is shared with the operating system so the system can reposition the window or hide it as a result the operating system to window relationship is slightly weaker and is shown using association You can model the application window and button relationships as shown
77. I Since it s not part of the specification you have some wiggle room in terms of specifying the services offered by an execution environment However it may be helpful to stick to a list of provided interfaces 6 2 2 Devices Adevice is a specialization of a node that represents a physical machine capable of performing calculations There are no implied size restrictions on a device a device can be an embedded controller or the hardware the controller is installed in You show a device as a node with the stereotype device Figure 6 9 shows a node stereotyped as a device Figure 6 9 A node stereotyped as a device adevice Desktop Computer One of the more powerful features of devices is that they can be nested For example you can model a server with internal devices representing RAID controllers video cards etc A real world use of nested devices can be pixel and vertex shading code running on a video card represented as a device while the rest of the application runs on the machine s CPU Figure 6 10 shows an example of what this diagram might look like This page was created by the unregistered version of CHM To POF Converter by Theta Sottware Figure 6 10 A device the video card nested inside another device the desktop machine devices ot leak Sie Desktop Machine Shader code executes directly on the video card eGevrcer modeled as a device inside Video card 3 i of i
78. L specification states that the return type is optional If it s left off you can t assume anything about the return value of the operation or even if one exists properties Specifies constraints and properties associated with an operation These are optional if you don t use properties you don t show the curly braces See Operation Constraints for more information Parameter syntax elements are direction An optional part of the syntax that indicates how a parameter is used by an operation It is one of in inout out OF return in States that the parameter is passed to the operation by the caller inout states that the parameter is passed by the caller and is then possibly modified by the operation and passed back out out states that the parameter isn t set by the caller but is modified by the operation and is passed back out return indicates that the value set by the caller is passed back out as a return value parameter name type Is a noun or noun phrase naming the parameter Typically the parameter name starts with a lowercase letter with any subsequent words starting with a capital letter Is the type of the parameter This is typically another class interface collection or primitive type multiplicity Specifies how many instances of the parameter s type are present Can be absent meaning multiplicity of 1 a single integer a list of integers separated by commas or a range of values specified between square brac
79. ML though some effort has been made to make it human readable The OCL specification defines a simple language for writing constraints and expressions for elements in a model The OCL is often brought into play when you specify UML for a particular domain and need to restrict the allowable values for a parameter or object Appendix B is an overview of the OCL It is important to realize that while the specification is the definitive source of the formal definition of UML it is by no means the be all and end all of UML UML is designed to be extended and interpreted depending on the domain user and specific application There is enough wiggle room in the specification to fit a data center through it this is intentional For example there are typically two or more ways to represent a UML concept depending on what looks best in your diagram or what part of a concept you wish to emphasize You may choose to represent a particular element using an in house notation this is perfectly acceptable as far as UML is concerned However you must be careful when using nonstandard notation because part of the reason for using UML in the first place is to have a common representation when collaborating with other users a PREY NEXT This page was created by the unregistered version of CHM To POF Converter by Theta Sottware PREY NEXT 1 5 Putting UML to Work A UML model provides a view of a systemoften just one of many views needed to actu
80. Programmers will add custom code in protected areas Marks record both the updates and whether the marks originate from humans The unpolluted model be it PIM or PSM remains the same no matter how many downstream technologies there are The principle model remains unchanged regardless of whether a dependent model appears or disappears With the technology concerns partitioned from the principle model and each other the marking models can evolve independently of each other The technology functions can create default marks for elements Technical modelers who are experts in different fields elaborate their models separately A PREY NEKT W This page was created by the unregistered version of CHM To POF Converter by Theta Sottware PREY NEXT 1 A 4 Sewing the Models Together At any one time the many models are implicitly related For example a transformation function transforms the PIM and related marks from a marking model to create a PSM An MDA system of models probably has several PSMs each with its own marking model and at least one code model and likely its own marking model or handcoded extensions Over time the PIM will change as will the marks on it and on the PSM If the transformation function summarily overwrites existing marks explicitly updated by a modeler the effect of the marks disappears the modeler must reenter all again Clearly this is untenable On the other hand deletions from the PIM will remove
81. RL links in notes providing an easy way to navigate from one diagram to the next or to HTML documents etc This page was created by the unregistered version of CHM To POF Converter by Theta Sottware 1 6 4 Classifiers and Adornments The basic modeling element in UML is the classifier A classifier represents a group of things with common properties Remember at the level of classifier we are discussing UML itself not a particular system So when we Say a class is a classifier we mean that classes are things that have common properties methods attributes exceptions visibility etc A specific class such aS Automobile isn t a UML classifier it s an instance of a classifier or a class For the truly self abusing this is a glimpse into the UML meta model The full metamodel is quite complex and begins with the UML infrastructure specification A classifier s generic notation is a rectangle that can be divided into compartments to show classifier specific information such as operations attributes or state activities However many UML classifiers such as states activities objects etc have custom notations to help distinguish them visually A classifier can have several types of extra information attached to it via a UML mechanism calledadornments For example classifiers can have restrictions placed on the values a feature of the classifier can take In general constraints are written near the classifier or in
82. The compartment should be labeled with the realizations stereotype While this provides more detail than a black box view it is of limited use to component developers Figure 5 9 shows a component with a realizations compartment 5 2 2 2 Classifier dependencies To show the internals of a component you may show each classifier that realizes a component with a dependency on the component itself Note that the relationship between the classifiers and the component is a dependency relationship dashed line open arrow not a realization relationship This notation is useful Figure 5 9 Component with a realizations compartment This page was created by the unregistered version of CHM To POF Converter by Theta Sottware component a AccountManagement provided interfaces AccountServices required interfaces IdentityVerifier TransactionLogger arealizations Account OrderHistory artifacts acccountmanagement jar for identifying which classifiers make up a component but the focus of the diagram is still on the component as a whole Figure 5 10 shows a white box view of a component and its constituent classifiers Figure 5 10 White box view of AccountManagement wi an component AccountManagement Account A OrderHistory To shift the focus to the structure of the classifiers making up the component you may show the classifiers inside the component s rectangle This tends to have the
83. a specialized activity edge for control only elements called a control flow A control flow explicitly models control passing from one action to the next In practice however few people make the distinction between a generic activity edge and a control flow because the same notation is used for both 9 1 1 2 Object flows UML offers a data only activity edge called object flows Object flows add support for multicasting data token selection and transformation of tokens The notation for object flows is the same as that for a generic activity edge You can use an object flow to select certain tokens to flow from one activity to the next by providing a selection behavior You indicate a selection behavior by attaching a note to the object flow with the keyword selection and the behavior specified Figure 9 7 shows selecting the top candidates from potential new hires See Object Nodes for details on modeling objects Figure 9 7 Activity diagram where objects are selected based on a This page was created by the unregistered version of CHM To POF Converter by Theta Sottware selection behavior i interview Candidates selection Candidate expernience gt 5 years Candidates ex Interview Candidate You can assign behaviors to object flows that transform data passed along an edge however the behavior can t have any side effects on the original data You show transformation behaviors using a note attached to th
84. aces with the stereotype required interfaces Figure 5 7 shows the AccountManagement component using compartments to identify the provided and required interfaces UML suggests an additional compartment stereotyped artifacts that can show which artifacts actually implement a component typically one or more JARs DLLs etc Figure 5 8 shows a component with an artifact compartment Figure 5 7 Interface dependencies in compartment form component T AccountManagement provided interfaces AccountServices required interfaces IdentityVerifier TransactionLogger This page was created by the unregistered version of CHM To POF Converter by Theta Sottware Figure 5 8 A component with an artifacts compartment component T AccountManagement provided interfaces AccountServices required interfaces IdentityVerifier TransactionLogger artifacts acccountmanagement jar 5 2 2 White Box View In order to provide details about the implementation of a component UML defines a white box view The white box view shows exactly how a component realizes the interfaces it provides This is typically done using classes and is illustrated with a class diagram however a component may delegate some or all of its behavior to other components 5 2 2 1 Realization compartment The simplest white box view of a component is to add a compartment to the component and list the classifiers that realize it
85. ach operand can be interleaved according to the following rules 1 The ordering of the event occurrences within each operand is maintained For example if the first operand has lt stepl step2 step3 gt and the second operand is lt stepaA stepB stepc gt they may be interleaved to lt step1 stepA step2 stepB step3 stepC gt because the order is maintained but not to lt step1 step3 stepA step2 stepB stepC gt because the ordering of the event occurrences in the first operand is changed 2 If event occurrences in different operands occur on different lifelines they can be interleaved in any order 3 If event occurrences in different operands occur on the same lifeline they can be interleaved only in such a way that the event occurrences of the first operand execute before the occurrences of the second operand The interaction operator is seq For Figure 10 22 a weak Sequencing wouldn t change the way the calls are interleaved because the first operand has calls only to DesktopService and the second operand has calls only to the ApplicationService However if the sequence is changed so that the second operand includes a call to the DesktopService it isn t allowed to execute until all the calls to DesktopService in the first operand are complete Rule 3 Figure 10 23 shows this new sequence diagram Figure 10 23 Example of a weak sequencing operator This page was created by the unregistered version of CHM To POF Conv
86. aieUser username password E encryptString password rethievePassword usarname b creates alt encrypledPassword sloredPassword setValid true b satAccessPriviprivs Login success else set Valid false setReason invalid password E Login failed credentials Figure 10 35 shows the second diagram a sequence diagram that makes use of the Login sequence and defines continuations for Login success and Login failed If the correct password was entered the Login success continuation is executed otherwise the Login failed continuation is run Notice in this diagram that the continuation symbols are at the top of the interaction indicating that this diagram defines the behavior to execute Figure 10 35 Defining continuations in a sequence diagram This page was created by the unregistered version of CHM To POF Converter by Theta Sottware sd System Authentication J logStartup date Login L gin SUCCESS logSuccess credentials Usemame date Login failed logFailura credentials Reason Taken together these two diagrams are equivalent to Figure 10 36 A PREY NEKT W This page was created by the unregistered version of CHMI To POF Converter by Theta Sottware PREY NEXT W 10 12 Sequence Timing UML provides a notation to capture a specific time associated with an event occurrence You simply place a small horizontal line next to an event occu
87. aints This page was created by the unregistered version of CHM To POF Converter by Theta Sottware sd Mail server _ Transmitting 1 mh SE E Authenticated sendMail idle Login Disconnect I t t 104 0123 t very quickly becomes unreadable if a lot of messages are exchanged Figure 10 43 shows the Mailserver talking with a client Desktop Figure 10 43 Timing diagram with multiple lifelines and messages sd Mail server Pa 7 Transmitting uh d u B Authenticated vk idle a A Disconnect sendMail Disconnected aioe Login S Waiting _ 1 a m Sending data Connecting L 0123 t UML provides a variation on the timeline notation that simplifies diagrams by showing state names between two horizontal lines that cross when the state changes This notation makes it This page was created by the unregistered version of CHMI To POF Converter by Theta Sottware much easier to show multiple objects along a single timeline but it doesn t show the messages that trigger transitions Figure 10 44 shows the MailServer and Client lifelines progressing through state transitions Figure 10 44 Timing diagram using a simpler timeline notation sd Sending Mail MailServer Desktop A PREY NEKT W This page was created by the unregistered version of CHMI To POF Converter by Theta Sottware PREY NEXT 9 Chapter 11 Tagged Values Stereotypes a
88. al variables sequence diagrams can access data in the participants See Messages for examples a PREY NEKT W This page was created by the unregistered version of CHM To POF Converter by Theta Sottware PREY NEXT 1 10 3 Messages The focus of interaction diagrams is on the communication between lifelines This communication can take many different forms method calls sending a signal creating an instance destroying an object etc all of which are collectively called messages A message specifies the kind of communication its sender and its receiver For example a PoliceOfficer Class instantiating a SpeedingTicket class is represented as a message from an instance of PoliceOfficer to the newly created instance of SpeedingTicket The most common use of messages is to represent method calls between two objects When messages are used to indicate a method call you can show the parameters passed to the method in the message syntax The parameters should be one of the following e Attributes of the sending object e Constants e Symbolic values expressions showing what the legal values can be Explicit parameters of the enclosing interaction Attributes of the class owning the enclosing interaction The syntax for a message is atliipuLce ignal of operation mame arguments i To Cura values where attribute Is an optional part of the syntax that provides a shorthand way of showing that the return value from
89. ally build or document the complete system Users new to UML can fall into the trap of trying to model everything about their system with a single diagram and end up missing critical information Or at the other extreme they may try to incorporate every possible UML diagram into their model thereby overcomplicating things and creating a maintenance nightmare Becoming proficient with UML means understanding what each diagram has to offer and knowing when to apply it There will be many times when a concept could be expressed using any number of diagrams pick the one s that will mean the most to your users Each chapter of this book describes a type of diagram and gives examples of its use There are times when you may need to have more than one diagram to capture all the relevant details for a single part of your system For example you may need a statechart diagram to show how an embedded controller processes input from a user as well as a timing diagram to show how the controller interacts with the rest of the system as a result of that input You should also consider your audience when creating models A test engineer may not care about the low level implementation sequence diagram of a component only the external interfaces it offers component diagram Be sure to consider who will be using each diagram you produce and make it meaningful to that person 1 5 1 UML Profiles In addition to a variety of diagram types UML is designed to
90. along the communication link for each instance The advantage of this notation is that you can specify the attributes and operations that are involved in the collaboration remember you can leave off any attribute or operation that isn t directly related to the functionality you are expressing The disadvantage of this notation is that you don t model the direct communication paths between the various instances Figure 4 17 shows the Observer Observable pattern using this alternate notation Figure 4 17 The Observer Observable collaboration with details outside of the collaboration ellipse FileSaver Button fileName String buttonText String handleEvent e ObservableChanged void adidObserver o Observer void ramoveQbserver o Observer void notifyObservers void re Observer get Ea Observable Observer Observable The UML specification makes it clear that any classifier can be substituted for any member of the collaboration as long as they provide the appropriate attributes and operations to fulfill their role For example in the Observer Observable collaboration shown in Figure 4 17 the Observable must have a means of adding removing and notifying observers and the Observer must have a way to handle changes to the observable Any other classifier may be used in this collaboration as long as it can provide the message font attribute and the appropriate operation As mentioned earlier interfaces
91. als 10 13 1 Communication Diagrams Communication diagrams allow you to focus on the elements involved in interactions rather than the detailed sequencing and flow control allowed in sequence diagrams Most UML tools can automatically convert from a sequence diagram to a communication diagram however because communication diagrams aren t as expressive some information may be lost This page was created by the unregistered version of CHM To POF Converter by Theta Sottware When you re modeling with communication diagrams objects are represented by a rectangle and connections between objects are shown as a solid line Each message has a sequence number and a small arrow indicating the direction of the message along a given connection Communication diagrams can t show message overtaking see Figure 10 6 earlier in the chapter or interaction fragments Figure 10 38 shows a simple sequence diagram and the equivalent communication diagram The syntax for a message name is sequence number name recurrence or guara Figure 10 37 A sequence diagram with hard timing requirements sd Timed App roval verifyPayment orderinfo m now results l t 3 Figure 10 38 Example of a sequence diagram and its equivalent communication diagram sd Application slarup sd Application startup Mainida inapo Mainhindow i dando Soerti igen lnactAppSentingat 2i create ea kal DataStore aid i 7 y 3 listen
92. ami eika ja rence DerialRanson a re L i i 1 I i i i l Gumd conditions i 10 8 2 2 Option Options are interaction fragments that executes only if the guard condition is TRue The interaction operator is opt Conceptually options are similar to an alt operator with only one operand Figure 10 19 shows an option operator 10 8 2 3 Break Abreak indicates that the associated interaction fragment operand should execute and then terminate the enclosing interaction The interaction operator is break A break is similar to the following code block if quarcCondi tion return Figure 10 19 Example option operator This page was created by the unregistered version of CHM To POF Converter by Theta Sottware sd Authenticate User authenticateUser Admin qr tPassword creates ES be opt J curUser access Admin enableAdminCredentials true E credentials Figure 10 20 shows a break operator Figure 10 20 Example break operator ad Authenticate Waar Gmicesirator iia ESET EA gedentiais Auibanicatonsentca ian Waar Aer teers auilenitaleliser Admin grblPassord e actfales break password curser password i sollrvatidl centre credentials Se TI ue The steps after the break execute lo aieeaii Desa ahs p onky the suamitied password i GellrvalicUgarffatee o 5 matches the user s password l a i j i i l
93. ams from left to right with actors initiating use cases on the left and actors that receive use case results on the right However depending on the model or level of complexity it may make sense to group actors differently Figure 7 7 shows an actor communicating with a use case Figure 7 7 An actor associated to the Order Item use case Order Item J i hni _ Fo Customer Though not part of the official UML specification it is common to see directional arrows on association lines to indicate who initiates communication with whom Note that the arrows don t necessarily restrict the direction of information flow they simply point from the initiator to the receiver of the communication What happens after a use case begins execution is specified elsewhere see Use Cases Figure 7 8 shows two actors and a use case with directional associations Figure 7 8 An example of directed associations between actors and a use case This page was created by the unregistered version of CHM To POF Converter by Theta Sottware a ih epics a EEA 5 Withdraw Money is a use case from an ATM Since the ATM never initiates contact with the user the user always approaches the machine the association is directed toward the use case E mem p meme gt ee o e mr a r r r o o r a e r Sm p me p ee a gt Withd raw Money gt rh fo i i Bank Customer Regional Account Management System 7 2 2 System Bound
94. an attached note See the specific diagram types for details on what notation to use for a constraint when writing it near the classifier Another type of adornment is a stereotype Just as you would expect a stereotype is intended to give the reader a general idea of what a particular classifier represents Stereotypes are usually associated with implementation concepts such as TRansactional Or singleton though that isn t required by the UML specification A PREY NEXT W This page was created by the unregistered version of CHM To POF Converter by Theta Sottware PREY NEXT 1 1 7 UML Rules of Thumb While UML provides a common language for capturing functionality and design information it is deliberately open ended to allow for the flexibility needed to model different domains There are several rules of thumb to keep in mind when using UML Nearly everything in UML is optional UML provides a language to capture information that varies greatly depending on the domain of the problem In doing that there are often parts of UML that either don t apply to your particular problem or may not lend anything to the particular view you are trying to convey It is important to realize that you don t need to use every part of UML in every model you create Possibly even more importantly you don t need to use every allowable symbol for a diagram type in every diagram you create Show only what helps clarify the message you are trying
95. and is introduced here in its basic form If you re familiar with the fundamental UML concepts you can read this book s chapters in nearly any order However there is always a certain amount of overlap between chapters because some elements can appear on many diagrams Instead of repeating the information in each chapter we fully define elements and their associated stereotypes attributes etc the first time they are encountered and in subsequent chapters we provide detailed cross references back to the original definition when needed A PREY NEKT W This page was created by the unregistered version of CHM To POF Converter by Theta Sottware PREY NEXT W Typographic Conventions The following typographic conventions are used in this book Constant width Used in the text to refer to class names stereotypes and other elements taken from UML diagrams Constant width Italic Used in UML diagrams to indicate text that would be replaced by the user Italic Used when new terms are introduced and for URLs and file references Ellipses indicate nonessential material that has been omitted from a diagram for the sake of readability Indicates a tip suggestion or general note Indicates an aspect of UML that you must be particularly careful about using Note that UML makes frequent use of curly braces and guillemots When these are used in a syntax definition they are required by UML Nearly e
96. and the user management separate complex functions Just as with the class packages in Figure 3 8 you manage the use case packages to manage the project Remember that tracking use case packages tracks customer value 3 5 3 Directed Dependency Graphs Directed dependency graphs of the packages in a system reveal nonfunctional issues related to buildability testability and robustness they provide a guide for several roles in software development Figure 3 9 A set of functional major use case packages This page was created by the unregistered version of CHM To POF Converter by Theta Sottware CMs User A Management Admin Search p Feedback Surfer s View Content Management a Ne rtf editing x editing Editor Reporting When all the dependencies flow in one direction as in Figure 3 10 without any loops or cycles the graph is acyclic Acyclic graphs show a project in good health Directed dependency graphs can help you avoid problems with build scripts and project testing Looking at Figure 3 10 you can see that refactoring timer will invalidate testing and potentially break the build of visualizers threads controllers and top you should thus change the timer package with caution Directed dependency graphs can also help you divide project work among different staff members For example Figure 3 10 shows no dependencies between threads and visualizers Thus different groups of people can work o
97. aries By definition use cases capture the functionality of a particular subject Anything not realized by the subject is considered outside the system boundaries and should be modeled as an actor This technique is very useful in determining the scope and assignment of responsibilities when designing a system subsystem or component For example if while you are modeling an ATM system your design discussions digress into discussions of the details of the back end banking system a use case model with clearly defined system boundaries would identify the banking system as an actor and therefore outside the scope of the problem You represent system boundaries in a generic sense using a simple rectangle with the name of the system at the top Figure 7 9 shows the system boundaries for the ATM machine mentioned in the previous paragraph 7 2 3 Using Actors to Identify Functionality Actors don t need to have a one to one mapping to physical entities in fact they don t need to be physical entities at all UML allows for actors to represent roles of potential users of a system For example the system administrator may be the only physical user of a system but that administrator may wear many hats It may be helpful to view the system from the perspective of a database administrator backup administrator deployment administrator and so on By specifically identifying the various roles of actors that may use the system you can often discover use
98. arts of the decomposed element attached as smaller rectangles to the bottom of the head of the lifeline Each part gets its own lifeline This can be useful to show inner classes receiving or sending messages For example it is common practice in Java to declare an inner anonymous class to handle GUI events If you felt this was relevant to your interaction you can show this level of detail on the main interaction diagram However inline notation is relatively uncommon because decompositions are typically used to show a complex subinteraction that would clutter the top level diagram Figure 10 33 shows an example inline part decomposition where Mainwindow has two inner classes an anonymous WindowListener and an instance of an EventHandler named mEventHldr This page was created by the unregistered version of CHM To POF Converter by Theta Sottware Figure 10 33 Example of an inline decomposition sd Application Termination WindowListener I windowCiosingl E lj same oo mEventHidr EventHandler savePreferances closet escit 0 NEXT i This page was created by the unregistered version of CHM To POF Converter by Theta Sottware PREY NEXT 1 10 11 Continuations Typically used with interaction references continuations allow you to define different branches of an alternative interaction outside of the alternative itself Continuations are conceptually similar to named blocks of functionali
99. atherserver war be _ deployment spec weatherserver jar a web xml a PREY NEXT W This page was created by the unregistered version of CHM To POF Converter by Theta Sottware PREY NEXT 1 6 4 Variations on Deployment Diagrams Most of the time deployment diagrams are used for their intended purpose to show how an application is physically deployed Some modelers prefer to display the bare minimum just showing how many machines they will need and how they are supposed to talk Modelers often take liberties with the official notation and will specify minimum requirements for their machines as in Figure 6 18 Figure 6 18 A minimal deployment diagram webserver database WebServert DBServert numProcessors 2 minSpeed 2 4GHz raidLevel 1 Storage 1TB ObviouslyFigure 6 18 doesn t provide any information on actual software deployment Instead of focusing on the node s configuration you can focus on the software deployment configuration and specify details for executing your software as shown in Figure 6 19 Figure 6 19 Detailed application deployment diagram eho ApolicailonSonvar chewitie a sAile JDE pa a sejbcontainers aniba oe Jose Uae Account Accounthlanagenent provider MySQL UserAccountho Eieployineal apdes POLS Te ees Eo JNO Narnes myo Use Berrios For the sake of completeness we should mention that deployment diagrams have been used to sh
100. blocks Ideally the code model is compile ready It doesn t require any further human intervention Deployment should be automated In a mature MDA environment you can think of the code model as you would think of object files or class filesthey re just machine files opaque to mere mortals In reality MDA tools aren t mature Developers need to understand the technology so that they can debug the application or the deployment Developers need to load the source into IDEs and debug and deploy as normal Because little code is actually handwritten the dilemma is more to deploy correctly than to debug infrastructure These models can continue on to the right We can have a bytecode or link object model and beyond that a machine code model Software has matured so much that the vast majority of workers take those models for granted They just work If they don t we just replace them Figure A 1 shows a one tier PSM MDA doesn t restrict PSMs to one tier Each PSM addresses a different technological layer of a system If a particular technology lends itself to multiple layers of abstraction the PSM allows for that too The specific technologies and hence PSMs are defined by the MDA tool and the architecture it proposes As a business application developer you will have to work with that particular framework This page was created by the unregistered version of CHM To POF Converter by Theta Sottware PREY NEXT 1 A 3 Design Decision
101. cal representation greater than gt guard condition brackets and communication diagrams decision nodes and edges and interaction fragments and interaction operators and ordering syntax transitions 2nd guillemots 4 PREY NEXT W This page was created by the unregistered version of CHM To POF Converter by Theta Sottware PREY NEXT Index SYMBOL A B C D E F G H H J K M N O P Q R S CO U M W X high level transition HyperModel hyphen arguments and messages visibility 2nd Klima NEXT W This page was created by the unregistered version of CHM To POF Converter by Theta Sottware KESA NExT ah Index SYMBOL A B C D E F G H N J K M N O P Q R S CO U M W X if then else logical operator if then else endif keywords if then else endif operator ignore interaction operator 2nd implementation defined functionality and state machines and implementation diagrams implementation view implicit binding implies keyword implies logical operator 2nd 3rd importing packages 2nd in keyword inactive state include keyword includes keyword inclusion use case indirect substates inheritance classes and decomposition and init keyword initial nodes initial pseudostate 2nd inlined attributes inout keyword 2nd input pins expansion regions object nodes and representation streaming instances
102. cases that would have gone unnoticed Figure 7 10 shows a sample diagram containing three types of administrators and example use cases Figure 7 9 A use case diagram showing the system boundaries of an ATM System This page was created by the unregistered version of CHM To POF Converter by Theta Sottware a one Use Case Deposit Funds i Bank Client 7 Banking System a a m ef Check Balance Figure 7 10 An example of using specialized versions of an actor to help find required functionality Example System Py Re aa gp ki a 2 as ho Replicate Database KN Databases Administrator 5 See it is M ee t Backup User A 7 m Data ie RA S w F w Backup oe ee Startup Administrator i N ie ot i gt __ mme Shutdown lt p a r Ey Sm i a moh an 2 ie f 4 oe mt oe Fa Deploy Web k Deployment Application Administrator ie ea m m This page was created by the unregistered version of CHMI To POF Converter by Theta Sottware A PREY NEKT W This page was created by the unregistered version of CHM To POF Converter by Theta Sottware PREY NEXT 1 7 3 Advanced Use Case Modeling As it does for other classifiers UML provides mechanisms for reusing and adding on to use cases and actors You can expand an actor s capabilities or replace entire use cases using generalization You can factor out common elements of use cases using included u
103. cation of the activity diagram notation see Chapter 9 Interaction overview diagrams can help you visualize the overall flow of control through a diagram however they don t show detailed message information You can embed interactions or interaction occurrences inside an interaction overview diagram if it is helpful to see message details for a subset of the overall interaction Several sequence diagram concepts are supported in interaction overview diagrams Show combined fragments using a decision node and merge node Show parallel interactions by using a fork node and join node Show loops as cycles in the activity diagram Show names of the lifelines involved in an interaction using the keyword lifelines after the name of the interaction overview diagram followed by a comma delimited list of each lifeline s name including any colon separators that may or may not be part of the name Figure 10 39 is an interaction overview diagram showing a subset of the interaction shown in Figure 10 36 10 13 3 Timing Diagrams This page was created by the unregistered version of CHMI To POF Converter by Theta Sottware Timing diagrams are a special representation of interactions that focus on the specific timings of messages sent between objects You can use timing diagrams to show detailed time constraints on messages or to show when changes occur within lifelines with respect to time Timing diagrams are most often used with real time
104. ched to an operation using a dashed line Figure 2 18 shows an example of an operation that throws several exceptions Figure 2 18 A method that throws several exceptions Throws FileNotFoundException InvalidxXMLException and XMLParser ParserConfigurationException parseFile file File Object cme ponui NEA TEN eate aega FEA Since the class must be able to throw the exceptions specified it s not uncommon to see dependencies from the Class throwing the exceptions to the actual exception classes This page was created by the unregistered version of CHMI To POF Converter by Theta Sottware 2 3 2 Static Operations Operations typically specify behavior for an instance of a class However UML allows for an operation to specify behavior for the class itse f These operations are called static operations and are invoked directly on the class not on an instance Static operations are frequently used as utility operations that don t need to use the attributes of the owning class UML doesn t formally discuss the notation of these operations but it is typical to see them represented with the same convention as static attributes You indicate an operation is static by underlining the operation signature Figure 2 19 shows an example of a static operation Figure 2 19 A class with a static operation a PREY NEKT W This page was created by the unregistered version of CHM To POF Converter by Theta Sottware
105. cing a state invariant on your diagram after the initialization messages You show a boolean state invariant by simply placing the conditional inside curly braces lt on the lifeline of the object you want to check The invariant will be evaluated after any messages that come above it on the diagram Figure 10 13 shows a basic boolean invariant checking that an Account has been authenticated successfully Figure 10 13 A state invariant ensuring that the account is in the proper state before continuing sd Account authentication MainWindow creale Dan s3cur3 a verifyCredentials account account Authenticated true se PhoneNumber 867 5309 You show an invariant as a UML state by simply drawing the state symbol rectangle with rounded sides over the appropriate part of the lifeline of the object you want to check The actual information that is validated by the state can be expressed using the normal UML state diagram notation Figure 10 14 shows the same Account authentication using a UML state UML allows you to place the state invariant information inside a note and link it back to the lifeline though this doesn t tend to be as obvious to the reader as seeing a constraint directly on the lifeline in the proper sequence Figure 10 15 shows a state invariant using a note Figure 10 14 A state invariant using a real UML state This page was created by the unregistered version of CHM To PO
106. ck circle rather than a receiver s lifeline Figure 10 11 Shows a Workstation sending out a ping message that for some reason network failure isn t received Figure 10 11 An example message being lost This page was created by the unregistered version of CHM To POF Converter by Theta Sottware sd Unreceived ping sendPing id 1 a PREY NEXT W This page was created by the unregistered version of CHM To POF Converter by Theta Sottware PREY NEXT 10 4 Execution Occurrences You can show an object is involved in executing some type of action typically a method call for a measurable amount of time using an execution occurrence Execution occurrences are shown as gray or white rectangles on a lifeline In practice it is common to hear execution occurrences called focus of control because they indicate that an object is busy has the focus of the system for some period of time Figure 10 12 shows several execution occurrences in response to messages Figure 10 12 Several example execution occurrences sd Send Mail Note that the snitial sendMail message ls N iai kocalhlachime an open amow MailDeliveryAgent meaning it s i ee eee asynchronous The i eee sender does not wait ihe eta forthe remote host identitySender hastinta to receive thee mail B b fore continuing identifyRecipiants userinio ee 0tsts E m a kremiem sendBody message Execution
107. complexity as well Conceptually composite structure diagrams link class diagrams and component diagrams they don t emphasize the design detail that class diagrams do or the implementation detail that composite structures do Instead composite structures show how elements in the system combine to realize complex patterns Composite structures are discussed in Chapter 4 This page was created by the unregistered version of CHM To POF Converter by Theta Sottware Deployment diagrams Deployment diagrams show how your system is actually executed and assigned to various pieces of hardware You typically use deployment diagrams to show how components are configured at runtime Deployment diagrams are discussed in Chapter 6 Package diagrams Package diagrams are really special types of class diagrams They use the same notation but their focus is on how classes and interfaces are grouped together Package diagrams are discussed in Chapter 3 Object diagrams Object diagrams use the same syntax as class diagrams and show how actual instances of classes are related at a specific instance of time You use object diagrams to show Snapshots of the relationships in your system at runtime Object diagrams are discussed as part of class diagrams in Chapter 2 Behavioral diagrams focus on the behavior of elements in a system For example you can use behavioral diagrams to capture requirements operations and internal state changes for elements The
108. ct in C this would probably be a void in Java and C it would probably be an object However while you wanted your List class to be able to support any type of object you want all of the objects in a given list to be of the same type UML allows you to create and specify these kinds of abstractions using templates You can indicate that a class is a templated also called parameterized class by drawing a dashed rectangle in the upper right corner of the class For each element you would like to template you need to specify a name to act as a placeholder for the actual type Write the placeholder name in the rectangle Figure 2 34 shows an example of a List class that can Support any type Figure 2 34 A templated List class ElementType List yP elements ElementType This example uses ElementType as the name of the templated type for clarity In practice this is often abbreviated to just T You can have multiple templated types within a single class just separate the type names with a comma If you need to restrict the types the user may substitute show that with a colon followed by the type name Figure 2 35 shows a more complicated version of the List Class that requires a Sorter along with the type of object to store in the list Figure 2 35 A templated class with type restrictions This page was created by the unregistered version of CHM To POF Converter by Theta Sottware ElamentType SorterT
109. cture a one to one association versus a many to one association and they can be elaborated with explicit hints such as differentiating the three earlier cases At the level of code generation 3GLs have hints although they work at a much lower level of abstraction Programmers switch on code optimization or debugging information As a result the bytecode object code becomes vastly different with different performance characteristics Figure A 2 shows how MDA records design decisions as marks A transformation function uses related marks held in a subordinate marking model along with the principle model either PIM or PSM as the case may be to create the next more concrete model Partitioning the marks into separate marking models keeps the principle model pure and the marks related to different concerns separate from each other Were the downstream technology to change the related marks could be dropped without disturbing the principle model Figure A 2 Tightly coupled marking models keep technology decisions out of the principal models This page was created by the unregistered version of CHM To POF Converter by Theta Sottware WEB Marks Marks Bus Log Marks Persistence Marks DR Marks Model elaboration is the intentional enrichment of a generated model Generated models likely have need tailoring or optimization otherwise why have them Modelers assign or update the marks to control the transformation function
110. d 8 6 2 Deferred Events You can list events that should be deferred from dispatching while in a given state You show a deferred event by listing the event followed by a forward slash and the keyword defer within the state Figure 8 18 shows a state that defers the cancel event If the cancel event does fire it is held in the event pool until the state machine leaves this state This page was created by the unregistered version of CHMI To POF Converter by Theta Sottware Figure 8 18 State with deferred cancel event Encrypt Message entry start encryption cancel defer l If an event is triggered that doesn t cause a transition and it is on the deferred list it will be held in an event pool while nondeferred events are dispatched The event will be held in the pool until the state machine enters a state in which the event is no longer deferred or in which the event would cause a transition The event is then dispatched To clarify events that cause a transition can t be deferred If the state machine enters a state that doesn t defer an event and the event doesn t cause a transition the event is lost PREY NEXT This page was created by the unregistered version of CHM To POF Converter by Theta Sottware PREY NEXT 1 8 7 Variations on Statechart Diagrams In addition to modeling behavior and protocols statecharts have been used to capture real time system behavior As they do with many applications o
111. d with more than one TaxPayer but by using qualifiers you indicate that a socialSecurityNumber uniquely identifies a single TaxPayer within the IRS a PREY NEKT W This page was created by the unregistered version of CHM To POF Converter by Theta Sottware PREY NEXT 1 2 Interfaces Aninterface is a classifier that has declarations of properties and methods but no implementations You can use interfaces to group common elements between classifiers and provide a contract a classifier that provides an implementation of an interface must obey For example you can create an interface named Sortable that has one operation named comesBefore Any class that realizes the Sortable interface must provide an implementation of comesBefore Some modern languages such as C don t support the concept of interfaces UML interfaces are typically represented as pure abstract classes Other languages such as Java do support interfaces but don t allow them to have properties The moral is that you should be aware of how your model is going to be implemented when modeling your system There are two representations for an interface which one you should use depends on what you re trying to show The first representation is the standard UML classifier notation with the stereotype interface Figure 2 31 shows the Sortable interface Figure 2 31 The Sortable interface interface sortable comesBefore object Sortable boolean
112. defined post keyword postconditions actions and activities and naming OCL expressions and OCL properties and operation constraints protocol state machines pound sign 2nd pre keyword preconditions actions and activities and naming OCL expressions and operation constraints protocol state machines primary keys 2nd private visibility 2nd 3rd process component process view process relevant data profiles constraints and defined 2nd overview tools and uses for programming languages code model efficiency of importing packages interface support multiple inheritance support OCL logic rules PIM and query only UML and projects structuring properties artifacts associations and attribute 2nd composite structures and dots and interfaces and 2nd OCL properties element operations property strings element protected visibility 2nd protocol keyword protocol state machines defined This page was created by the unregistered version of CHMI To POF Converter by Theta Sottware overview 2nd real time systems and provided interfaces assembly connector and compartments components and ports and 2nd pseudostates connection points and 2nd overview state machine extensions state machines and transitions PSM Platform Specific Model 2nd public visibility 2nd 3rd Fa PREY NEXT This page was created by the unregistered version of CHM To POF Converter by Theta Sottware
113. deler doesn t capture the internal states of a system or if the implementation is simple enough that there are no additional internal states the state machine can wind up being a model of the protocol Figure 8 19 is closer to a protocol state machine than a detailed implementation model each state in the figure can be represented by one or more smaller internal states in a real implementation However according to the strict definition of protocol state machines entry activities can t be used so Figure 8 19 isn t tagged with the protocol tag This page was created by the unregistered version of CHMI To POF Converter by Theta Sottware PREY NEXT W Chapter 9 Activity Diagrams Activity modeling focuses on the execution and flow of the behavior of a system rather than how it is assembled Possibly more than any other UML diagram activity diagrams apply to much more than just software modeling They are applicable to just about any type of behavioral modeling for example business processes software processes or workflows Activity diagrams capture activities that are made up of smaller actions When used for software modeling activities typically represent a behavior invoked as a result of a method call When used for business modeling activities may be triggered by external events such as an order being placed or internal events such as a timer to trigger the payroll process on Friday afternoons Activity diagrams have unde
114. diagram For example you can have two partitions that indicate the business department responsible for particular functionality and two partitions indicating the geographic location of the departments These are called multidimensional partitions and are new to UML 2 0 You can show a multidimensional partition by using both horizontal and vertical intersecting partitions as shown in Figure 9 29 9 4 2 Exception Handling UML 2 0 activity diagrams provide support for modeling exception handling An exception is an error condition that occurs during the execution of an activity An exception is said to be thrown by the source of the error and caught when it is handled You can specify that an action can catch an exception by defining an exception handler The exception handler defines the type of exception and a behavior to execute when that particular exception is caught Figure 9 28 Simple attribute partition example This page was created by the unregistered version of CHMI To POF Converter by Theta Sottware Handle Expired Password z Force Password Change Reactivate Account 5 i i T Z S 2 3 a 3 Change Password fa Figure 9 29 Activity diagram with multidimensional partitions Hive Employee Washinglon DG Austin TX Dulles w p Subm Employed D i Pr P Banaka nkmn Lp r a Confirm Employoo TVR Garpacny l Abo Daan ap ai E i Bo Up Laar Acna
115. different internal elements However it doesn t specify what happens when communication is received at that port this is left up to the modeler Some possible solutions are to forward the communication toall connectors forward based on priority forward on a round robin basis or simply randomly choose a connector Regardless of your decision be sure to document it in your model probably using a note attached to the port Figure 4 8 shows an example of using a port with many connectors Figure 4 8 A port with multiple connectors Accountservices Lk Communication to the T J In this example there are two instances of OrderServices port is the OrderProcessingimpt Serveri and forwarded in a round robin Semer According to the note when dala fashion to the servers Servact is reaceved at the OrderSenices port it is l 4 a in forwarded to one of the two servers ior l OES Se OrderServices P ti Le Fe 4 1 2 4 Port multiplicity A classifier may specify multiplicity for a port like any other element Simply place the desired number of port instances in brackets after the port name and type if present When the classifier is instantiated the associated ports are instantiated as well These are called interaction points and can be uniquely identified by the classifier For example if your classifier has two ports one with provided interfaces that offer anonymous access to data and one with a provided interface that offers aut
116. dostate or exited because of the completion of the submachine you don t need to show explicit entry exit points The state machine shown in Figure 8 10 uses the default initial pseudostate and two different exit points A submachine state machine may be used multiple times within a containing state machine and different references to the submachine may show different entry exit points based on what is relevant to the current submachine state For clarity you may use the same composite icon to show that the referenced submachine is defined elsewhere in the model Figure 8 11 shows a submachine state with the composite icon Figure 8 11 A submachine state showing the composite icon Verify Credit Card CreditCardValidationSM _ F 8 2 3 Transitions A transition shows the relationship or path between two states or pseudostates It represents the actual change in the configuration of a state machine as it heads from one state to the next Each transition can have a guard condition that indicates if the transition can even be considered enabled a trigger that causes the transition to execute if it is enabled and any effect the transition may have when it occurs Transitions are shown as a line between two states with an arrowhead pointing to the destination state You specify the details of the transition using the following syntax This page was created by the unregistered version of CHM To POF Converter by Theta Sottware trig
117. e 9 36 shows the same audio encoder but is drawn using the streaming shorthand notation This page was created by the unregistered version of CHMI To POF Converter by Theta Sottware Figure 9 36 Activity diagram with streaming actions using shorthand notation 7 Audio Encoder Analog Waveform Bitstream Analog Audio gt D A Converter E n Encode Audio Note that the stream keyword is not used in the shorthand notation Instead fill in the input or output pins The UML specification expects that vendors will provide base classes for domain specific activities users can employ to model an application specific problem You may also mark a set of actions as streaming using an expansion region See Expansion Regions for more information 9 4 6 Interruptible Activity Regions You can mark that a region of your activity diagram can support termination of the tokens and processing by marking it as an interruptible activity region For example you may want to make a potentially long running database query as interruptible so that the user can terminate things if he doesn t want to wait for the results You indicate a region is interruptible by surrounding the relevant nodes with a dashed rectangle that has rounded corners You indicate how the region can be interrupted by drawing a lightning bolt style edge leaving the region and connecting to the node that assumes execution If a token leaves the region over this edge all other
118. e a direct link between the association ends the implementation may require you to traverse through the association class to get to the opposite end of the link In other words FootballPlayer may not have a direct reference to FootballLeague but may have a reference toFootballTeam instead FootballTeam would then have a reference to FootballLeague How the relationships are constructed is a matter of implementation choices however the fundamental concept of an association class is unchanged 2 6 7 Association Qualifiers Relationships between elements are often keyed or indexed by some other value For example a bank patron may be identified by her account number or a tax payer by his Social Security number UML provides association gualifiers to capture such information A qualifier is typically an attribute of the target element though this isn t required You show a qualifier by placing a small rectangle between the association and the source element Draw the name of the qualifier usually the name of an attribute in the rectangle Figure 2 30 shows the relationship between the IRS and a taxpayer qualified by the taxpayer s Social Security number Figure 2 30 An association qualifier This page was created by the unregistered version of CHM To POF Converter by Theta Sottware IRS social Secunty Number TaxPayer Notice that the multiplicity between the association qualifier and TaxPayer is 1 Obviously the IRS is associate
119. e can be either active or inactive A state is considered active as soon as it is entered because of some transition Similarly a state is considered inactive immediately after leaving the state UML defines three types of states Simple states Simplest of all states they have no substates All the example states used so far in this section are simple states Composite states Have one or more regions for substates A composite state with two or more regions is calledorthogonal This page was created by the unregistered version of CHM To POF Converter by Theta Sottware Submachine states Semantically equivalent to composite states submachine states have substates that are contained within a substate machine Unlike composite states submachine states are intended to group states so you can reuse them Composite states are typically specific to the current state machine Composite and submachine states are explained in more detail in the following subsections 8 2 1 Composite States A composite state is a state with one or more regions A region is simply a container for substates A composite state with two or more regions is called orthogonal A composite state may have an additional compartment called the decomposition compartment A decomposition compartment is a detailed view of the composite state where you can show a composite state s regions substates and transitions Figure 8 6 shows a composite state with a singl
120. e familiar with previous versions of UML you can probably skim this chapter If you don t have a strong background in UML you should definitely start here The next set of chapters cover what is called static modeling in UML Static modeling captures the physical structure of a piece of software as much as software has a physical structure For example what operations and attributes a class contains what interfaces a class realizes or what packages contain all this mess The static modeling chapters include Chapter 2 Class Diagrams This chapter introduces the class diagram It discusses the various elements that can be used on a class diagram what they represent and how to extend them Because class diagrams are often a centerpiece of a UML model you should know this chapter inside and out The last part of the chapter discusses how class diagrams fit into the overall UML model and how the diagrams are typically mapped to code Chapter 3 Package Diagrams This chapter introduces packages and grouping within a UML model Chapter 4 Composite Structures This chapter introduces the new UML 2 0 concept of composite structures Composite structures are specifically designed to represent patterns and are a major new component to the modeling language Chapter 5 Component Diagrams This chapter introduces components and the component diagram Topics such as the stereotypes used in component diagrams relationships between componen
121. e for allowing the use of XML examples Thanks also to Derek McKee of Mindset Corporation for the use of LamMDA examples Finally I d like to especially thank Jonathan Gennick for his depth of patience a PREY NEKT W This page was created by the unregistered version of CHMI To POF Converter by Theta Sottware PREY NEXT Chapter 1 Fundamentals of UML On the surface the Unified Modeling Language UML is a visual language for capturing software designs and patterns Dig a little deeper though and you ll find that UML can be applied to quite a few different areas and can capture and communicate everything from company organization to business processes to distributed enterprise software It is intended to be a common way of capturing and expressing relationships behaviors and high level ideas in a notation that s easy to learn and efficient to write UML is visual just about everything in it has a graphical representation Throughout this book we ll discuss the meaning behind the various UML elements as well as their representations A PRE NEKT W This page was created by the unregistered version of CHM To POF Converter by Theta Sottware PREY NEXT 1 1 1 Getting Started If you re new to UML you should be sure to read this chapter all the way through to get acquainted with the basic terminology used throughout the book If you are a developer class diagrams tend to be the simplest diagrams to start with because they
122. e object flow Label the note with the keyword TRansformation and write the behavior under the label Figure 9 8 shows an example of a transformation behavior that extracts student identification from course registrations to verify that the student s account is fully paid Object flows allow you to specify sending data to multiple instances of a receiver using multicasting For example if you are modeling a bidding process you can show a Request for Proposal RFP being sent to multiple vendors and their responses being received by your activity You show sending data to multiple receivers by labeling an object flow with the keyword multicast and you show data being received from multiple senders by labeling an object flow with the keyword multireceive Figure 9 9 shows an activity diagram modeling an RFP process There are times when an action may accept more than one type of valid input to begin execution For example a human resources action named Adjust Salary May require an Employee object and either a New Hire Document OF Yearly Performance Review Document but not both You can show groups and alternatives for input pins see Pins under Object Nodes by using parameter sets A parameter set groups one or more pins and indicates that they are all that are needed for starting or finishing an action An action can use input pins only from one parameter set for any given execution and likewise output on only one output parameter
123. e of the interaction operand critical This and other interaction operators are described in Interaction Operators Figure 10 17 An example combined fragment sd Perfomn DA backup inkereedion i upie mortes Starter tale backup jee ea aed a i DNE i j Combined fragment i gt a gt j ee ee oe e colbcal i ead ate Data a _ Fa vere Tabb Daal La wpime Tabe Sau Archived i E uote Progress Conta ied table backup Depending on the interaction operator you choose for a combined fragment you may need to specify multiple operands You separate operands using a horizontal dashed line across the rectangle Messages aren t permitted to cross between interaction fragments The order of the operands is significant for some of the operators so always read a combined fragment from This page was created by the unregistered version of CHMI To POF Converter by Theta Sottware top to bottom See Figure 10 18 for an example of multiple operands 10 8 1 Guard Conditions An interaction fragment may have a guard condition that states when the fragment is valid can be executed as in an if then condition The syntax for a guard condition is simply boolean expression You show a guard condition directly above the first event occurrence in the relevant interaction fragment and on top of the associated lifeline A guard condition can refe
124. e region Figure 8 6 A composite state with one region a Dispensing Rotating drink rack entry start drink rack rotation do rotate drink rack current drink preferred drink stop drink rack rotation Y a f Releasing drink entry release current drink A Fi IR sensor tripped Y n Qpening dispenser door entry release dispenser door exit close dispenser door IR sensor cleared r hy rj 1 7 i ia 4 pEi r This page was created by the unregistered version of CHM To POF Converter by Theta Sottware You may hide the decomposition compartment to increase the clarity of a diagram If you hide the compartment you can use the composite icon to indicate that the state s decomposition isn t shown on this diagram Figure 8 7 shows a composite state with the decomposition compartment hidden Figure 8 7 Composite state with composite icon Dispensing l J You may place states within a region of a composite state to represent internal substates A substate that isn t contained in another state is called a direct substate and a substate contained within other substates resulting in recursive composite states is called an indirect substate A composite state is considered active when the state machine is in any of the composite s substates When a composite state is active the tree of active states starting with the composite state itself and working do
125. ec gt gt stereotype This page was created by the unregistered version of CHMI To POF Converter by Theta Sottware lt lt destroy gt gt message lt lt device gt gt stereotype lt lt exception gt gt keyword lt lt external gt gt keyword lt lt import gt gt keyword lt lt interface gt gt keyword lt lt iterative gt gt keyword lt lt J2EE Containers gt gt stereotype lt lt localPostcondition gt gt keyword lt lt localPrecondition gt gt keyword lt lt merge gt gt keyword lt lt multicast gt gt keyword lt lt multireceive gt gt keyword lt lt OS gt gt stereotype lt lt parallel gt gt keyword lt lt postcondition gt gt keyword lt lt precondition gt gt keyword lt lt provided interfaces gt gt keyword lt lt realizations gt gt keyword lt lt required interfaces gt gt keyword lt lt selection gt gt keyword 2nd lt lt singleton gt gt lt lt transformation gt gt keyword equals sign 2nd gt angle brackets gt greater than pre keyword pre operator brackets 2nd __ underscore protocol tag pipe tilde 2nd guillemots A PREY NEKT W This page was created by the unregistered version of CHM To POF Converter by Theta Sottware 4 PREV NEXT Index SYMBOL A B C D E E G H U J K M N O P Q R S L Y M W X abs operation abstract classes interfaces as naming convention
126. ecifies the name of the instance involved in the interaction selector Is an optional part of the name that can identify which particular instance in a multivalued element is to be used for example which EventHandler in an array of EventHandlers Class name Is the name of the type of this participant decomposition Is an optional part of the name that can point to another interaction diagram that shows details of how this participant processes the messages it receives see Decomposition UML defines a reserved participant name self that indicates the participant is the classifier that owns this interaction diagram Figure 10 2 shows a trivial interaction diagram with two participants and a message between them Figure 10 2 A trivial sequence diagram with two participants This page was created by the unregistered version of CHM To POF Converter by Theta Sottware sd Storing an item in a HashMap E E ier E aed Cit elt nt mee oh This diagram has two participants one a ae l named GuyWhoNeedsToSaveSomething i GuyWhoNeedsTo 1 and one unnamed l SaveSomething HashMap A SE Sed eee ee ay eed ee aa oe E Object put key valus You can show the destruction of a participant during an interaction using a stop symbol Typically this is preceded by a destroy message to the object though that isn t strictly necessary Place an X at the bottom of the lifeline where the object ceases to exist Figure 10
127. ecision input behavior this functionality is allowed to evaluate the data arriving at the node and offers output for the guard conditions to evaluate The behavior is not allowed to have any side effects when executing since it can Figure 9 19 Activity diagram with a decision node Wrap Presents recipient isn t local i oe Address Shipping Label Christmas Presents Wrap Present gt lt F Place Under Tree recipient is local t P be executed multiple times for the same data input once for each edge that needs to be tested You show decision input behavior in a note labeled with the keyword decisionInput Figure 9 20 shows an activity diagram that checks to see if a newly authenticated user is the 100th user and should therefore be prompted to take a survey This page was created by the unregistered version of CHM To POF Converter by Theta Sottware Figure 9 20 Decision node with an input behavior Login to System a true o gt show Customer Survey Verify User lt gt Show Main Menu false P k adecisioninput numLogins 100 Amerge node is effectively the opposite of a decision node it brings together alternate flows into a single output flow It doesn t synchronize multiple concurrent flows see Fork and join nodes for concurrency support A merge node has multiple incoming edges and a single outgoing edge A merge node simply takes any tokens offered o
128. el this line with the keyword merge Figure 3 7 shows an example of merging two packages Figure 3 7 ProtocolStateMachines merging the elements from BehavioralStateMachines so it can add to the contained classes ProtocolState _ BehavioralState Machines merge Machines The rules for package merge are e Private members of a package aren t merged with anything e Classes in the package performing the merge that have the same name and type as classes in the merged package s get a generalization relationship to the merged class es Note that this can result in multiple inheritance but UML allows this e You can still reference any of the original classes by explicitly scoping the class using the original package name e Classes that exist only in the merged package or the merging package remain unchanged and are added to the merging package e Subpackages within the merged package are added to the merging package if they don t already exist This page was created by the unregistered version of CHM To POF Converter by Theta Sottware e If a subpackage with the same name already exists in the merging package another merge is started between the two subpackages e Any package imports from the merged package become package imports from the merging package Elements that are imported aren t merged i e aren t given generalization relationships If an imported element conflicts with an element in the merging pac
129. elopment and business and data modeling In other disciplines a new metamodel can be created from adding dropping and reorganizing UML packages to allow for a concise modeling of the discipline More formally as seen in Figure 11 2 UML builds on its core infrastructure MOF MOF can be used by other modeling languages for other uses The core UML can be used as is for building models directly or it can be constrained by one or more profiles Each level is a level of abstraction The levels are named MO M1 M2 and M3 as they become more abstract MO is the concrete systemthe code M1 is the model of the system of which MO is just one realization the model where designers work M2 is the language used to describe the model in this case UML and optionally the profiles M3 MOF is the language used to describe UML and any similar modeling languages MOF is far beyond the scope of this book Suffice it to say though that MOF provides a formal infrastructure to UML which explains why stereotypes resemble classes and components and why tagged values resemble enumerations and attributes The Mi model specifying your application may have profiles associated with it The architect determines the profiles to use according to the platform language and tools available Deciding the profile effectively freezes the M2 layer As an application modeler you model classes attributes states and all the other UML elements You don t define new ste
130. encies risk technology building testing and OO principles Project managers think in terms of risk tracking resources need ownership required skills and delivery Although all issues are important and good packaging recognizes its responsibility to all needs architects tend to identify top level packaging with an eye on the control functions of project management For example a project manager might draw a package diagram for a web application such as that shown in Figure 3 8 Figure 3 8 Top level packages defining a web application This page was created by the unregistered version of CHM To POF Converter by Theta Sottware gt web rtf editing x editing user search editing database The diagram in Figure 3 8 carries very little meaning by itself It must be accompanied by an auxiliary textual document that describes the basis for the packaging Such a document might for example contain a list as follows web Requires special skills HTML CSS and Struts a presentation technology most dependencies database Requires database management and modeling skills most independent fewest dependencies user To be built off site by a remote team search Requires familiarity with search engine technology and techniques self contained subsystem editing Comprises the basic editing features to be delivered in the first release different skills and different team rtf editing This page was created
131. ent in a node edevices AppServerl adevices bates J2EE Containers Appservert JBoss i aJZEE Containers eee ee e m JBoss You show the relationship between the hosting node and the execution environment using a composilion i relationship Note that since ihere is mo arrow on this line the relatonship is bidirectional 6 2 1 1 Execution environment stereotypes The UML specification intends for people to create UML 2 0 Profiles that define unique execution environments and their required deployment specifications These unique environments are each given their own stereotype and are applied to nodes when appropriate For example the UML specification suggests stereotypes such aS 0S database system and J2EE Container 6 2 1 2 Explicit services Usually any services offered by the execution environment are implicit in the stereotype used However you may explicitly show the services if that increases the readability of your This page was created by the unregistered version of CHM To POF Converter by Theta Sottware model The specification doesn t state how to represent explicit services but suggests listing them in a compartment within the execution environment Figure 6 8 shows an example execution environment with an explicit list of the services offered Figure 6 8 An execution environment with explicit services JZEE Containers JBoss services Persistence Transaction JMX JND
132. er by Theta Sottware Index SYMBOL A B C D E F G H H J K M N O P Q R S CO U M W X XML documents 2nd XML Structure Definition Language XSDL xor constraint xor logical operator 2nd XSDL XML Structure Definition Language
133. erter by Theta Sottware sd Desktop Startup Sequence seq shawLoginSplashScroent loadColorF refs m sorniconsi o hideLoginSplashScreent t E startF rewal Searvineal D e iea waea a E startSystemLoginApost Since tha maximize indow call gt B invoked on the DeskiopService a weak sequencing forces this call lo execute aller the calls to startUserLoginAppsi QesktepService from the first l i maximine Window Wweloome Applicaton i startSyaiem TrayAppat operand be me _ lt oS oo lt 10 8 2 6 Strict sequencing Strict sequencing indicates that the ordering of the event occurrences is significant across lifelines not just within the same lifeline as with weak sequencing The operands of a strict sequence must be executed in order from top to bottom The interaction operator is strict 10 8 2 7 Negative Negative indicates a set of event occurrences that are considered invalid meaning the interaction can never execute this particular path The interaction operator is neg This particular operator is rarely used but can convey that the particular sequence isn t permitted Figure 10 24 shows an example of an invalid call to a Graphics2pD object In this diagram a UML note indicates to the reader why the particular sequence is invalid 10 8 2 8 Critical region Acritical region indicates that the given event occurrences must be treated as an a
134. es just about everything in UML You show an artifact using the classifier rectangle with a dog eared paper in the upper right Figure 6 1 shows a basic artifact Figure 6 1 A simple artifact k logging jar UML allows artifacts to have properties and operations that manipulate the artifact These are most commonly used when an artifact represents a set of configurable options For example deployment specifications which represent configuration settings for deployed artifacts frequently use attributes to represent the allowed settings see Deployment Specifications Figure 6 2 shows an artifact with attributes Figure 6 2 An artifact with attributes logging jar Fon ng reentrant boolean numLoggers int 1 N oe AE SE PIRNER The logging jar artifact has two attributes The numLoggers attribute has a default value of 1 6 1 1 Artifact Instances Like nearly all other UML classifiers artifacts are really types This means that technically a physical DLL on a node is an instance of an artifact For example you can have an artifact This page was created by the unregistered version of CHM To POF Converter by Theta Sottware namedlogging jar that represents your logging framework implementation However you may have several web applications installed on a server each with their own copy of logging jar Each physical copy is an instance of the original artifact You show an instance of an ar
135. es concise expression moving the models further from their domains Instead of burdening UML with complexity or overwhelming it with abstraction UML s authors factored out everything specific to domains and platforms They created the profile extension mechanism to address the specific needs of specific application domains CORBA models for example would be concise and precise but would not influence a Net model Although UML cousins such as the Object Management Group s Software Process Engineering Metamodel SPEM and SysML org s Systems Modeling Language SysML borrow much structure from UML they also discard parts that bring no value to their disciplines SPEM best known as the basis for the Rational Unified Process RUP describes the process of software development in terms of process roles work products and activities Between a software application and the process of software development the fundamental structure and relationships between the parts change Although much is similar in the statechart class sequence package use case and activity diagrams for example there is no implementation or component diagram or interface A profile specializing a few elements works but it must exclude or constrain many basic concepts MOF factors out the structure of UML itself for reuse in other disciplines Using MOF SPEM and SysML become metamodels at the same level as UML UML remained close to the disciplines of general software dev
136. ess this constraint in a note if the inlined attribute notation was used 2 2 3 Derived Attributes The derived notation which is the leading forward slash can be used as an indicator to the implementer that the attribute may not be strictly necessary For example let s say you modeled a bank account with a simple class named Account This class stores the current balance as a floating point number named balance To keep track of whether this account is overdrawn you add a boolean named overdrawn Whether the account is overdrawn is really based on whether the balance is positive not the boolean you added You can indicate this to the developer by showing that overdrawn is a derived attribute with its state based on balance Figure 2 6 shows how balance and overdrawn can be represented using a note to convey the relationship Figure 2 6 Derived attribute Overdrawn true it balance lt 0 Account balance float foverdrawn boolean The UML specification notes that a derived attribute is typically readonly meaning a user may not modify the value However if a user is permitted to modify the value the class is expected to update the source of the derived information appropriately 2 2 4 Attribute Multiplicity The multiplicity of an attribute specifies how many instances of the attribute s type are created when the owning class is instantiated For example our car class will likely have four wheels so the mult
137. essed This doesn t mean that all ao activities see Activities are complete just that the state machine is in a well defined condition with entry and exit activities completed This is called run to completion by the UML specification After an event is dispatched if no transitions are enabled and the event isn t deferred see Deferred Events the event is discarded and the next event can be processed If an event does trigger one or more transitions such as in the case of orthogonal states see Composite States the order in which the transitions are fired isn t specified by UML Once all transitions have been fired the event is considered complete If a synchronous activity is triggered by a transition the event processing isn t complete until the invoked object has finished its run to completion step When dispatching events UML allows for transitions to conflict However only one out of a set of conflicting transitions is allowed to execute If an event triggers two different transitions from the same state the state machine must select only one transition to execute The following rules determine which transition executes e A transition starting from a substate has higher priority than a transition from any of its containing states and therefore is executed e Transitions from an orthogonal state are considered to have the same priority assuming they are at the same level so the first transition encountered is execute
138. extra information attached to it using conveniently enough attributes Modelers typically represent XML elements as classes and XSDL attributes as UML attributes Each element is linked to the next using composition arrows Multiplicity specifications on the relationships show how many times one element appears within another Example 2 1 is a sample XML document that describes a piece of equipment Example 2 1 A sample XML document lt xml version 1 0 encoding UTF 8 gt lt equipmentlist xmlns xsi http www w3 org 2001 XMLSchema instance xsi noNamespaceSchemaLocation equipment xsd gt lt equipment equipmentid H 1 gt lt shortname gt lt langstring lang en gt Hammer lt langstring gt lt shortname gt lt technicalcontact gt lt cContact gt lt name gt Ron lt name gt lt telephone gt 555 1212 lt telephone gt lt CoOncacl gt lt technicalcontact gt lt trainingcontact gt lt cContact gt lt name gt Joe lt name gt lt email gt joe home com lt email gt lt Contact gt This page was created by the unregistered version of CHMI To POF Converter by Theta Sottware lt trainingcontact gt lt equipment gt lt equipmentlist gt Example 2 2 is the XSDL that describes the XML document Example 2 2 XML schema describing Example 2 1 lt xml version 1 0 encoding ISO 8859 1 gt lt xs schema xmlns xs http www w3 org 2001 XMLSchema elementFormDefault qualified gt a Class CONE eet e
139. f UML diagrams real time system modelers frequently use tagged values and constraints to customize the syntax for their organization however almost all real time diagrams include some notation to indicate time A common notation is to use the keyword after to indicate a maximum allowable time for a transition to occur Figure 8 19 shows a satellite uplink acquisition statechart that requires a ground station to respond to satellite commands within a fixed amount of time to prevent the acquisition sequence from failing and starting over Since real time systems are frequently involved in well defined protocols the line between real time state machines and protocol state machines can blur There is no real notational difference it is a matter of what the modeler is trying to convey Real time state machines often model the internal states of a system something Figure 8 19 A sample real time statechart diagram Aguio ground station Surstreceived Synchronizing ground Burst tires Moving ground station to Waiting for syne equisilion sisilon dane synchronned Transenit window i winka J Burat eny send time offset value aniy eend bansmit window offset ater Sms Restarting ground atation aftan Os ony sond RESYNC command Burst denied in karsii wrge after 10ms Reoniwa SYNG AK Verifying ground station syng l m Te eniry pand SYNG _ACHK cormmamni deliberately avoided by protocol state machines If the mo
140. f a connector has required interfaces and a port is connected to the other end of the connector the port must provide a required interface The actual means of communication isn t specified by the connector it can represent a simple method call or a complex protocol over a socket connection You can constrain the connection using the normal UML note notation Simply specify the constraint in a note and link it to the connector using a dashed line Figure 4 2 shows a constrained connector Figure 4 2 A constrained connector f i Pedal gears 10 c Chain realistic constraint could specify that only high priority messages are delivered or that the sender must be authenticated etc You may specify the multiplicity of each connector end using the normal multiplicity syntax Simply write the number of instances for a given end near the end of the connector For example a student teacher relationship may require at least 5 students and no more than 20 You can show the student teacher relationship as depicted in Figure 4 3 Figure 4 3 A Teacher must have at least 5 Students but no more than 20 This page was created by the unregistered version of CHM To POF Converter by Theta Sottware Teacher i Student 5 20 4 1 2 Ports Aport is a way to offer functionality from a composite structure without exposing the internal details of how that functionality is realized For example you may have a subsystem that can
141. f its environment through a given port Provided interfaces show what functionality a classifier exposes to the environment For example our credit card payment system may provide an interface to verify credit cards CreditCardProcessor while requiring access to an account verification system AccountServices Offered by the credit card company If you use ports in your diagrams the required and provided interfaces capture a the interaction the system may have with a given classifier Provided and required interfaces are typically shown using the ball and socket lollipop notation though you may explicitly type a port see Port typing If there are This page was created by the unregistered version of CHM To POF Converter by Theta Sottware multiple required or provided interfaces simply list each interface name followed by a comma don t show multiple lollipops Figure 4 5 shows a port with a required interface and two provided interfaces Figure 4 5 The CreditCardVerificationSubsystem providing two interfaces CreditCardProcessor and CardHolderVerification and requiring one AccountServices CreditCardProcessor subsystem Pani Hal ficatn CreditCardVerificationSubsystem CAGE et Mer Raa nOF E ti j ENES EATER Pansies ETER Note that this port is unnamed This is permitted by UML and the port is treated as being anonymous a cs i i a T eS Se al CreditCardServices 4 1 2 2 Realizing port implementat
142. f th chosen branch can be evaluated to TRue or false the nonchosen branch is completely disregard even if it would be undefined B 3 2 Variable Declaration This page was created by the unregistered version of CHM To POF Converter by Theta Sottware OCL supports several complex constructs you can use to make your constraints more expressive and easier to write You can break complex expressions into reusable pieces within the same expression by using the let and in keywords to declare a variable You declare a variable by giving it a name followed by a colon its type an expression for its value and the in keywol The following example declares an expression that ensures a teacher of a high level course has appropriate salary context Course inv let salary float self instructor salary in if self courseLevel gt 4000 then salary gt 80000 00 else Salary lt BUUU UQ endif You can define variables that can be used in multiple expressions on a classifier by classifier bas using the def keyword For example instead of declaringsalary as a variable using the let keyword you can define it using the def keyword for the course context Once you define a variable using the def keyword you may use that variable in any expression that is in the same context The syntax for the def keyword is the same as that for the let keyword context Course def salary float self instructor salary So now you can write the previous in
143. fy that an artifact requires database transactions or connection information to communicate with a server You model the specific deployment information as a deployment specification artifact You show a deployment specification using the classifier rectangle stereotyped as deployment spec with required deployment information as attributes Figure 6 16 shows an example deployment specification captured in a file named web xml Figure 6 16 A sample deployment specification adeployment spec web xml errorPage URL laginCanfig enum resources Resource The specific information in a deployment specification depends on the type of artifact being deployed You may need a separate model to capture the type of information used by the This page was created by the unregistered version of CHMI To POF Converter by Theta Sottware specification For example Figure 6 16 uses a type named Resource that should be defined on another diagram It s common to bundle an artifact and its deployment specification into a larger artifact You show the relationship between an artifact and its deployment specification using a dashed line with an open arrow dependency pointing from the specification to the artifact Figure 6 17 shows bundling the weatherserver jar application with its deployment descriptor in a web archive called weatherserver war Figure 6 17 An artifact that contains another artifact and its deployment specification we
144. g passed to an activity object nodes to represent complex data and control nodes to direct the flow through an activity diagram 9 3 1 Parameter Nodes You can represent parameters to an activity or output from an executed activity as parameter nodes You show a parameter node as a rectangle on the boundary of an activity with the name or description of the parameter inside the rectangle Input parameter nodes have edges to the first action and output parameter nodes have edges coming from the final action to the parameter node Figure 9 13 shows an example of wood being fed into a paper production activity and paper being produced at the end Figure 9 13 Activity diagram with incoming and outgoing parameters Process Paper Wood 4 Create Pulp Press Paper Package Reams Ream 9 3 2 Object Nodes To represent complex data passing through your activity diagram you can use object nodes An object node represents an instance of a particular classifier in a certain state Show an object node as a rectangle with the name of the node written inside The name of the node is typically the type of data the node represents Figure 9 14 is an activity diagram showing a factory producing parts for shipping Figure 9 14 Object nodes in an activity diagram This page was created by the unregistered version of CHM To POF Converter by Theta Sottware Create Parts Process Steel Part Ship Parts If the type of data the node rep
145. g to an interesting expansion and contraction of the language UML 2 0 is by far the largest UML specification in terms of page count the superstructure alone is over 600 pages but it represents the cleanest most compact version of UML yet Fa PREY NEXT W This page was created by the unregistered version of CHM To POF Converter by Theta Sottware PREY NEXT 1 1 3 UML Basics First and foremost it is important to understand that UML is a language This means it has both syntax and semantics When you model a concept in UML there are rules regarding how the elements can be put together and what it means when they are organized in a certain way UML is intended not only to be a pictorial representation of a concept but also to tell you something about its context How does widget 1 relate to widget 2 When a customer orders something from you how should the transaction be handled How does the system support fault tolerance and security You can apply UML in any number of ways but common uses include e Designing software e Communicating software or business processes e Capturing details about a system for requirements or analysis e Documenting an existing system process or organization UML has been applied to countless domains including e Banking and investment sectors e Health care e Defense e Distributed computing e Embedded systems e Retail sales and supply The basic building block of UML is a diagram The
146. ger guard effect where trigger Indicates what condition may cause this transition to occur The trigger is typically the name of an event though it may be more complex guard Is a constraint that is evaluated when an event is fired by the state machine to determine if the transition should be enabled Guards should not have any side effects and must evaluate to a boolean Guards will always be evaluated before a transition is fired The order in which multiple guards are evaluated isn t defined A guard can involve tests of states in the current state machinefor example not in Dialing Orin WaitingForCall The state names can be fully qualified if necessary effect Specifies an activity that is executed when a transition happens This activity can be written using operations attributes and links of the owning classifier as well as any parameters of the triggering event An effect activity may explicitly generate events such as sending signals or invoking operations Figure 8 12 shows several transitions between states 8 2 3 1 Transition types UML defines several specific types of transitions These are described in the following list There are no special symbols associated with transition types They are defined only for clarity and common vocabulary Compound transition A representation of the change from one complete state machine configuration to another Compound transitions are a set of transitions choices fork
147. he desktop machine The h gameengine exe full game engine runs on tha y watermodal ysh desktop machine itself ji ona a tae Cees I Sa 6 2 3 Communication Paths Communication paths represent generic communication between nodes For example a router may pass HTTP requests to a web server that uses a proprietary socket connection to a database Assuming the database is hosted on its own machine you can model the deployment of the system as nodes linked via communication paths The concept of links between nodes existed prior to UML 2 0 however now the specification formally names them You show a communication path as a solid line drawn from one node to another You typically don t show any directionality on the line because the communication is assumed to be bidirectional Figure 6 11 shows an example web server configuration with several nodes communicating over communication paths Figure 6 11 Several nodes linked with communication paths j Path l WebServer2 W LoadBalancer Database UML doesn t specify a way of modeling the actual messages passed between nodes However protocol state machines see Chapter 8 often provide a good way to represent information flow if a particular protocol is spoken between nodes If a link represents messages between components that aren t captured in a protocol state machine it may make sense to link to one or more component diagrams see Chapter 5 using a note Figure 6
148. he models applying this profile only classes may have that stereotype as shown by the relationship 2 Having established that the Billcurrency is an EJBEntityBean it now has all the EJBEntityBean tagged values as shown by the relationship 3 Stereotypes that extend other stereotypes aS EJBPrimaryKey extends EJBCmpField have all the parent s tagged values Ideally tooling will aid enforce and validate by making available the correct tagged values and defaults according to the stereotype s definition If not the modeler must rely on discipline This page was created by the unregistered version of CHMI To POF Converter by Theta Sottware A PREY NEKT W This page was created by the unregistered version of CHM To POF Converter by Theta Sottware PREY NEXT 11 6 Tools and How They Use Profiles UML tools use profiles to provide a spectrum of solutions Tools providing Model Driven Architecture MDA solutions have transformations from the Platform Independent Model PIM to Platform Specific Model PSM and from the PSM to the application See Appendix A for a fuller discussion of MDA The OMG conceived the MDA as a vision rather than a specified method Each vendor has a different sometimes radically different approach to MDA Consequently although the concepts of the PIM and the PSM vary greatly from one vendor to another any one vendor s concept of the PIM and the PSM is strict and concrete The extra r
149. he unregistered version of CHMI To POF Converter by Theta Sottware use cases and statechart diagrams behavioral state machines event processing implementation view and protocol state machines 2nd pseudostates SPEM and state machine extension states and variations on 2nd states classifiers and final invariants and OCL properties and overview protocol state machine and pseudostates state invariants as state machines and 2nd submachine timing diagrams and transitioning 2nd static attributes static modeling static operations stereotypes lt lt realizations gt gt Application Server component database schemas and defined 2nd execution environment extending overview tagged values and stop symbol stream keyword 2nd strict interaction operator strict sequencing strictfp keyword Java string datatype 2nd structural diagrams 2nd structured classes structures classes and defined diagramming PIM and subjects submachine states 2nd subroutines subsets property attributes substate machines substates 2nd substring operation subsystem component This page was created by the unregistered version of CHMI To POF Converter by Theta Sottware SVG Scalable Vector Graphics swimlanes SYSML Systems Modeling Language SySML org system boundaries Systems Modeling Language SysML PREY NEXT This page was created by the unregistered version of CHM To POF Converter by The
150. henticated access to data your classifier can This page was created by the unregistered version of CHMI To POF Converter by Theta Sottware distinguish which port was used by the external system Figure 4 9 shows the credit card verification system offering two instances of the credit card verification port Figure 4 9 A component with two instances of the CCServices port CreditCardServices CCServices 2 CCServicesimp 4 1 2 5 Port typing In practice when a port is instantiated it is represented by a classifier that realizes the provided interfaces Any communication with this interaction point simply passes the information to internal classifiers that realize the behavior UML 2 0 allows you to specify the type of a port using classes to provide more sophisticated behavior For example you can specify that the port is typed using a class that filters the communications it receives or prioritizes delivery When this port is instantiated the corresponding class has a chance to manipulate the communication it receives before passing it to the realizing classifiers To show that a port should be represented using a specific classifier simply follow the name of the port with a colon and the name of the classifier to use Note that the classifier must realize the provided interfaces You can use this notation to show provided interfaces by using an interface as the port type though the lollipop notation is often more flexible
151. heta Sottware Messages that come into or out of the decomposed lifeline are treated as gates that must be matched by corresponding gates on the decomposition A gate represents a point where a message crosses the boundary between the immediate interaction fragment and the outside environment A gate has no symbol of its own you simply show a message pointing to the edge of the frame of an interaction fragment The entire purpose of a gate is to show an object that sent a message connecting to the object that received the message By default a gate s name is based on the direction in or out and the message in question For example a gate showing a message named verifyPayment leaving an interaction fragment is named out verifyPayment However you may explicitly name gates if that adds readability to your diagram If the messages shown in the decomposition are part of a combined fragment in the larger interaction diagram the decomposition must inherit the same interaction operand UML defines this as extra globa For example if the larger interaction is part of an assert interaction operand and the state invariant is declared on the lifeline you want to decompose that state invariant and its assertion must apply to your decomposition You can show extra global combined fragments by drawing the combined fragment on your decomposition but making the combined fragment rectangle larger than your decomposition rectangle Figure 10 32 shows an as
152. hey separate the platform concerns They trace the origin of each element These models are static Transformation functions apply a transformation to a source model to produce a target model Figure A 4 shows the general case of the transformation function creating or updating target models from the source model and marks The transformation function along with the marks and the mappings are called the bridge between the two principle models The mapping model acts in two roles Before the transformation it relates the elements of the source models together with previous versions of the target models After the transformation the mapping model traces the source of every target model element created or updated During model evolution transformations at the PIM can cause turmoil in the PSM and code models Because of the leverage MDA gives slight refactoring can render the mapping model incapable of reconciling changes If mappings are recorded by element ID deleting an element and recreating it risks orphaning it from its marks Figure A 4 Custom model transformations automate changing abstraction levels Definition Transformer Transformer Definition Target Code PIM PSM PSM Code Code Marks Marks Marks PIM PSM PSM Code mapping mappmg and derivative elements in the target models If the PSM or code model has a great deal of elaboration MDA doesn t proscribe a solution to this Figure A 4 shows a transformer ac
153. hile at the same time keeping the system consistent and coherent as a whole The concept of account for example permeates most or all of the models business web database persistence business logic business delegate and code Not only is any one model consistent within itself but also the concepts from one model relate to the corresponding concepts in other models Changes in the concept ofaccount must affect all related models This notion moves significantly ahead of current non MDA modeling tools that either model everything in one model or require manual synchronization of separate models Although ultimately hoping to eliminate all programming languages current MDA tools can t provide enough finesse to deliver varied and high quality systems without a hybrid approach of UML and 3GL MDA allows handcoded extensions and other tweaking throughout the abstraction layers It remembers the origins of these changes so that subsequent generations of the system respect them MDA tools are sophisticated systems No offering has established itself as a leader Most of the MDA offerings cater to niche markets Most predate MDA so they drag along baggage of a less well defined approach or of a well defined but narrow proprietary approach None manages highly abstract models and generates crack code and generates a variety of This page was created by the unregistered version of CHM To POF Converter by Theta Sottware implementations at least no
154. iagrams provide a way to capture this physical structure of a system a PREY NEXT This page was created by the unregistered version of CHM To POF Converter by Theta Sottware PREY NEXT 1 2 1 Classes A class represents a group of things that have common state and behavior You can think of a class as a blueprint for an object in an object oriented system In UML speak a class is a kind ofclassifier For example Volkswagen Toyota and Ford are all cars so you can represent them using a class named car Each specific type of car is an instance of that class or an object A class may represent a tangible and concrete concept such as an invoice it may be abstract such as a document or a vehicle as opposed to an invoice or a motorcycle greater than 1000 cc or it may represent an intangible concept such as a high risk investment strategy You represent a class with a rectangular box divided into compartments A compartment is simply an area in the rectangle to write information The first compartment holds the name of the class the second holds attributes see Attributes and the third is used for operations see Operations You can hide any compartment of the class if that increases the readability of your diagram When reading a diagram you can make no assumptions about a missing compartment it doesn t mean it is empty You may add compartments to a class to show additional information such as exceptions or events
155. icon usually right below it Figure 7 4 shows an actor icon Alternatively an actor can be shown using the classifier notation You represent the actor with a rectangle with the keyword actor at the top and the name of the actor in bold immediately below that Because actors don t typically have compartments this representation isn t used very often Figure 7 5 shows an actor in classifier notation If it is helpful you may use custom icons to clearly distinguish different types of actors For example you can show an external database system using a database Figure 7 4 An actor using the stick figure representation Preferred Customer Figure 7 5 An actor using classifier notation lt lt actor gt gt Preferred Customer icon while showing the system administrator as a stick figure Figure 7 6 shows exactly this set of actors This page was created by the unregistered version of CHM To POF Converter by Theta Sottware Figure 7 6 Actor with a custom icon o en A Actor with amp custom icon Replicate Databases Database Administrator Database Server 7 2 1 Actor Use Case Associations You typically associate an actor with one or more use cases A relationship between an actor and a use Case indicates the actor initiates the use case the use case provides the actor with results or both You show an association between an actor and a use case as a Solid line Conventionally you read use case diagr
156. ided specifying how you go about leveraging software models MDA has not matured so each of the nearly 50 companies committed to MDA promote vastly differing visions If you find this confusing you aren t alone MDA defines a framework for processing and relating models MDA tools transform pure business models into complete deployable running applications with a minimum of technological decisions Modifying the pure business model behind an application require only updates in the dependent technological area s Technology decisions unrelated to the change remain so the application can be regenerated in a matter of a few minutes An application has many concerns some related to the business itself some related to a particular implementation tier some related to a particular implementation technology MDA further separates the technological concerns of an application from the business it separates high level technical decisions from their technological implementation it separates one technology from another Web forms or database tactics don t complicate the business concepts of say Account and Customer Transaction management decisions don t affect persistence Messaging doesn t interfere with property management or security Each technology can be replaced without recoding In the extreme case the business application can be redeployed on a completely different technology platform MDA keeps these separate concerns in different models w
157. ier An assembly connector ball and socket indicates provided and required interfaces In order to show the realization of functionality a connector maps the port to an internal classifier A connector is shown as a Solid line with a filled arrow from the port to the classifier A connector indicates that any messages arriving at the port typically in the form of method calls are forwarded to the specified classifier You can also use connectors from a classifier to a port to show messages being passed through a provided interface Figure 5 12 shows a white box view of a component with three ports Figure 5 12 Component realization with ports and connectors acomponont Count Management 2 a baer thy cere Account r mi feermama ander aay OrderHiaiary anifirathame Ez girder Ondel i Let han findkOorder date Stat Date dateEnd Gate Orde geb0rdec orderbumiber irt Order i ego tE raddOrdarjerder Creer vori AccouniSerndons verison oarden Onder m rre Order l miira Yea H TraneactonLogaes AccountServicesimpl AG Acuna Ae wed HindA cooumiilas Hama String vod mCrdarBate Cais H Aka Numba inl gatiemal liemi qetOnderDaie Dale 5 2 3 Component Stereotypes This page was created by the unregistered version of CHM To POF Converter by Theta Sottware UML defines several stereotypes that apply specifically to components Entity A component that
158. iews of a system The 4 1 notation represents four distinct views of a system and one overview of how everything fits together The four views are Design view The design view captures the classes interfaces and patterns that describe the representation of the problem domain and how the software will be built to address it The design view almost always uses class diagrams object diagrams activity diagrams composite structure diagrams and sequence diagrams to convey the design of a system The design view typically doesn t address how the system will be implemented or executed Deployment view The deployment view captures how a system is configured installed and executed It often consists of component diagrams deployment diagrams and interaction diagrams The deployment view captures how the physical layout of the hardware communicates to execute the system and can be used to show failover redundancy and network topology This page was created by the unregistered version of CHM To POF Converter by Theta Sottware Implementation view The implementation view emphasizes the components files and resources used by a system Typically the implementation view focuses on the configuration management of a system what components depend on what what source files implement what classes etc Implementation views almost always use one or more component diagrams and may include interaction diagrams statechart diagrams and composite
159. ifying it However C has a somewhat subtler concept of packages called namespaces How packages map to an implementation language is often up to the implementer a PREY NEKT W This page was created by the unregistered version of CHM To POF Converter by Theta Sottware PREY NEXT 1 3 4 Merging Packages UML supports a somewhat complex concept of merging packages Merging packages differs from importing packages in that merge by definition creates relationships between classes of the same name The motivation behind package merging comes directly from the evolution of UML from 1 x to 2 0 UML 2 0 defines the base concept of elements and allows specific diagram types to extend a base concept without needing to provide a new name for it For example UML extends several core Behavioral State Machine concepts into Protocol State Machine concepts while retaining their original name When a package merges another package any class of the same type and name automatically extends or has a generalization relationship to the original class For example UML can define the concept of the include relationship at a generic level and then specialize it for use cases inclusion and retain the name include This type of extension has simplified the internals of the UML model but rarely makes an appearance in real world development You show package merging using a dashed line with an open arrow from the merging package to the merged package Lab
160. imploMiiribule AllributeT ype ipital value saath asic legate Tha s symbol undicates the E fdeciedAtinbule boolean al j F aliribules are privat i T aratu ROMP EEO a o vena bllenkareny Cnfect ordered UiniqueCotiennan Cbject uraque ordered SlancAtiihaee Sonne lass The syntax elements are This page was created by the unregistered version of CAMA To POF Converter by Theta Sottware v s b l ity Indicates the visibility of the attribute Use the following symbols or for public private protected Or package respectively see Visibility in Chapter 3 Indicates the attribute is derived A derived attribute is simply one that can be computed from other attributes of the class See Derived Attributes pame Is a noun or short phrase naming the attribute Typically the first letter is lowercase and the first letter of each subsequent word is capitalized type Is the type of the attribute as another classifier typically a class interface or built in type like int multiplicity Specifies how many instances of the attribute s type are referenced by this attribute Can be absent meaning multiplicity of 1 a single integer or a range of values specified between square brackets separated by Use as the upperbound to represent the upper limit or on its own to mean zero or more See Multiplicity default Is the default value of the attribute property str
161. in that partition must be handled by the currentUser instance To indicate that a partition represents a class you use the keyword class before the type name Though the UML doesn t explicitly state it it is customary to show that a partition represents an instance by underlining the type name Figure 9 27 shows an example of a partition representing a classifier and a partition representing an instance Figure 9 27 Activity diagram with partitions representing classes and instances This page was created by the unregistered version of CHMI To POF Converter by Theta Sottware User Logon g rE Verify Usemame _ Update Access and Password i k Logs S Load User Information from DE 1 a5s Curent User User Partitions can also represent attributes with specific values For example you can have an activity diagram which shows that at a certain point in its execution an attribute has a specific value You can use a partition to indicate the attribute and value available to actions executing within that partition Indicate that a partition represents an attribute by placing the keyword attribute followed by the name of the attribute in a box above the value boxes Figure 9 28 is an example of an activity diagram in which the UserRole attribute is specified to indicate what level of access a user needs to perform the given actions You can combine partitions to show arbitrarily complex constraints on an activity
162. inal node as a solid circle Figure 9 3 An action with pseudocode i Process Sale Purchasedlitem Item Foreach ltem t Subtotal subtotal item cost pe subtotal subtotal taxRate Ship Item End foreach finallnvoice subtotal F with a ring around it See Control Nodes for more information on initial and final nodes Figure 9 4 shows an activity with initial and final nodes Figure 9 4 An activity diagram with initial and final nodes This page was created by the unregistered version of CHMI To POF Converter by Theta Sottware Process Sale Purchasedltem Item 4 F amp gt Bill Customer Ship Item gt e A eo See eee oe Initial node i Activity final node Activities may have pre and postconditions that apply to the entire activity You show a precondition by placing the keyword precondition at the top center of the activity and then place the constraint immediately after it You show a post condition using the keyword postcondition Figure 9 5 shows an activity with pre and postconditions Figure 9 5 Activity diagram with pre and postconditions Process Sale precondition Sale complete Purchasedltem tem postcondition Items shipped __ Bill Customer Ship Item o An action may have local pre and postconditions that should hold true before the action is invoked and after it has completed respectively However the UML specification does
163. ing reveals to others what you discover through modeling It doesn t matter whether you formally create a model in a modeling tool whether the model is implicitly in your head or whether the model resides in another form each diagram drawn from that model should express one or a very limited number of related concepts You choose the idea to express and you express it from the elements in the model Presenting your ideas in UML requires multiple diagrams just as writing a section in this chapter requires multiple paragraphs Implicitly you may think that discussions of layout and effective diagrams relate only to human drawn diagrams Automated utilities create one way transformations to UML of complex text or XML based configuration files or even nontext systems This visual UML presents an alternative and complementary view to the difficult to understand source text especially when used as overviews and sanity checks Most such utilities automatically lay out the resulting diagrams without allowing the user to arrange the diagrams Manual arrangement would impose undue work on the user The need for clarity and focus applies equally to UML produced by tools because the reader is still the same Though UML provides an excellent vehicle for both modeling and diagramming the resultant diagrams aren t necessarily the same Modeling tolerates larger diagrams with a muddled focus A large diagram makes a better playground because the cost of refact
164. ings Is a collection of properties or tags that can be attached to attributes These are typically context specific and denote such things as ordering or uniqueness They are Surrounded by and separated by commas See Properties Constraints Are one or more restrictions placed on an attribute They may be natural language or use a formal grammar such as the OCL See Constraints 2 2 2 Attributes by Relationship You may also represent attributes using the relationship notation The relationship notation results in a larger class diagram but it can provide greater detail for complex attribute types The relationship notation also conveys exactly how the attribute is contained within a class see Relationships for information on the types of relationships For example if you are modeling a car you can show that a car contains an Engine much more clearly using relationships than you can just by listing an attribute in the car s rectangle However showing This page was created by the unregistered version of CHM To POF Converter by Theta Sottware thecar s name by relationship is probably overkill because it is likely just a string To represent an attribute using relationships you use one of the association relationships between the class containing the attribute and the class that represents the attribute as shown in Figure 2 4 which shows that the relationship between a car and its engine has a multiplicity of 1 a car has
165. interaction tables Because sequence diagrams are used most frequently each concept is introduced using that notation The other notations are described in detail later in the chapter The basic symbol for an interaction diagram is a rectangle with the keyword sa and the name of the interaction in a pentagon in the upper left corner Figure 10 1 shows an example sequence diagram The various parts of this diagram are explained throughout the chapter Figure 10 1 A sample sequence diagram sd Authenticate User niroller validaleCreadentials Dan b4ddp4ss se restoraliserData Dan i create Dan Administrator y r CurentUser en es CurrentUser This page was created by the unregistered version of CHM To POF Converter by Theta Sottware PREY NEXT 1 10 2 Interaction Participants You show participants in an interaction using a rectangle called a ifeline The term lifeline illustrates UML s bias toward representing interaction diagrams using the sequence diagram notation When shown in sequence diagrams participants have a dashed line dropping down from a rectangle that shows how long the object is actually in existence When used in other interaction diagram notations such as communication diagrams a lifeline is simply a rectangle You show the name of the participant in the rectangle using the following notation oject hame selector Class name rer decomposition where object name Sp
166. ion diagrams section Because of the expanded functionality quite a bit of new terminology has been introduced We ll cover all the terms in this chapter and try to give you a feel for what terms are really critical and which are there to formalize the specification A PREY NEKT B This page was created by the unregistered version of CHM To POF Converter by Theta Sottware PREY NEXT 1 10 1 What Are Interactions Interaction diagrams are defined by UML to emphasize the communication between objects not the data manipulation associated with that communication Interaction diagrams focus on specific messages between objects and how these messages come together to realize functionality While composite structures show what objects fit together to fulfill a particular requirement interaction diagrams show exactly how those objects will realize it Interaction diagrams are typically owned by elements in the system For example you may have an interaction diagram associated with a subsystem that shows how the subsystem realizes a service it offers on its public interface The most common way of associating an interaction diagram with an element is to reference the interaction diagram in a note attached to the element You can show the details of an interaction using several different notations however sequence diagrams are by far the most common Other notations include interaction overviews communication diagrams timing diagrams and
167. ion model drives code or application generation so you have little or no control over the stereotypes tagged values or constraints comprising the profile This section discusses the use of existing profiles as opposed to defining your own Figure 11 6 depicts a partial UML profile defining a stereotype with its associated tagged values and a couple of constraints as you might receive in a vendor s documentation The profile extends classes with a stereotyped class EJBEntityBean It extends attributes with two stereotyped attributes EUBPrimaryKey and EJBCmpField It declares the respective tagged values for the stereotyped classes and attributes and it declares the enumeration transactionIsolationLevel to define the allowable values for the TRansactionAttribute tagged value The profile also adds the constraints that EJBEntityBean classes must have attributes of type EJBCmpField and EJBPrimaryKey Furthermore attributes having these stereotypes can exist only in an EJBEntityBean class From your point of view the profile along with its constituent stereotypes and tagged values is read only because it tells what the third party tool expects in order to do its job Figure 11 6 A partial specification UML profile Class must be stereotyped ametaclassm annataciaaas as lt EJBE nih Beane Attribute Class nr slereolyped as EJB CmpFisid EJBCmpField or subclasees aEnumerations ah TH
168. ions Ports are wired to an internal implementation using connectors See Connectors for information on how to represent a connector If the classifier owning the port provides the implementation of the functionality itself the port is considered a behavioral port In this case the connector links to a state inside the classifier This state is used to explain the behavior of the classifier when the port is used see Chapter 8 for more information on using states to model behavior This is typically used for simple classifiers not complex structures that implement functionality themselves Figure 4 6 shows a behavioral port Figure 4 6 A behavioral port Alphabetizer E Sorting Services Sort Names On the other hand if the functionality is realized by internal elements you link the connector to internal classifiers that provide the implementation This is typically used for composite structures such as components and subsystems Figure 4 7 shows such a port Figure 4 7 A port linked to an internal implementation This page was created by the unregistered version of CHM To POF Converter by Theta Sottware CreditCardServices CCServices F AccountHolder Note that in this diagram AccountHolder is involved in the implementation of the CCServices functionality but isn t directly connected to the port I 4 1 2 3 Multiple connectors UML 2 0 allows you to have multiple connectors leading from a port to
169. ions If you are modeling an application you may want to split an activity diagram based on which tier handles which action You split an activity diagram using an activity partition Show an activity partition with two parallel lines either horizontal or vertical called swimlanes with the name of the partition in a box at one end Place all nodes that execute within the partition between the two lines Figure 9 25 shows an activity diagram partitioned by business unit There are times when trying to draw a straight line through your activity diagram may not be possible You can show that a node is part of a partition by writing the partition name in parentheses above the name of the node If the activities within Figure 9 25 Activity diagram divided into partitions Hire Employee Lo a 5 i r Submit Employes ame nie Sipe sons Information to Insurance gt be Acceptance i Paperwork Company m z I 5 E Set Up User Account F A E 8 haf E a amp i Set Up Office Space nf E i LL 5 a partition occur outside the scope of your model you can label a partition with the keyword external This is frequently used when performing business modeling using activity This page was created by the unregistered version of CHMI To POF Converter by Theta Sottware diagrams If the behavior being modeled is handled by someone external to your business process you can mark the functionality with an external
170. ions 2nd 3rd 4th UML Infrastructure 2nd UML Superstructure 2nd underscore _ union property attributes unique property uniqueness property 2nd attributes use case diagrams actors and advanced modeling components defined interfaces and SPEM and use case scope use case view and use cases and 2nd use case extension 2nd use case generalization use case inclusion use case packages use case view use cases advanced modeling generalization overview 2nd representation scope use case diagrams and This page was created by the unregistered version of CHM To POF Converter by Theta Sottware PREY NEXT Index SYMBOL A B C D E F G H H J K M N O P Q R S CO U V W X value pins variables capturing time declaring defining local naming OCL and relative times Vector class Java views modeling and 2nd visibility attribute syntax element 2nd package diagrams 2nd visibility element operations A PREY NEKT W This page was created by the unregistered version of CHM To POF Converter by Theta Sottware PREY NEXT Index SYMBOL A B C D E F G H H J K M N O P Q R S CO U M W X wallpaper diagrams weak sequencing weights edges and white box view components 2nd whole part relationships 2nd 3rd a PREY NEKT W This page was created by the unregistered version of CHMI To POF Convert
171. iplicity of the wheel attribute is 4 If no multiplicity is specified 1 is implied Multiplicity can be a single integer a list of integers separated by commas or a range of values When specifying a range of values an infinite upper bound can be This page was created by the unregistered version of CHMI To POF Converter by Theta Sottware represented as an if no lower bound is specified an means zero or more The multiplicity value is shown between square brackets as a single integer or as two integers separated by two dots Figure 2 7 shows the various ways to represent an attribute s multiplicity Figure 2 7 Multiplicity examples Car E a pm eR RT PoE wheels Wheel 4 F Since the engine attribute doesn t have engine Engine explicit multiplicity 1 is assumed 1 passengers Person 1 5 im lg a sg Sie le ea i sal bumperStickers Sticker 2 2 4 1 Ordering An attribute with a multiplicity greater than 1 can be specified to be ordered If the attribute is ordered the elements must be stored sequentially For example you can specify that a list of names be stored alphabetically by marking the list as ordered Exactly what it means for attributes to be stored sequentially typically depends on the attribute type By default attributes are not ordered To mark an attribute as ordered specify the property ordered after the attribute in braces as shown in Figure 2 8 Figure 2 8 Ordered multiplicity
172. ive diagramming communicates one aspect of a system well The less cluttered a diagram the better We chose to communicate the class structure of the Java AWT system To that end the diagram focuses on classes and their relationships and leaves off details such as attributes which have no bearing on the knowledge we are trying to share 12 1 3 Separate Inheritance and Class Interrelationships Our subset of the AWT doesn t contain enough complexity to require more simplification Figure 12 2 mixes the abstract class relationships and the concrete classes using them For even more clarity together Figures 12 3 and 12 4 illustrate the same model as do Figures 12 i and 12 2 but they separate the two concerns of abstraction and inheritance Figure 12 3 focuses on the abstraction common to all the components With just two interesting classes and four supporting classes Figure 12 3 is simple enough to memorize That learned the inheritance hierarchy of concrete classes in Figure 12 4 becomes easy to classify and to manipulate Figure 12 3 Structure of Components and Containers in the AWT This page was created by the unregistered version of CHM To POF Converter by Theta Sottware Q ImageObserver layoutManager LayoutManager Bt Component ComponentPeer Figure 12 4 Inheritance tree of Component in the AWT om e Ee e FileDialog EJ EA Be Es Ee Bo This page was created by the unregistered version of
173. j Company eS Confirm Employee Acceptance Sel Up User Account ata A Set Up Office Space i Se ee oe ends wilh a flow final node indicating that that particular branch ands Sut I All branches Of tha activity diagram axecute concurrently Each branch the overall activity may still be executing in some olher branch i Ajoin node is effectively the opposite of a fork node it synchronizes multiple flows of an activity back to a single flow of execution A join node has multiple incoming edges and one outgoing edge Once all the incoming edges have tokens the tokens are sent over the outgoing edge You show a join node as a vertical line with multiple incoming edges and one outgoing edge Figure 9 23 is an activity diagram that models serving a meal Figure 9 23 Example activity diagram with a join node This page was created by the unregistered version of CHM To POF Converter by Theta Sottware Prepare Meal Defrost Turkey Roast Turkey a i Wash Vegetables gt sleam Vegetables a n e Bake Potatoes B It is worth noting that activity diagrams don t have the advanced time modeling notations that interaction diagrams have So while it s possible to show how to prepare a meal and serve everything at the same time with an activity diagram you can t capture the time needed to cook each part of the meal However you can capture this information with a timing interaction diagram See Chap
174. kage the merging package s element takes precedence and the imported element must be explicitly qualified A PREY NEKT W This page was created by the unregistered version of CHM To POF Converter by Theta Sottware PREY NEXT 1 3 5 Variations on Package Diagrams This section presents two applications of class package diagrams and one application of use case packages Although layering and simplification always motivate packaging the term simplification means different things to different people Simplification can mean e Easier to build and test e Better tracking and project transparency e Working at a stable overview without the noise of low level churn e Less conflict between distributed teams e Easy refactoring and extension Simplification likely means more apparent complexity to some constituency Unless your packaging balances these diverse needs you are likely to receive complaints of unnecessary complexity no matter how noble your motives are 3 9 1 Structuring a Project with Package Diagrams Class packages organize a logical system during construction They provide the terms for management and external stakeholders as well as structure to contain all classes and code to be built Class package diagrams are the UML equivalent of block diagrams Different parties think of a project according to their different needs Programmers think in terms of language and tactical design Architects think in terms of depend
175. kets separated by An infinite upper bound can be represented as an if no lower bound specified an means zero or more See Multiplicity default_value This page was created by the unregistered version of CHM To POF Converter by Theta Sottware Specifies the default value of this parameter The default value is optional If it isn t present you don t show the equals sign Note that UML doesn t specify if a parameter with a default value may be left out when invoking an operation e g C s default parameter value implementation The actual syntax for invoking an operation is language dependent properties Specifies any parameter related properties and is specified between curly braces These are typically defined within the context of a specific model with a few exceptions ordered readOnly and unique See Multiplicity and Properties for more information Properties are optional for parameters if they aren t used don t show the curly braces 2 3 1 Operation Constraints An operation may have several constraints associated with it that help define how the operation interacts with the rest of the system Together constraints on an operation establish a contract that an implementation of the operation must obey Constraints on an operation follow the usual constraint notation and are placed either immediately after the operation signature or in a note attached with a dashed line See Constraints for more informati
176. keywords The conditions are used only to determine which expression is evaluated they can t be used to influence the underlying system or to affect program flow The following invariant enforces that student s year of graduation is valid only if she has paid her tuition context Student inv if tuitionPaid true then yearOfGraduation 2005 else yearOfGraduation 0000 endif OCL s logic rules are slightly different from typical programming language logic rules The boolei evaluation rules are 1 Trueor ed with anything is true 2 FalsSeanp ed with anything is false 3 FalsermpLiesanything is TRue Theimplies keyword evaluate the first half of an expression and if that first half is true the res is taken from the second half For example the following expression enforces that if a student s GPA is less than 1 0 their year of graduation is set to 0 If the GPA is higher than 1 0 Rule 3 applies and the entire expression is evaluated as true meaning the invariant is valid context Student inv self GPA lt 1 0 IMPLIES self yearOfGraduation 0000 OCL s boolean expressions are valid regardless of the order of the arguments Specifically if the first argument of an AND operator is undefined but the second operator is false the entire expression is false Likewise even if one of the arguments to an or operator is undefined if the other is true the expression is true If then else endif constructs are evaluated similarly i
177. l authors dedicate whole books to MDA seek out those books The treatment here aims simply to demystify MDA enough so that you can talk sensibly about it Better yet investigate the vendor offerings Abstract descriptions don t deliver value tools do Both Model Driven Architecture and MDA like the Unified Modeling Language and UML are trademarks of the Object Management Group Fe PREY NEXT W This page was created by the unregistered version of CHM To POF Converter by Theta Sottware PREY NEXT 1 A 1 What Is MDA MDA is the natural evolution of UML Object Oriented Analysis and Design OOAD code generators and third millennium computing power At the highest level MDA envisions the day that UML models become the standard way to design and build software Business software developers will build their systems through MDA tools Development in 3GL languages such as Java or Net will remain a toilsome necessity for the system level For business applications current languages will be too inefficient to be viable used only by the most backward looking organizations As an analogy consider the place of assembler and C or even C in main line business applications today MDA uses models to get the highest leverage out of software development MDA isn t a development process It isn t a specification It isn t an implementation It isn t a conformance suite It doesn t have a reference implementation The OMG wisely has avo
178. l sales department 800 998 9938 or corporate oreilly com Paming nitor O Nutshell Handbook the Nutshell Handbook logo and the O Reilly logo are registered trademarks of O Reilly Media Inc The In a Nutshell series designations UML 2 0 in a Nutshell the image of a chimpanzee and related trade dress are trademarks of O Reilly Media Inc Unified Modeling Language UML Model Driven Architecture MDA Common Object Request Broker Architecture and CORBA are all trademarks of Object Management Group Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks Where those designations appear in this book and O Reilly Media Inc was aware of a trademark claim the designations have been printed in caps or initial caps While every precaution has been taken in the preparation of this book the publisher and authors assume no responsibility for errors or omissions or for damages resulting from the use of the information contained herein ISBN 0 596 00795 7 M This page was created by the unregistered version of CHM To POF Converter by Theta Sottware PREY NEXT 1 Dedication For my family the reason I wrote this book and the reason I was able to Dan Pilone For Laurie Ann Giorraionn beirt bothar Two people shorten the road Neil Pitman PREV E This page was created by the unregistered version of CHMI To POF Converter by Theta Sottware Kins NEXT
179. l to the desired number of tokens A weight of null indicates all tokens should be made available to the target action as soon as they arrive For example Figure 9 12 shows that nine players are needed before you can make a baseball team Figure 9 12 Activity diagram with edge weights f i Create Baseball Team weight 9 In addition to weights each edge may have a guard condition that is tested against all tokens If the guard condition fails the token is destroyed If the condition passes the token is available to be consumed by the next action If a weight is associated with the edge the tokens aren t tested against the guard condition until enough tokens are available to satisfy the weight Each token is tested individually and if one fails it is removed from the pool of available tokens If this reduces the number of tokens available to less than the weight for the edge all the tokens are held until enough are available You show a guard condition by putting a boolean expression in brackets near the activity edge Guard conditions are typically used with decision nodes to control the flow of an activity see Decision and merge nodes This page was created by the unregistered version of CHM To POF Converter by Theta Sottware PREY NEXT 1 9 3 Activity Nodes UML 2 0 defines several types of activity nodes to model different types of information flow There are parameter nodes to represent data bein
180. lass named window and a class named cursor Because you can t navigate from an instance of Cursor to an instance of Window we explicitly show the navigability arrow and an x where appropriate Figure 2 23 Association between Window and Cursor showing you can t navigate from Cursor to Window This page was created by the unregistered version of CHM To POF Converter by Theta Sottware 2 6 2 2 Naming an association Associations may be adorned with several symbols to add information to your model The simplest is a solid arrowhead showing the direction in which the viewer should read the association It is common to include a short phrase along with the arrowhead to provide some context for the association The phrase used with the association doesn t typically generate into any form of code representation it is purely for modeling purposes Figure 2 24 shows the solid arrowhead on the window to Cursor association Figure 2 24 Shows how to read the association between Window and Cursor Changes the gt Window bn a Cursor 2 6 2 3 Multiplicity Because associations typically represent lasting relationships they are often used to indicate attributes of a class AS mentioned in the Attributes by Relationship section you can express how many instances of a particular class are involved in a relationship If you don t specify a value a multiplicity of 1 is assumed To show a different value simply place the multiplicity specificati
181. lend themselves nicely to collaborations You can define an Observable interface and programmatically capture exactly what attributes and operations are needed to fulfill a role UML 2 0 makes collaborations full classifiers meaning you can attach sequence diagrams state machines or any other behavioral diagram to help capture the details of the implementation This page was created by the unregistered version of CHM To POF Converter by Theta Sottware PREY NEXT W 4 3 Collaboration Occurrences UML 2 0 introduced a new concept to allow you to attach a collaboration to a specific operation or classifier to show how it is realized by other elements When you associate a collaboration with an operation or classifier you create a collaboration occurrence You can think of collaboration occurrences as instances of collaborations For example you can use a collaboration occurrence to document how various classes make up a subsystem what is responsible for persistence what is really a fa ade to another subsystem etc The advantage of using a collaboration occurrence to document the implementation of functionality is that you can assign role names to internal elements of the classifier There may be multiple occurrences of a particular collaboration within a classifier each with different internal elements fulfilling the roles of the collaboration You show a collaboration occurrence using the same dashed ellipse used to show a collab
182. les each property will take on by showing a slash followed by the role name after the property name and type Figure 4 13 shows the initialization of a button with its appropriate values You can show that the instance of the owning classifier is related to a particular constructor of a classifier using a dependency line labeled with the keyword create You can use any parameters to the constructor when initializing properties simply by using the parameter name Figure 4 14 shows the application composite diagram tied to a constructor on the Application class Figure 4 12 The Application Window and Button relationships as a This page was created by the unregistered version of CHM To POF Converter by Theta Sottware composite structure Application Window E By representing relationships using a composite structure you can show that the Buttons and Window used in the association must be owned by the same Application Note that since the Application doesn t own the Window it s an association rather than a composition relationship the Window is shown using a dashed box Figure 4 13 Application composite structure with property values OkButton Button MainWindow text OK Window ae e My OEP CancelButton width 100 Button height 300 a text Cancel Figure 4 14 Application constructor relating to an instance of an Application Application Application
183. lor of a car the number of sides in a shape etc are represented as attributes Attributes can be simple primitive types integers floating point numbers etc or relationships to other complex objects see Relationships An attribute can be shown using two different notations inlined or relationships between classes In addition notation is available to show such things as multiplicity uniqueness and ordering This section introduces both notations and then describes the details of the attribute specification 2 2 1 Inlined Attributes You can list a class s attributes right in rectangle notation these are typically called inlined attributes There is no semantic difference between inlined attributes and attributes by relationship it s simply a matter of how much detail you want to present or in the case of primitives like integers how much detail you can present To represent an attribute within the body of a class place the attribute in the second compartment of the class UML refers to inlined attributes as attribute notation Inlined attributes use the following notation visibility name typemultiplicity default property strings and constraints visibility multiplicity lower upper Figure 2 3 lists several attributes demonstrating various aspects of attribute notation Figure 2 3 Example attributes Se ee eer DivarseClass ae Se later in thie chapter for oars arcmin de s
184. low a GPA of less than 2 0 and send out a letter to the student s parents in the event such a low GPA is achieved you would model such behavior using a UML diagram such as an activity or interaction diagram You can follow associations between classifiers using the association end names as though they were attributes of the originating classifier The following invariant on course ensures that the instructor is being paid This page was created by the unregistered version of CHMI To POF Converter by Theta Sottware selivsanstructor lt salary gt 0 00 If an association has a multiplicity of 0 1 you can treat the association end as a Set and check to see if the value is set by using the built in notEmpty operation To call the notEmpty Operation on a set you must use an arrow gt rather than a dot See Collections for more information on sets The following invariant on Course enforces that a course has an instructor seli instructor gt notEmpty If an association role name isn t specified you can use the classifier name The following invariant on school checks that each course has a room assignment self Course gt forAll roomAssignment lt gt No room Comments can be inserted into an expression by prefixing each comment with two dashes like this make sure this student could graduate self GPA gt 2 0 If you can t determine the context of an expression by looking at the UML model or if you want
185. med Titlebar Figure 2 27 Titlebar is a part of Window This page was created by the unregistered version of CHM To POF Converter by Theta Sottware Window Titlebar As with the association relationship you can show navigability and multiplicity on a composition line See Association for examples 2 6 5 Generalization Ageneralization relationship conveys that the target of the relationship is a general or less specific version of the source class or interface Generalization relationships are often used to pull out commonality between difference classifiers For example if you had a class named Cat and a class named Dog you can create a generalization of both of those classes called Animal A full discussion of how and when to use generalization especially versus interface realization is the subject for an object oriented analysis and design book and isn t covered here Generalizations are usually read as iS a starting from the more specific class and reading toward the general class Going back to the cat and Dog example you would say a Cat IS a Animal grammar aside You show a generalization relationship with a solid line with a closed arrow pointing from the specific class to the general class Figure 2 28 shows an example of the cat tO Animal relationship Figure 2 28 Cat specializes the Animal base class Animal Cat Unlike associations generalization relationships are typicall
186. message to occur during execution 10 8 2 10 Assertion Anassertion indicates that the contained event occurrences are the only valid execution path The interaction operator is assert Assertions are typically combined with some kind of state invariant to enforce a state of a system Figure 10 28 shows a sequence diagram in which the user requests that maps be redrawn TheRenderingEngine instructs the DrawingSurface to remove all the existing textures and the assertion guarantees there are no textures left 10 8 2 11 Loop This page was created by the unregistered version of CHM To POF Converter by Theta Sottware Aloop indicates that the contained event occurrences are to be executed some number of times The interaction operator is loop The notation for a loop includes a minimum and maximum number of times a loop should execute You Figure 10 27 Example of a consider operator sd Mail transmission sequence consider authenticateUser sendEnvelope sendBody disconnect shutdown reset authenticateUser Dan nOm411 Shae A sendEnvelope headers en sendBody bodyText disconnect YY Figure 10 28 Example of an assertion operator ed Redraw maps RenderingE ngine _Drawingturlace Maploader mee e ee ee sis ae OS Eiaa i This is a found message meaning p C B we don care who he Sener wis a ee ee ee asad necro All Tg are Sh bextureZount Q gotVia
187. mple Add item to shopping cart is probably not the larger goal a user intends Purchase item is likely a better scope Purchase item can consist of adding an item to a shopping cart but typically has more functionality such as logging on entering billing and shipping information and confirming the order Above all use cases are intended to convey desired functionality so the exact scope of a use case may vary depending on the intended audience and purpose for modeling A PREY NEKT W This page was created by the unregistered version of CHMI To POF Converter by Theta Sottware PREY NEXT Chapter 8 Statechart Diagrams State machine diagrams capture the behavior of a software system State machines can be used to model the behavior of a class subsystem or entire application They also provide an excellent way of modeling communications that occur with external entities via a protocol or event based system UML has two types of state machines Behavioral state machines Show the behavior of model elements such as objects A behavioral state machine represents a specific implementation of an element Protocol state machines Show the behavior of a protocol Protocol state machines show how participants may trigger changes in a protocol s state and the corresponding changes in the system i e the new state of the protocol Protocol state machines aren t typically tied to a particular implementation and they show the requi
188. n italics as well Figure 2 20 is an example of the abstract class Movable Figure 2 20 Abstract class Movable move void An abstract class can t be instantiated it must be subclassed and then a subclass which does provide the operation implementation can be instantiated See Relationships for more information on subclasses PREY NEXT This page was created by the unregistered version of CHM To POF Converter by Theta Sottware PREY NEXT 1 2 6 Relationships Classes in isolation would not provide much insight into how a system is designed UML provides several ways of representing relationships between classes Each of UML relationship represents a different type of connection between classes and has subtleties that aren t fully captured in the UML specification When modeling in the real world be sure that your intended viewers understand what you are conveying with your various relationships We say this both as a warning to the modeler and as a slight disclaimer that the following explanations are our interpretation of the UML specification For example the debate over when to use aggregation versus composition is ongoing To help determine which relationship is most appropriate we offer a short phrase for each type that may help make the distinction Again the important thing is to be consistent within your model 2 6 1 Dependency The weakest relationship between classes is a dependency relationship
189. n any of the incoming edges and makes them available on the outgoing edge You show a merge node using the same diamond you use in a decision node except with multiple incoming edges and a single outgoing edge Figure 9 21 shows how a potential new hire s information may be submitted to Human Resources for processing Figure 9 21 Activity diagram with a merge node i Hire New Employees Recruit Candidates _ Eri Paat p amp h Prepare Job Offer Review Unsolicited Le U ae Applications V a y g j E Merge node 9 3 4 3 Fork and join nodes Afork node splits the current flow through an activity into multiple concurrent flows It has one incoming edge and several outgoing edges When data arrives at a fork node it is This page was created by the unregistered version of CHMI To POF Converter by Theta Sottware duplicated for each outgoing edge For example you can use a fork node to indicate that when a new person is hired actions are initiated by Human Resources the IT Department and Facilities Management All these actions execute concurrently and terminate independently You show a fork node as a vertical line with one incoming edge and several outgoing edges Figure 9 22 is an activity diagram that models hiring a new employee Figure 9 22 Example activity diagram with a fork node Hire Employee Submit Employee Prepare Benefits Information to Insurance gt F Paperwork
190. n example central buffer node feeding car dealer supply lines Figure 9 38 Activity diagram with a central buffer node _ lay Distribute Cars pa Sell Cars Car ees 4 E 1 _ centralBuffer Assemble Car ims Car 4 ke ah Refresh Company Cars Car As the cars are produced they are sent to the Sell Cars action or rotated into the company cars inventory as needed by the respective actions 9 4 8 Data Store Nodes Adata store node is a special type of central buffer node that copies all data that passes through it For example you can insert a data store node in your activity diagram to indicate that all interactions are logged to an external database or that when an article is submitted for review it is automatically stored in a searchable archive You show a data store node as a stereotyped version of an object node Show the node as a rectangle and place the keyword datastore above the name of the node Figure 9 39 shows a data store node If the same object passes through a data store node the specification states that the previous version of the object will be overwritten This page was created by the unregistered version of CHM To POF Converter by Theta Sottware Figure 9 39 Activity diagram with a data store node Process Order ey a 1 Make Sale gt Ship Item w Fi l 4 When an order is placed the information regarding the sale is stored in the customer da
191. n t dictate how pre and postconditions map to implementation violations of the conditions are considered implementation dependent and don t necessarily mean the action can t execute You show pre and postconditions using notes attached to the action You label the note with the keyword localPrecondition Or localPostcondition Figure 9 6 illustrates this Figure 9 6 An activity diagram with local pre and postconditions for actions This page was created by the unregistered version of CHM To POF Converter by Theta Sottware alocalPrecondition TS Process Sale Purchaser s address is Purchaseditem Item valid ee Bill Customer gt Ship Item localPostcondition N Furchaser has been sent an invoice 9 1 1 Activity Edges In order to show flow through an activity you link actions together using activity edges Edges specify how control and data flow from one action to the next Actions that aren t ordered by edges may execute concurrently the UML specification leaves it up to the specific implementation of an activity diagram to say whether actions actually execute in parallel or are handled sequentially You show an activity edge as a line with an arrow pointing to the next action You can name edges by placing the name near the arrow though most edges are unnamed Figure 9 6 as well as the earlier figures shows an activity diagram with several activity edges 9 1 1 1 Control flows UML offers
192. n those two packages without destabilizing each other Figure 3 10 Dependency graph of modified JMeter with no cycle This page was created by the unregistered version of CHM To POF Converter by Theta Sottware Dependency Level 4 top 3 ay i controllers visualizers threads Y p samplers 0 reporters timers Through time projects evolve and new dependencies creep in because of misunderstanding or expediency Figure 3 11 shows such a case three bidirectional dependencies ruin the desirable acyclic nature of the graph e utils now depends on threads e threads now depends on controllers e samplers now depends on tHReads The problem here is that the reverse of each dependency already existed in Figure 3 10 The result is the tangle of bidirectional arrows in level 1 of Figure 3 11 which contrasts with the clear flow of arrows in Figure 3 10 The further result is pain for the developers testers and likely managers and users Changes in threads will confound the team responsible for controllers and utils and vice versa because fixes in one require fixes in the code or unit tests of the others It may take several iterations until all packages stabilize t For more theory and metrics regarding packages and their dependencies see John Lakos Large Scale C Software Design Also see Robert C Martin s http c2 com cgi wiki PrinciplesOfObjectOrientedDesign Figure 3 11 Dependency gra
193. na A a lt xs element name contact type contact gt lt xs complexType name contact gt lt xS sequence gt lt xs element name name type xs string gt lt x Cchoilce gt lt xs element name telephone type xs string gt lt xs element name email type xs string gt lt xS gt choice gt lt xs sequence gt lt xs complexType gt lt l Class SQ0IPMENL ener eter Ae ee Ree gt lt xs element name equipment type egquipment gt lt xs complexType name equipment gt lt xs sequence gt lt xs element ref shortname gt lt xs element name technicalcontact type technicalcontact gt lt xs element name trainingcontact type trainingcontact gt lt xs sequence gt lt xS attribute name equipmentid type xs string use required gt lt xs complexType gt lt C1laSS guipmen tligt See ere eee eer eee eee ree ee lt xs element name equipmentlist type equipmentlist gt lt xs complexType name equipmentlist gt lt xsS sequence gt lt xs element ref equipment minOccurs 1 maxOccurs unbounded gt lt xs sequence gt lt xs complexType gt lt l Class lt lt xXsDLoplevelAlrtribute gt gt lang renarena gt lt xs attribute name lang type xs language gt Kle gt Class langst ring Anaa ean A AA gt lt xs element name langstring type langstring gt lt xs complexType name langstring gt lt xs SsimpleContent gt lt xs extension base xs string
194. nation Found messages are messages that are received by an object but the sender is unknown For example if you want to model an exception handling mechanism the sending of the exception is really irrelevant to the mechanism itself so you can model that as a found message Understand that unknown senders and receivers are relative concepts The sender or receiver of a message may be unknown as far as a This page was created by the unregistered version of CHM To POF Converter by Theta Sottware Figure 10 9 Object instantiation with the object lined up with the creation message sd Create a new user WeblInterface Servlet addNewUser accountinfo m pcreatefaccountinfo a TE A ee eee eee se ese een ememen sa UserAccount newUser particular interaction is concerned meaning it s really outside the scope of what you are trying to show not that the message necessarily vanishes from existence though that s permissible too You show a found message by starting the message from a black circle rather than the sender s lifeline Figure 10 10 shows an example of a found message The CcircuitBreaker doesn t care where the power surge came from it must terminate the power in all conditions Figure 10 10 An example of a found message sd Handling a power surge CircuitBreaker powerSurge bo terminatePower fe Similarly you show a lost message by terminating the message arrow at a bla
195. nd UML Profiles The UML described in the previous chapters allows you to understand any UML model You can understand the analysis of a billing system the implementation model of a CORBA system a gaming system in C or an EJB e commerce system Practitioners rarely work on such diverse systems at one time however and no UML model will represent more than one type of application More commonly a practitioner that s you works with colleagues on one system or a series of closely related systems exclusively For example you might design a series of gaming systems or a series of Net systems And as you might expect the specific concerns of a gaming system differ profoundly from those of a Net system UML allows toolmakers to create a dialect called a profile tailored to a specific niche Within a niche a stereotype gives specific roles to elements and records additional context specific information in tagged values Profiles also include constraints that ensure integrity of use A practitioner familiar with a profile will immediately grasp the meaning of a model developed using that profile because of the unique stereotypes Moreover the model contains deeper meaning because of the tagged values and the model has a higher degree of integrity because of the constraints This gives a distinct advantage to practitioners and tools working in the niche People and tools unfamiliar with the profile will process it only at a formal level
196. nd are often used to look for problems or determine compilation order Nearly all UML elements can be grouped into packages including packages themselves Each package has a name that scopes each element in the package For example if you had a class namedtimer in a package named utilities the fully qualified name for the class is Utilities Timer Elements in the same package can refer to each other without qualifying their names A PREY NEKT W This page was created by the unregistered version of CHM To POF Converter by Theta Sottware PREV NEXT 3 1 Representation You show a package using a rectangle with a tab attached to the top left Figure 3 1 shows theutilities package Figure 3 1 A simple package Utilities You can show the elements contained within a package in two different ways First you can show the elements contained within the package by drawing them inside the large rectangle If you use this representation write the name of the package in the tab Figure 3 2 shows the contents of the utilities package inside of the package To refer to the Timer class from outside of the Utilities package you Say Utilities Timer Figure 3 2 Several classes contained inside the Utilities package Utilities Timer Queue Semaphore The second representation uses a solid line pointing from the package to each contained element You place a circle with a plus sign in it at the end nearest the package to indica
197. ndicate that the argument return a value If the argument is used as an out argument a value after the colon in the specification is interpreted to be the return value return value Is an optional part of the reference that if present indicates the value returned by the co interaction This page was created by the unregistered version of CHM To POF Converter by Theta Sottware Figure 10 30 shows a simple mail transmission sequence diagram that uses an interaction occur refer to another sequence diagram that illustrates user authentication In this example the retu from the interaction occurrence is ignored so it isn t assigned to any variable Figure 10 30 Example of an interaction occurrence sd Mail transmission sequence ra I 7 r Ci i m o co fo ref The AuthenticateUser sequence i diagram assumed to be defined AuthenticateUser Dan n m oii a elsewhere in the model is l invoked with the arguments Dan and n m4il i sendEnvelopa neaders fm cm eee M 3 e sendBody bodyText E disconnect e oan l l PREV NEXT This page was created by the unregistered version of CHM To POF Converter by Theta Sottware PREV NEXT 1 10 10 Decomposition A participant in an interaction diagram may be a complex element in and of itself UML allows you to link interaction diagrams by creating a part decomposition reference from a participant to a separate diagram Fo
198. ne understanding the specialized domain of the computer system under study can understand the PIM Although destined to be an information system the PIM requires no information system background The PIM is the starting point for MDA discussions in this appendix Platform specific model PSM The PSM projects the PIM onto a specific platform Because one PIM begets multiple PSMs the PSMs must collaborate to deliver a consistent and complete solution Commonly the implementer defines a different UML profile to define the PSM for each target platform The PSM realizes the PIM as it applies to one specific platform The PSM deals explicitly with the operating system programming language technology platform e g CORBA Net J2EE or PHP remote distribution or local collocation Although porting from one platform or language probably means discarding the PSM sibling PSMs and the PIM remain unchanged Despite the need for an understanding of the underlying technology to understand the PSM the understanding need not be profound Modelers must know the difference between locally and remotely located components they don t need to know how to implement or debug them Code model The code model represents the deployable code usually in a high level language such as XML Java C C VB HTML JSP or ASP It may or may not be readable It may or may not be extendable although often it has extension points in the form of protected code
199. ng shortname technicalcontact trainingcontact l 4 Pe E langstring PERE XSDattribute lang langEnum _ 7 pi XS Dchoicen aenumerations shah group 1 _langEnum ian aXSDelement telephone string FR z inaen aXSDelement email string Figure 2 39 An example database schema using a class diagram CONTENT ARTICLE SITE apimarykoye ID inbeger 8 incl null epimaryaeys 1D integer C8 not mull aprmarykeys 10 inkager 5 incl nun E 1 MAME varchar 20 Pt Soreignkeys CONTENTID integer 5 not nul TITLE varchar Sih not rail eoreignkiys SITED ineger 5 not radi TITLE varechar d 1 WMLSTRONG longiext ALTHORMAME vantaa T ajoin mikis ajalt bloa SITE CATEGORY ATP CATEGORY_ARTICLE eprineryieys ID wager 5 n0 nul om eater eth ISHAR caie spemaryhieys AD imaga 5 not rrul afoma SITE ID integer Sb ret mull SHORTNAME varchar 10 akayin CATEGORY ID misge 3 ampi ma aiiai CATEGORY IOI misgar 5 rect ral aharreg keys ARTKHIE IF iniga Si re neil This page was created by the unregistered version of CHMI To POF Converter by Theta Sottware PREY NEXT 1 Chapter 3 Package Diagrams Packages provide a way to group related UML elements and scope their names For example you can put all elements having to do with 3D rendering into a package named 3DGraphics Package diagrams provide a great way to visualize dependencies between parts of your system a
200. ng l A aie I the activity transitions to Factory Problem 3 gt l f 4 m Report Notify Maintenance eea pe i with a Factory Problem ocess Stee Part i Report l Ship Parts M eA n r ae pe _ Part If you don t have edges leading into or out of an action you can show whether a pin is an input pin or an output pin by placing small arrows inside the pin rectangle The arrow should point toward the action if you are showing an input pin and away from the action if you are showing an output pin Figure 9 17 shows an action with input and output pins If an action takes a constant value as input you can model the input data using a value pin A value pin is shown as a normal input pin except the value of the object is written near the rectangle Figure 9 18 shows an activity diagram with a value pin Figure 9 17 Action with input and output pins tems Bor Package Order E The Figure 9 18 Action with a value pin Plaintext String m L Encrypt String KeyLlength 2046 9 3 4 Control Nodes In addition to actions activities may include other nodes to represent decision making concurrency or synchronization These specialized nodes are called contro nodes and are described in detail in this section This page was created by the unregistered version of CHM To POF Converter by Theta Sottware 9 3 4 1 Initial nodes Aninitial node is the starting point for an activity an
201. nnectors are illustrated using ball and socket icons To show a required interface use the socket icon and write the name of the interface near the connector symbol Figure 5 3 shows a component with two required interfaces Figure 5 3 Component with two required interfaces identity Verifier component AccountManagement TransactionLogger Show a provided interface with the ball half of an assembly connector again with the name of the interface near the symbol Figure 5 4 shows a component with a provided interface Figure 5 4 Component with a provided interface This page was created by the unregistered version of CHM To POF Converter by Theta Sottware To wire components together simply connect the matching provided and required interfaces Component dependencies using assembly connectors provide more details about the actual relationships between components than simple dependency relations Figure 5 5 shows the Same three components from the Component Dependencies section but using assembly connectors Figure 5 5 Component relationships using assembly connectors component AccountManagement Identity Verifier L TransactionLogger ae IdentityVerifier TransactionLogger cS a component component 2 CreditCardServices Logger 5 2 1 2 Interface dependencies While assembly connectors provide more detail than simple component dependencies they don t provide detailed informati
202. nregistered version of CHM To POF Converter by Theta Sottware PREY NEXT 1 8 3 State Machine Extension Like many other concepts in UML state machines may be specialized as needed A specialized state machine is an extension of a general state machine You can specialize a state machine by adding regions states pseudostates or transitions In addition to adding features to state machines you can redefine states regions and transitions When drawing a specialized state machine draw the inherited states with dashed or gray toned lines You may also place the keyword extended in curly braces after the name of the state machine Figure 8 16 shows a specialized soda dispensing state machine The Dispensing Drink state is extended to introduce a new substate out of selection The states Releasing drink and Refunding change retain their other transitions and a new transition Time expired is added to transition to the new substate if the IR sensor isn t triggered see Figure 8 6 for the original composite state A PREY NEKT W This page was created by the unregistered version of CHM To POF Converter by Theta Sottware PREY NEXT 1 8 4 Protocol State Machines Protocol state machines capture the behavior of a protocol such as HTTP or a challenge response speakeasy door They aren t tied to a particular implementation of a protocol rather they specify the state changes and events associated with a protocol based communicati
203. ns are typically read as has a For example if you have a class named window that has a reference to the current mouse cursor you would say Window has a Cursor Note that there is a fine line between has a and owns a see Aggregation later in this section In this case Window doesn t own the cursorjCursor is shared between all applications in the system However Window has a reference to it so that the Window can hide it change its shape etc You show an association using a solid line between the classes participating in the relationship Figure 2 22 shows an association between Window and Cursor Figure 2 22 Association showing Window has a Cursor W indow Cursor 2 6 2 1 Navigability Associations have explicit notation to express navigability If you can navigate from one class to another you show an arrow in the direction of the class you can navigate to If you can navigate in both directions it is common practice to not show any arrows at all but as the UML specification points out if you suppress all arrows you can t distinguish nonnavigable associations from two way associations However it is extremely rare to use a nonnavigable association in the real world so this is unlikely to be a problem You can explicitly forbid navigation from one class to another by placing a small x on the association line at the end of the class you can t navigate to Figure 2 23 shows an association between a c
204. nsition pointing from the source state to a rectangle with a triangular point on one side The signature of the signal including parameters is shown inside the rectangle Another unlabeled transition links the rectangle to the target state Figure 8 14 shows a This page was created by the unregistered version of CHM To POF Converter by Theta Sottware detailed view of a transition sending a signal Figure 8 13 A transition oriented view showing a Signal being received i Releasing Drink Y IR Sensor Tripped W Opening Door Figure 8 14 Transition oriented view of a signal being dispatched 4 a Dispensing Drink Close Door F a r k j 1 I 4 P k Pea You can show effects that occur as a result of a transition using a simple rectangle The description of the activity is written inside the rectangle As with signal icons you link everything together with an unlabeled transition from the source state to the rectangle and then from the rectangle to the target state Figure 8 15 shows details of the effects of a transition 8 2 3 3 Transitions and composite states A transition from an external state to the border of a composite state is called default entry The entry activity of the composite state is executed and then the default transition to a substate occurs A transition from an external state to a specific substate of a composite state is called explicit entry The entry activity fo
205. ntuitive to new users of UML Sequence diagrams are discussed as part of interaction diagrams in Chapter 10 State machine diagrams State machine diagrams capture the internal state transitions of an element The element could be as small as a single class or as large as the entire system State machine diagrams are commonly used to model embedded systems and protocol specifications or implementations State machine diagrams are discussed in Chapter 8 Timing diagrams Timing diagrams are a type of interaction diagram that emphasize detailed timing specifications for messages They are often used to model real time systems such as satellite communication or hardware handshaking They have specific notation to indicate how long a system has to process or respond to messages and how external interruptions are factored into execution Timing diagrams are discussed as part of interaction diagrams in Chapter 10 Use case diagrams Use case diagrams capture functional requirements for a system They provide an implementation independent view of what a system is supposed to do and allow the modeler to focus on user needs rather than realization details Use case diagrams are discussed in Chapter 7 1 6 2 Views While not strictly part of UML itself the concept of views of a system helps the modeler choose diagrams that help convey the correct information depending on his goals Specifically models are often divided into what is called the 4 1 v
206. ocode This page was created by the unregistered version of CHMI To POF Converter by Theta Sottware list append keystroke print or natural language record keystroke and show password character You may omit the slash when you don t show the activity expression Activity expressions can use attributes and operations available to the classifier owning the state machine UML reserves three activity labels Entry Triggers when a state is entered The entry activity executes before anything else happens in the state Exit Triggers when leaving a state The exit activity executes as the last thing in the state before a transition occurs Do Executes as long as a state is active The do activity executes after the entry activity and can run until it completes or as long as the state machine is in this state Each state may have additional activities associated with it and specific labels for each See Figure 8 5 for an example of a state with several activities If the do activity completes it causes a completion event which can trigger a transition see Dispatch If there is a completion transition a transition with no other event condition the exit activity executes and the transition occurs If some other event causes the state to transition before the do activity completes the activity is aborted the exit activity executes and the transition occurs a PREY NEKT W This page was created by the u
207. of abstraction Attributes defined in the design model M1 exist in the runtime system MO Tagged values defined in the profile M2 exist only in the design model M1 The tagged values may provide hints to help the generation of code either by human or machine A tagged value of optimize space will probably affect the code ultimately although the actual value itself never appears in the code A PREY NERT W This page was created by the unregistered version of CHM To POF Converter by Theta Sottware PREV NEXT 11 4 Constraints Stereotypes give roles to elements Tagged values provide role specific information enriching the element in its role While atomically the element knows its role and has all the information to fulfill it the element must still interact with its neighbors The element and their roles must be in harmony with the architectural vision The element must also be internally consistent Constraints see Constraints in Chapter 2 provide the mechanism to specify rules for correct usage of the stereotyped elements a PREY NEKT W This page was created by the unregistered version of CHM To POF Converter by Theta Sottware PREY NEXT 1 11 5 UML Profiles UML profiles combine the concepts of stereotypes tagged values and constraints to provide a coherent and concise dialect of UML for a specific family of applications To make much use of a profile some tooling must be provided The applicat
208. of a composite state to another region in the same composite state isn t allowed Completion transition A transition from a state that has no explicit trigger When a state finishes its do activities a completion event is generated This event is placed in the event pool and dispatched before any other event see Event Processing If the completion transition s guard conditions if there are any are met the transition is triggered You can have multiple completion transitions however they must have mutually exclusive guard conditions A completion transition from an orthogonal composite state will be taken when all the regions have reached their final state and have completed their do activities 8 2 3 2 Signal symbols Transitions may be shown in more detail using explicit icons to show signal sending signal receipt and effect activities These icons are not necessary and are simply used to provide a more transition oriented view of a state machine You can show a transition that receives a signal by showing an unlabeled transition from the source state to a rectangle with a triangular notch on one side The signal s signature is shown inside the rectangle Complete the diagram by showing an unlabeled transition pointing from the rectangle to the target state Figure 8 13 shows a detailed view of a transition receiving a signal You can show a transition that sends a signal as part of the transition effect by drawing an unlabeled tra
209. oles and information introduced as the PIM is refined to the PSM and the PSM to code must be well defined and well controlled Profiles provide the definition of the information to be captured and the constraints on a valid model Each tool validates conformity to a profile in its own way The PIM needs only one profile because it can be used and reused for different platforms Each PSM on the other hand potentially needs a different profile because each specific platform has different issues and transformations to arrive at optimal code Tools previous to MDA still use profiles In general they provide a model to code code generation feature and often a code to model reverse engineering feature To faithfully generate runnable code many details must be stored in the model Many language dependent features can t be recorded in core UML For example UML doesn t recognize the Java keyword strictfp which indicates floating point processing Without tagged values a reverse engineered system would not faithfully reproduce the same code when forward engineered A PREY NEKT W This page was created by the unregistered version of CHM To POF Converter by Theta Sottware PREY NEXT W Chapter 12 Effective Diagramming This chapter illustrates how you can create effective class diagrams The diagrams presented in the reference section of this book have few elements Those diagrams illustrate individual diagram elements clear of any clutte
210. om For more information about books conferences Resource Centers and the O Reilly Network see the O Reilly web site at http www oreilly com PREY NEXT W This page was created by the unregistered version of CHM To POF Converter by Theta Sottware L PREY Acknowledgments From Dan This book was truly a team effort Without support emails comments harassment and suggestions from friends family and colleagues this book would not have happened First I d like to thank my editor Jonathan Gennick for his astonishing amount of patience He is fantastic to work with and helped keep this book on track Next I d like to thank the technical reviewers who were never short on suggestions or comments At times I felt like this was the fourth edition of the book after working in all their ideas The tech reviewers were Stephen Mellor Michael Chonoles Mike Hudson Bernie Thuman Kimberly Hamilton Russ Miles and Julie Webster Finally I d like to thank my family my parents for supporting me from the start and setting an example that has driven me in both my professional and personal life and my wife Tracey for somehow managing to hold everything together while I wrote this book Compared to the magic she has been working writing this book was a piece of cake Last but not least I d like to thank my son Vinny now we can head to the park From Neil I d like to thank Ron Wheeler and Jacques Hamel of Artifact Softwar
211. on 2 3 1 1 Preconditions Preconditions capture what the state of the system must be before an operation can be invoked Practically speaking you really can t express the state of the entire system Instead preconditions typically express the valid values for parameters the state of the class owning the operation or a few key attributes of the system The specification explicitly states that the operation doesn t need to check the preconditions in the body of the operation before executing theoretically the operation will not even be invoked if the preconditions aren t met In practice few languages offer such protection If someone took the time to express them it is usually in your best interest to verify the preconditions are correct when implementing an operation As a developer preconditions offer you one of the few chances to cover your butt and say exactly how you expect things to be when your implementation is invoked use them Figure 2 14 shows several examples of preconditions Figure 2 14 Preconditions for operations This page was created by the unregistered version of CHM To POF Converter by Theta Sottware 2 3 1 2 Postconditions Postconditions capture guarantees about the state of the system after an operation has executed Like preconditions postconditions typically express the state of one or more key attributes of the system or some guarantee about the state of the class owning the operation Figure 2
212. on Unlike in behavioral state machines states in protocol state machines represent stable situations where the classifier isn t processing any operation and the user knows its configuration Figure 8 16 State machine extension Soda Machine extended Dispensing Orink extended Releasing drink Time expired entry display message _efunding changa Protocol state machines differ from behavioral state machines in the following ways e entry exit and do activities can t be used e States can have invariants Place invariants in square brackets under the state name e The keyword protocol is placed in curly braces after the state machine name to indicate the state machine is a protocol state machine e Transitions in protocol state machines have a precondition in place of the guard in normal transitions the trigger and a post condition The notation for a protocol transition is as follows precondition event postcondition e Each transition is associated with zero or one operation on the owning classifier The transition guarantees that the precondition will be true before the operation is invoked and that the post condition will be true before entering the target state This page was created by the unregistered version of CHM To POF Converter by Theta Sottware e The effect activity is never specified for a protocol transition Figure 8 17 shows a simplified version of the Simple Mail Transport Pr
213. on a single interface See Interfaces in Chapter 2 for more information Within a collaboration it is helpful to name the instances involved You typically name an instance based on its role in the collaboration For example if you wish to model the Observer Observable design pattern you will likely have an instance in the role of Observer and an instance in the role of Subject You show a collaboration using a dashed ellipse with the name of the collaboration written inside Figure 4 15 shows a collaboration named Observer Observable Figure 4 15 A simple collaboration Observer Observable There are two ways to render the details of a collaboration The first is to add a compartment to the collaboration ellipse and draw the instances involved in the collaboration inside Links between instances are shown as solid lines Each instance is named according to its role in the collaboration Figure 4 16 shows the internal structure of the Observer Observable collaboration Figure 4 16 Internal details of a collaboration This page was created by the unregistered version of CHM To POF Converter by Theta Sottware Observer Observable Observer Observable FileSaver Button Alternatively you can show the instances that make up a collaboration outside of the collaboration ellipse and use communication links to tie them back in In this case you don t specify the role name inside the classifiers instead you write the role name
214. on about the interface that is being realized UML provides a third black box representation of components using realization and dependency relationships to interfaces If a component provides an interface use a realization arrow from the component to the interface If the component requires an interface use a dependency arrow from the component to the required interface Figure 5 6 shows the same three components asFigure 5 2 but with explicit interface dependencies Figure 5 6 Components with explicit interface dependencies This page was created by the unregistered version of CHM To POF Converter by Theta Sottware component E AccountManagement i A iue i interface interface Identity Verifier TransactionLogger a component components CreditCardServices Logger An advantage to the interface dependency style of modeling is that you can attach other modeling elements such as a state machine or use case to an interface This is particularly useful when a component implements a protocol because you can link the provided interface to a protocol state machine to further clarify the component s usage see Protocol State Machines in Chapter 8 5 2 1 3 Component compartments UML also provides a black box view of components using compartments You may add a compartment to show provided and required interfaces Label provided interfaces with the stereotype providedinterfaces and required interf
215. on and associations and 2nd 3rd compositions and connector ends generalization relationships and of attributes port properties representation 2nd 3rd XML elements and multiplicity element operations Fa PREY E This page was created by the unregistered version of CHM To POF Converter by Theta Sottware 4 PREV NEXT Index SYMBOL A B C D E F G H H J K M N O P Q R S CO U M W X name compartment name element operations names association classes and attribute syntax element 2nd connectors and elements postcondition precondition qualifying state use cases and 2nd variable 2nd naming conventions abstract classes 2nd associations concrete models and naming conventions operation syntax elements operations parameters preconditions of representation state machines navigability aggregation and associations and compositions and neg interaction operator nesting devices message calls stereotypes nodes activity artifacts and central buffer data store defined exception handling overview representation 2nd not logical operator not operator notEmpt operation 2nd notes This page was created by the unregistered version of CHMI To POF Converter by Theta Sottware modeling and specifying constraints in state invariants and number datatype 4 PREV NEXT This page was created by the unregistered version of CHM To POF
216. on near the owned class See Attribute Multiplicity for the allowable multiplicity types Note that when you use multiplicity with an association you don t use Square brackets around the values Figure 2 25 shows an association with explicit multiplicity Figure 2 25 A simple association showing four Buttons in a Window Window wi a Button The properties related to multiplicity may be applied to associations as well See Properties for the names and definitions of allowed properties 2 6 3 Aggregation This page was created by the unregistered version of CHM To POF Converter by Theta Sottware Aggregation is a stronger version of association Unlike association aggregation typically implies ownership and may imply a relationship between lifelines Aggregations are usually read as 0WNS a For example if you had a classed named window that stored its position and size in a Rectangle class you would say the Window OWNS a Rectangle The rectangle may be shared with other classes but the Window has an intimate relationship with the Rectangle This is subtly different from a basic association it has a stronger connotation However it s not the strongest relationship you can have between classes If the relationship is more of a whole part class A iS part of class B you should look at composition You show an aggregation with a diamond shape next to the owning class and a solid line pointing to the owned clas
217. one engine Figure 2 4 Attribute using relationship notation Engine Car numCylinders int engine horsePower float manufacturer string Note that when using relationship notation you can I show arbitrarily complex attributes Of course you r l can hide the attribute compartments as well if that makes the model clearer Yes yes as my editor pointed out some cars like the Toyota Prius have two engines Work with me here Relationship notation supports the same syntax as inlined notation though the layout is slightly different The attribute s visibility and name are placed near the relationship line Don t use square brackets for multiplicity but do place the multiplicity specification near the attribute s classifier Like multiplicity you can place constraints on attributes see Constraints In relationship notation you write constraints near the attribute s classifier along the relationship line UML allows relationship notation to also express constraints between attributes as shown in Figure 2 5 Figure 2 5 Relationship notation using constraints This page was created by the unregistered version of CHM To POF Converter by Theta Sottware automaticlransmission AutomaticTransmission Ls i E manualTransmission InFigure 2 5 the standard UML constraint xor shows that only automaticTransmission OF manualTransmission Can be set at any given time exclusive or You need to expr
218. or embedded systems Unlike sequence diagrams timing diagrams are read left to right rather than top to bottom You show a lifeline name along the left edge of the diagram The various states of the lifeline are then listed followed by a graphical representation of the transitions between these states Figure 10 40 shows an example of a timing diagram in which the MailServer object progresses through several states InFigure 10 40 the MailServer starts in the Idle state until the Login event occurs The Login event causes the MailServer to transition to Authenticated When the sendMail event occurs the MailServer transitions to transmitting and remains there until disconnected Figure 10 39 Example of an interaction overview diagram This page was created by the unregistered version of CHMI To POF Converter by Theta Sottware sd System Authentication lifelines AuthenticationService DataStore EncryptionService UserCredentials ae j p encryptstring password i a retrievePassword usemame sd setValiditrue setAccessPriviprivs Figure 10 40 Simple timing diagram This page was created by the unregistered version of CHMI To POF Converter by Theta Sottware ro TT sd Mail server poe Steso conditions Line indicating the j i Transmiting as e7 T DT current state of the lt Authenticated and Idle Trantmitting i feline l i a ee S P Ee E
219. oration except that you list the name of the occurrence followed by a colon and then the name of the collaboration type For each role used in the original collaboration you draw a dashed line from the collaboration occurrence to the element fulfilling the role You label the dashed line with the name of the role For example a collaboration occurrence of our Observer Observable collaboration is shown in Figure 4 18 Figure 4 18 Two collaboration occurrences of the Observer Observable collaboration Translator WAPGateway Gloer Observer Observable an Observable ProtocolConverter DataSource Observable WirelessCarrier Observer Observable Observer WAP Device This page was created by the unregistered version of CHMI To POF Converter by Theta Sottware PREY NEXT W Chapter 5 Component Diagrams When modeling large software systems it is common to break the software into manageable subsystems UML provides the component classifier for exactly this purpose A component is a replaceable executable piece of a larger system whose implementation details are hidden The functionality provided by a component is specified by a set of provided interfaces that the component realizes see Black Box View In addition to providing interfaces a component may require interfaces in order to function These are called required interfaces The functionality of a component s provided interfaces is im
220. ore salient the features appear in relief Several diagrams each with a different purpose provide a clearer understanding than one diagram that has all the details When diagramming consider the purpose The following sections detail several errors that compromise the effectiveness of UML 12 1 2 Structure and Interrelationships Among Classes Figure 12 1 shows a class diagram cluttered by details It gives no insight Figure 12 2 shows This page was created by the unregistered version of CHM To POF Converter by Theta Sottware the same classes without attributes and operations More than half the diagram is an understandable inheritance tree Rid now of clutter what s left becomes readable The converging lines draw the eye to Component at the center You can clearly see the relationships between the abstract classes and various interfaces The subclasses clearly add individual behavior without adding any structure The diagram works Once you understand the structure you can find the details of operations and attributes elsewhere in such places as source comment extraction tools such as Javadoc supplied with the standard Java SDK from Sun or CppDoc check for it athttp www cppdoc com Figure 12 2 The structure of commonly used components within the Java AWT layoutM anager O ImageObserver LayoutManager a ComponentPeer Figure 12 2 illustrates that good diagramming doesn t need to show everything Effect
221. oring many small diagrams outweighs the benefits of the clarity those diagrams provide at least in the early stages of design Once you understand the model and are comfortable with it you can fission the resultant model more easily into packages and concise diagrams Ease during this phase validates the model s completeness pain in diagramming indicates incompleteness in modeling Details forgotten against the vastness of the model stand out when the focus narrows to a very small context Your documentation UML and otherwise must answer when you are absent When you re publishing a guide to a toolkit framework or system your audience will fail to exploit your offering without clear and focused diagrams At the same time once the model is clearly understood and concisely presented discard the playground diagrams to avoid confusion As with any other endeavor shortcuts can be appropriate If only you or an application generator access a model you don t need to publish it for others If the model is implicitly valid or you have better validation mechanisms such as model checkers you need not bother creating concise diagrams A code generator for example doesn t care about understandable diagrams No one diagram is definitive in all aspects To be effective a diagram must have unity of purpose As a 2D view of the model a diagram necessarily leaves out details in order to emphasize important features The more economic the details the m
222. orough meant for those who understand the basics and want to know the nitty gritty of a piece of UML Subsequent sections are kinder gentler discussions of the topic This includes examples that show how the topic may be applied to typical problems help you further refine your models to eliminate ambiguity capture details that might otherwise be lost or add information to your model that aids in tool based development A brief word of warning UML has a strict terminology for just about every aspect of modeling This is necessary to reduce ambiguity and confusion as much as possible However in everyday use some terms are used interchangeably with others that have completely different meanings in UML A classic example of this is operation and method These are frequently treated as being synonymous in a software development environment but have different meanings when used in the context of UML We will make a point to use the correct UML term even if it may not be the most colloquial name PREY NEXT 1 This page was created by the unregistered version of CHM To POF Converter by Theta Sottware PREY NEXT How to Use This Book This book is divided based on UML diagram type Obviously there is some crossover as some diagrams build on concepts from others Chapter 1 Fundamentals of UML covers the basics of UML and presents some background information that will help you understand the context for the rest of the book If you ar
223. otocol SMTP protocol Because protocol state machines don t not allow activities there is little detail about what the SMTP server actually does when receiving a command from the client By design the protocol state machine tells you only what state the protocol implementation will be in not what it does to get there or how it keeps itself occupied See Variations on Statechart Diagrams for an example of modeling a protocol in more detail KI NEXT W This page was created by the unregistered version of CHM To POF Converter by Theta Sottware PREY NEXT 1 8 5 Pseudostates Pseudostates are special types of states that represent specific behavior during transitions between regular states Combined with basic transitions pseudostates can represent complex state changes within a state machine Figure 8 17 A simplified SMTP protocol state machine Receive SMTP Mail protocol eval sarder address gnac MAIL FROM ae Idle Connected SS d Sender valid sender actress MAIL FROM ROPT TO GUT Message SEP SGN Retelving dis Recipients Queued Meseage Dats Approvod i I Character data Table 8 1 shows the types of pseudostates and their symbols Refer to Figure 8 1 for an example showing how these symbols are used Table 8 1 Types of pseudostates peeucostate Symbol Description name Initial The starting point of a state machine The transition pseudostate from the initial pseudostate to the first full
224. otype enclosed in guillemots Figure 11 4 A class and an attribute with two stereotypes each Form StrutsForms CarRegistration keyn StrutsField id A PREY NEKT W This page was created by the unregistered version of CHM To POF Converter by Theta Sottware PREY NEXT W 11 3 Tagged Values Having established an element s role within a system with a stereotype the element likely needs information not available from the core UML to fulfill its role The stereotype defines a number of tagged values Each tagged value is typed with a datatypenumber string boolean or user defined enumeration The upcoming section UML Profiles shows one way in which you might record or define the tagged values that you wish to include in a stereotype When you show them in a diagram place the tagged values in a note element that is connected to the declaring element with a dashed line Figure 11 5 shows the case of multiple stereotypes on one element To keep the stereotypes and the corresponding tagged values clear each stereotype is mentioned and the tagged are values listed separately Figure 11 5 Tagged values shown classified by their owning stereotype Form RequiresValidation false Forms Template secure 001 ProjectManagement _ CarRegistration ProjectManagement Author Boris Doc Laurie Ann At first you may confuse tagged values with attributes but they exist at a different level
225. ourse registerStudent s Student boolean pre s tuitionPaid true When writing postconditions you can use the keyword result to refer to the value returned by an operation The following expressions verify that a student s tuition was paid before registering for a course and that the operation registerStudent returned true context Course registerStudent s Student boolean pre s tuitionPaid true post result true As you can with invariants you can name preconditions and postconditions by placing a label after the pre or post keywords context Course registerStudent s Student boolean pre hasPaidTuition s tuitionPaid true post studentWasRegistered result true Postconditions can use the pre keyword to refer to the value of some element before an operation executes The following expression ensures that a student was registered and that the number of students in the course has increased by 1 This expression uses the self keyword to reference the object that owns the registerStudent operation context Course registerStudent s Student boolean pre s tuitionPaid true post result true AND self students self students pre 1 You may specify the results of a query operation using the keyword body Because OCL doesn t have syntax for program flow you are limited to relatively simple expressions The following expression indicates that honors students are students with GPAs higher than 3 5 The collection
226. ow network configurations Properties and tagged values can be used to show network configuration options rather than machine hardware details Figure 6 20 shows an example network modeled as a deployment diagram Be warned though deployment diagrams were not designed with network modeling in mind so a professional network administrator may find the syntax lacking This page was created by the unregistered version of CHM To POF Converter by Theta Sottware Figure 6 20 A sample network topology using a deployment diagram aiesktops Betty iPAddr DHCP ed evices WebServert aCAToe WPAgdr 192 163 20 10 i firewalls ethers efirewalls inet Gatewny DMZ 4G ntewny lt dMabasoe IPAddr a 216 239 390 099 iPAddr 1921680100 DEServer e iPAddr 10 1 0 50 gpenPoria 90 443 eflbers gapanta 506 i a CATS iPAddr 192 162 0 20 adoekiopes rf iPAddr DHCP a PREY NEXT W This page was created by the unregistered version of CHM To POF Converter by Theta Sottware PREY NEXT Chapter 7 Use Case Diagrams Use cases are a way to capture system functionality and requirements in UML Use case diagrams consist of named pieces of functionality use cases the persons or things invoking the functionality actors and possibly the elements responsible for implementing the use cases subjects A PREY NEKT W This page was created by the unregistered version of CHMI To POF
227. p a Authenticated mandhal z prenerien Le idle l i Lifeline et g Login Disconnect eee Eee i i i i i ies ee eaa re ee Messages that triggar the changes in state I 28 When reading the diagram left to right you can use the length of the timeline to indicate how long the object remains in a particular state To associate time measurements you show tick marks along the bottom part of the frame as shown in Figure 10 41 Figure 10 41 Timing diagram with tick marks sd Mail server _ Transmitting a ue T u E Authenticated sendMail idle Login Disconnect 01 23 t Figure 10 41 shows that the Login event is received three time units after the start of the sequence To show relative times you can mark a specific instance in time using a variable name Figure 10 41 marks the time the sendMail event is received as time t You can use relative time marks in constraints to indicate that a message must be received within a specified amount of time Figure 10 42 shows the Disconnect message must be received within 10 time units of the sendMail event You can show multiple objects involved in a timing diagram by stacking the lifelines You show messages between objects using an arrow from one timeline to another The start and end of the arrow correspond to when the message is sent and received This notation shows the triggers that cause a transition however it Figure 10 42 Timing diagram with time constr
228. pOata addT extureimapData l may also use a guard condition that is evaluated each time through the loop to terminate execution The syntax for the operator is loop min max This page was created by the unregistered version of CHM To POF Converter by Theta Sottware where both min and max are optional If max is excluded max equalS min max may be an asterisk to indicate an infinite loop or at least while the guard condition evaluates to true If both min and max are excluded min equals 0 and max equals infinity in this case you likely want to have a guard condition to prevent the loop from executing indefinitely Figure 10 29 shows the rendering loop modeled in Figure 10 25 In this sequence diagram the looping is explicitly shown with a guard condition that will terminate the loop when the user has set the quit flag to be TRue There is also an inner loop that instructs the MapLoader to execute while there are maps to load Figure 10 29 Example of a loop operator getlapDatal add Texture mapData loop 0 pendingMaps count critical P gelMapDeatat decomaressDatat queue ManDatal PREY NEXT 1 This page was created by the unregistered version of CHM To POF Converter by Theta Sottware PREY NEXT 1 10 9 Interaction Occurrences Aninteraction occurrence is shorthand for copying one interaction into another larger interactior example you can c
229. participating in an internal structure They can be runtime instances of associations or they can represent dynamic communication set up at runtimefor example by being values of local variables You show a connector as a solid line between two instances Note that while associations between classes represent a link between any instances of those classes a connector represents a link between only the two instances specified at each end of the connector see Collaborations You can provide name and type information for a connector using the following format name classname where name Is the name of the connector The name can be used later in collaborations to reference this connector classname Is the name of an association this connector represents Figure 4 1 is an example of a named connector Figure 4 1 The link between a Pedal and a Wheel is a connector named c which is a Chain This page was created by the unregistered version of CHM To POF Converter by Theta Sottware Pedal Wheel c Chain UML specifies several rules for determining the types of the elements at each end e If a connector is an instance of an association the types of the instances at either end of the connector must be the same types at either end of the association e If an instance at one end of a connector has required interfaces the instance at the other end of the connector must provide one of those interfaces e If an instance at one end o
230. partition Figure 9 26 shows examples of naming partitions directly on the node and using external partitions Figure 9 26 Activity diagram with external partitions labeled on the actions Hire Employee Human Resources cenherriale bes ar Paar Prepare Benefits New Hire information to burg img Paperwork Sign Paperwork cena Company Human Resources Confirm Employee i Arcepance IT Dopartmenij k Sat Up User Account NEN Facilities Management 1 Sel Up Office Space j i TA this activity diagram the New Hire is maponsibe for signing tht benefits paperwork Sinot the New Hire is outside of ihe immediate business process he mothe is marked es extemal A partition has no effect on the data flow in an activity however depending on the entity represented by the partition there are implications on how actions are handled If a partition represents a UML classifier any method invocation within that partition must be handled by an instance of that classifier If the partition represents an instance the same restrictions apply except that behaviors must be handled by the specific instance referenced by the partition For example if you are modeling a system that has a partition named LoginService all actions performed within that partition should be handled by an instance of your LoginService However if you have a partition that represents an instance of a User class namedcurrentuser all actions
231. pen to interpretation Either way well written UML is more effective While it may be true that a picture is worth a thousand words a picture with words is worth much more than just a picture Perhaps in the context of MDA and executable models UML can provide a minimum specification for an application generator In most cases complete system specification or system documentation requires commentary to explain emphasize and give nuance to the diagrams Diagrams alone risk burying or glossing over details as much as text alone Diagrams and text reinforce each other You can describe the context and Figure 12 8 Package imports impl from dav deploymentdes cnplors from cab common from generic major points with text then drive home those points with a good diagram and the formalism of UML This page was created by the unregistered version of CHM To POF Converter by Theta Sottware As seen throughout this chapter you can t effectively document classes with large APIs ona single class diagram Hundreds of attributes and operations become insignificant on a diagram The operation and attribute sections of a class box don t allow for descriptions Tools such as Doxygen http www doxygen org or Javadoc extract the most current source comments into searchable web pages Though the details they present are likely to change and therefore will make diagrams obsolete when they are made part of the software build proces
232. pendency This page was created by the unregistered version of CHMI To POF Converter by Theta Sottware component AccountManagement component 3 component CreditCardServices Logger Representing component dependencies in this fashion is a relatively high level view of a system To further refine the diagram you may want to show inter component relationships as dependencies on the interfaces provided by other dependent components see Black Box View also see Interfaces in Chapter 2 a PREY NEKT W This page was created by the unregistered version of CHMI To POF Converter by Theta Sottware PREY NEXT 1 5 2 Component Views UML uses two views of components a black box view and a white box view The black box view shows a component from an outside perspective the white box view shows how a component realizes the functionality specified by its provided interfaces 5 2 1 Black Box View The black box view of a component shows the interfaces the component provides the interfaces it requires and any other detail necessary to explain the guaranteed behavior of the component It does not specify anything about the internal implementation of the component This distinction is central to the concept of replaceable components 5 2 1 1 Assembly connectors When modeling a black box view of a component you represent the provided and required interfaces using assembly connectors Assembly co
233. perform credit card payment verification The actual implementation of this functionality may be spread over several classes working in conjunction The organization of these classes can be represented as an internal structure within the subsystem and the overall functionality or credit card verification can be exposed using a port Exposing the functionality through a port allows the subsystem to be used by any other classifier that conforms to the port s specifications Starting with UML 2 0 classes have been extended to allow for ports and internal structures By default ports are public however UML 2 0 allows you to have internal ports that are available only to the composite structure hosting them You show a port as a small square You typically draw the name and multiplicity of the port near the square though both may be hidden If you draw the port on the edge of a classifier the port is public and is available to the environment If you draw the port inside a classifier the port is protected and available only to the composite structure Figure 4 4 shows an example port Figure 4 4 The CreditCardVerificationSubsystem with a single public port CreditCardServices subsystem CreditCardVerificationSubsystem CreditCardServices Lt 4 1 2 1 Required and provided interfaces Ports are associated with required and provided interfaces see Interfaces in Chapter 2 Required interfaces show what the owning classifier may ask o
234. ph of modified JMeter with three cycles This page was created by the unregistered version of CHM To POF Converter by Theta Sottware Dependency Level i 2 visualizers A PREY NEKT W This page was created by the unregistered version of CHMI To POF Converter by Theta Sottware PREV NEXT Chapter 4 Composite Structures As a system becomes more complex it is often helpful to decompose it in terms of functionality see Chapter 7 To realize a piece of functionality different elements of a system often work together and communicate information UML 2 0 formalizes the concept of complex relationships between elements into the idea of composite structures Much of the material in this chapter is new to UML 2 0 PREY NEXT 1 This page was created by the unregistered version of CHM To POF Converter by Theta Sottware PREY NEXT 1 4 1 Composite Structures Astructure is a set of interconnected elements that exist at runtime to collectively provide some piece of functionality For example you can use a structure to represent the internal makeup of a classifier such as a subsystem what objects are related to each other who is communicating with whom etc UML calls such structures internal structures UML defines several symbols to capture the relationships and communications between elements in an internal structure 4 1 1 Connectors Connectors represent communication links between instances of classes
235. plemented with one or more internal classifiers These are typically classes but can be other components see White Box View Components should be designed to be reused with dependencies on external interfaces strong encapsulation and high cohesion PREY NEXT W This page was created by the unregistered version of CHM To POF Converter by Theta Sottware fa Prey NEXT 5 1 Components In UML 2 0 you represent a component with the classifier rectangle stereotyped as component Like other classifiers if the details of the component aren t shown you place the name of the component in the center of the rectangle Optionally you may show the component icon a rectangle with two smaller rectangles on the left side in the upper right corner Figure 5 1 shows a simple component Figure 5 1 A simple component component 3 AccountManagement The representation for a component has changed from previous versions of UML UML 1 4 recognized a rectangle with two smaller rectangles _ Component This notation is still recognized for backward compatibility but is no longer recommended 5 1 1 Component Dependencies Components may need other components to implement their functionality You can show component dependencies using the dependency relation a dashed line with an open arrow between the two components Figure 5 2 shows the AccountManagement Component dependent on two other components Figure 5 2 Component de
236. posite state conflicting transitions and defined 2nd transitions 2nd out keyword 2nd output pins expansion regions object nodes and representation streaming ownership 2nd 4 PREV NEXT W This page was created by the unregistered version of CHM To POF Converter by Theta Sottware 4 PREV NEXT Index SYMBOL A B C D E F G H N J K M N O P Q R S CO U M W X package diagrams defined directed dependency graphs functionality importing and accessing 2nd merging 2nd representation 2nd SPEM and structuring projects with use case packages visibility 2nd packages defined directed dependency graphs importing and accessing 2nd merging 2nd representation 2nd structuring projects with use case visibility 2nd packages visibility 2nd par interaction operator parallel execution parameter nodes 2nd parameter sets parameter_name element operations parameterized classes parameters activities and events and interaction occurrences mapping method calls and arentheses 2nd part decomposition participants partitions activity PIM Platform Independent Model 2nd pins pipe Platform Independent Model PIM 2nd Platform Specific Model PSM 2nd plus sign OCL operator 2nd visibility 2nd ports This page was created by the unregistered version of CHM To POF Converter by Theta Sottware bidirectional composite structures and connectors and
237. r i gt Serve Meal hy Wash Vegetables gt Steam Vegetables ae F w _ Bake Potatoes k pu p a e ea numGuests numinvitedGuests k Greet Guests H a LN F Fi E p mee o ee o e e e o o o e e o e ee o p e e e e oe e The join node won t aloa execution to flow to the Serve Meal action until all of the guests have arrived Famina EN aa ee E E re EE ARREA sash branch of the fork should be stopped but the others may continue Show a flow final node as a circle with an X in it as shown in Figure 9 22 a PREY NEXT W This page was created by the unregistered version of CHM To POF Converter by Theta Sottware PREY NEXT 1 9 4 Advanced Activity Modeling UML 2 0 introduces several powerful modeling notations for activity diagrams that allow you to capture complicated behaviors Much of this new notation is clearly targeted at moving closer to executable models with things such as executable regions and exception handling While not all the notations described in this section are used in every model these constructs are invaluable when applied correctly 9 4 1 Activity Partitions There are times when it is helpful to indicate who or what is responsible for a set of actions in an activity diagram For example if you are modeling a business process you can divide an activity diagram by the office or employee responsible for a set of act
238. r they aren t meant to illustrate diagram types The diagrams in the reference section don t represent systems that you will encounter in real life This final chapter illustrates some techniques you can use to make real life diagrams convey your thoughts more effectively A PREY NEXT W This page was created by the unregistered version of CHM To POF Converter by Theta Sottware PREY NEXT 12 1 Wallpaper Diagrams The classic novice class diagram displays all classes attributes operations relationships and dependencies for a system As the number of classes grows the diagram becomes huge and unmanageable Imprudent reverse engineering drags in clutter Figure 12 1 diagrams just a very small part of the Java Abstract Windowing Toolkit AWT You will not be able to read the diagram because it normally prints as an unwieldy nine pages You re paying for the paper so the diagram is shown here in a greatly condensed form Effective writers convey ideas through language constructs sentences and paragraphs organize text details reinforce ideas and true but irrelevant facts are omitted Modelers desiring to convey an ideabe it a structural overview a pattern implementation a detailed subsystem or the detailed context of one classmust also use economy and focus Figure 12 1 has neither economy nor focus The diagram throws a mass of insignificant detail at readers leaving the burden of understanding on them It is a false economy
239. r by Theta Sottware PREY NEXT Appendix B The Object Constraint Language The Object Constraint Language 2 0 OCL is an addition to the UML 2 0 specification that provides you with a way to express constraints and logic on your models For example you can use OCL to convey that a person s age must always be greater than O or that a branch office must always have one secretary for every 10 employees OCL isn t new to UML 2 0 it was first introduced in UML 1 4 However as of UML 2 0 it was formalized using the Meta Object Facility and UML 2 0 From a user s perspective the language has been updated and refined but the fundamentals remain the same This appendix introduces the basic concepts of OCL For more detailed information consult the OCL specification available from the Object Management Group s web site http www omg orgd a PREY NEKT W This page was created by the unregistered version of CHM To POF Converter by Theta Sottware PREY NEXT 1 B 1 OCL Basics The Object Constraint Language is just that a language It obeys a syntax and has keywords However unlike other languages it can t be used to express program logic or flow control By design OCL is a query only language it can t modify the model or executing system in any way It can be used to express preconditions postconditions invariants things that must always be TRue guard conditions and results of method calls OCL can be used virtually
240. r example you may have a Purchase Item interaction diagram that has a participant execute a credit card authorization The actual details of the authorization process are probably not of interest to the readers of your Purchase Item diagram however they are vitally important to the developers responsible for the authorization subsystem To help reduce clutter on your diagrams you can create a separate diagram showing how the authorization subsystem validates credit cards and place a decomposition reference to that on thePurchase Item diagram To create a part decomposition reference simply place ref interaction diagram name after the instance name in the head of your lifeline Figure 10 31 shows how the Purchase Item and authorization diagrams can be modeled Figure 10 31 Example of a decomposition diagram sd Purchase item _Paymenisubsys tam Customer Usar ref UPS complete Order La ventyPayment creditCardinto E Wue ship rder coniinmaton sd PaymentSubsystem Payment Authorization venfyPayment creditC ard nfs m coreales y 5 gt G werifhyCardHolderiverificationRequest i E true E cael fof it EEEIEE ER lO sass can lbs ce open hacen na TEENE E EEE This sequence diagram has two gates one to match the incoming werni Payment message and one to indicate the return value Rimes mmm meme eee e e This page was created by the unregistered version of CHM To POF Converter by T
241. r notation Figure 7 3 Use case in classifier notation This page was created by the unregistered version of CHM To POF Converter by Theta Sottware View Error Log lt lt extension points gt gt show Detailed Log UML makes a clear distinction that the term use case strictly applies to the UML element and its name Full documentation of a use case is considered an instantiation of the use case This is a subtle distinction but it allows you to document a use case whatever way best captures the use case s functionality You can document a use case in a text document state machine interaction diagram activity diagram or anything else that conveys the details of the functionality in a meaningful way to your reader a PREY NEXT This page was created by the unregistered version of CHMI To POF Converter by Theta Sottware PREY NEXT 7 2 Actors A use case must be initiated by someone or something outside the scope of the use case This interested party is called an actor An actor doesn t need to be a human user any external system or element outside of the use case may trigger the use case or be the recipient of use case results and should be modeled as an actor For example it is very common to model the system clock as an actor that triggers a use case at a given time or interval An actor can have several different representations in UML The first is a stick figure with the name of the actor written near the
242. r the composite state is executed before the substate becomes active This page was created by the unregistered version of CHM To POF Converter by Theta Sottware Whenever a state machine transitions to an orthogonal composite state a composite state with two or more regions each region is entered either explicitly or by default If the composite state is entered through an explicit entry any other region is entered using its default transition Figure 8 15 Transition oriented view with an activity k idle X StartGrinder gninders running true Grinding When leaving a composite state the exit activities for the active substates are executed from the inside out In other words the deepest of the active substate s exit activities executes first and then its containing substate and so on When exiting an orthogonal composite state the active substate in each region is exited first the exit activity for the composite state is then executed 8 2 4 Activities An activity represents some functionality that is executed by a system A state can have activities that are triggered by transitions to and from the state or by events raised while in the state A state s activities execute only if the state is active Each activity has a label showing when the activity executes and an optional activity expression An activity is written as label activity expression You can write an activity expression using pseud
243. r to any local data available to that lifeline or to any global data available to the overall interaction it can t refer to the local data of some other lifeline Figure 10 18 shows an example of an alternative interaction operator that models an if else condition See the description for each interaction operator to see when guard conditions are necessary and how they are used If you don t place a guard condition before an interaction fragment it is interpreted as a guard condition that always evaluates to true 10 8 2 Interaction Operators Each interaction operator defined in the UML 2 0 specification is explained in detail in the following sections Each operator has an associated number of operands and a keyword that is placed in the pentagon of a combined fragment 10 8 2 1 Alternatives Alternates are a choice of the behavior that executes based on guard conditions placed before each operand The interaction operator is alt You may include an else guard condition that executes the associated operand when the other conditions are false Figure 10 18 shows this Figure 10 18 Example alternative operator This page was created by the unregistered version of CHMI To POF Converter by Theta Sottware ad Poy with erodit card User er IN a aa Recep SubrnitPayrmantiniorctathcr _ veii Tana acres a ree pl ai rocoipt Paid tron i ahipiindan i ea EF 4 ail I g cenirmatonhiambar interaction A pr
244. rafted for professionals like you who must read create and understand system artifacts expressed using UML Furthermore it s been fully revised to cover version 2 0 of the language This comprehensive new edition not only provides a quick reference to all UML 2 0 diagram types it also explains key concepts in a way that appeals to readers already familiar with UML or object oriented programming concepts Topics include e The role and value of UML in projects e The object oriented paradigm and its relation to the UML e An integrated approach to UML diagrams e Class and Object Use Case Sequence Collaboration Statechart Activity Component and Deployment Diagrams e Extension Mechanisms e The Object Constraint Language OCL If you re new to UML a tutorial with realistic examples has even been included to help you quickly familiarize yourself with the system This page was created by the unregistered version of CHM To POF Converter by Theta Sottware PREY NEXT W UML 2 0 in a Nutshell by Dan Pilone with Neil Pitman Copyright 2005 O Reilly Media Inc All rights reserved Printed in the United States of America Published by O Reilly Media Inc 1005 Gravenstein Highway North Sebastopol CA 95472 O Reilly books may be purchased for educational business or sales promotional use Online editions are also available for most titles safari oreilly com For more information contact our corporate institutiona
245. re are several types some with very specific purposes timing diagrams and some with more generic uses class diagrams The following sections touch on some of the major ways UML has been employed The diagrams mentioned in each section are by no means confined to that section If a particular diagram helps you convey your message you should use it this is one of the basic tenants of UML modeling 1 3 1 Designing Software Because UML grew out of the software development domain it s not surprising that s where it still finds its greatest use When applied to software UML attempts to bridge the gap between the original idea for a piece of software and its implementation UML provides a way to capture and discuss requirements at the requirements level use case diagrams sometimes a novel concept for developers There are diagrams to capture what parts of the software realize certain requirements collaboration diagrams There are diagrams to capture exactly how those parts of the system realize their requirements Sequence and statechart diagrams Finally there are diagrams to show how everything fits together and executes component and This page was created by the unregistered version of CHM To POF Converter by Theta Sottware deployment diagrams Books describing previous versions of UML made a point to emphasize that UML was not a visual programming language you couldn t execute your model However UML 2 0 changes the rules somewha
246. reate an interaction that simply shows user authentication and then referenc an interaction occurrence in larger more complete interaction diagrams The syntax for an interaction occurrence is a combined fragment rectangle with the interaction c Place the name of the referenced interaction in the rectangle UML allows parameters to be pass referenced interactions using the following syntax attribute name collaboration OCCUrrenCe interaction mame argumente J 2s where attribute name Is an optional part of the syntax that specifies what attribute the return value should be a The attribute must be an attribute of a lifeline in the larger interaction Collaboration occurrence Is an optional scoping of the referenced interaction if it is part of a larger collaboration interaction name Is the name of the interaction to copy arguments Is a comma separated list of arguments to pass to the referenced interaction The argume values or parameter names If only argument values are used arguments are matched ac interaction parameters in order If you want to skip an argument you place a dash wl argument would be Skipped arguments have unknown values You may explicitly identify name by following its text name with a colon and then the value If you use parameter may omit arguments not relevant to the interaction As with a dash skipped arguments h values You may prefix an argument with the keyword out or inout to i
247. red protocol behavior Behavioral and protocol state machines share common elements however protocol state machines are not tied to an implementation and have restrictions on their transitions Because protocol state machines are a specialization of behavioral state machines this chapter first discusses behavioral state machines and other topics common to all state machine diagrams then details of protocol state machines are explained PREY NEXT 1 This page was created by the unregistered version of CHM To POF Converter by Theta Sottware PREY NEXT 1 8 1 Behavioral State Machines State machines represent the behavior of a piece of a system using graph notation A state machine is shown using the basic rectangle notation with the name of the state machine shown in the top compartment The outside rectangle is often omitted on state machine diagrams that show only a single state machine The metaclass is simply state machine Figure 8 1 shows a simple state machine modeling a soda machine Figure 8 1 A basic state machine I ed conden fo preved changing states unb their ae m m Ca Soda Machine pir A Leii eee SFG dopoki conn dence tend forks drink coal hokd coin in bemp bin state wan depasi com hotd coin in bap ban depot coln deposiled furta gt drink cost hoki ogn in Lanng Een ado l 5 ih Waiting fer funds LO Waiting for selection eee zl hile i y
248. registered version of CHM To POF Converter by Theta Sottware 4 PREV NEXT Index SYMBOL A B C D E F G H H J K M N O P Q R S CO U M W X 4 PREV NEXT This page was created by the unregistered version of CHM To POF Converter by Theta Sottware a PREY NEXT I Index SYMBOL A B C D E E G H U J K M N O P Q R S L Y M W X pound sign 2nd parentheses 2nd asterisk loop operator looping constraints multiplicity value OCL operator 2nd plus sign OCL operator 2nd visibility 2nd comma 2nd dash arguments and comments and messages visibility 2nd minus sign 2nd dot 2nd 3rd forward slash deferred events derived notation OCL operator 2nd property instances and 4 1 views colon constraints and _interaction overview diagram object names and OCL and 2nd 3rd 4th parameter name and 2nd port typing lt less than lt lt access gt gt keyword lt lt artifacts gt gt keyword lt lt attribute gt gt keyword lt lt bind gt gt keyword lt lt centralBuffer gt gt keyword lt lt class gt gt keyword lt lt component gt gt keyword lt lt create gt gt keyword 2nd lt lt database system gt gt stereotype lt lt datastore gt gt keyword lt lt decisionInput gt gt keyword lt lt depends gt gt keyword lt lt deploy gt gt keyword lt lt deployment sp
249. reotypes or tagged values You assign existing stereotypes You fill in the values appropriate to the tags Figure 11 2 Layers of abstraction in UML This page was created by the unregistered version of CHM To POF Converter by Theta Sottware amatameterodel Mio OMG 4 ainstance Ns ainstanceOte metamodel M2 h lt eaxtondse paa OMG Vendors i cinstanceOte Focus of UML 2 0 in a Nutshell samodel Mi f gt TheAnySystem Designers Specification cinstancelts runtime Mia TheAnySystem Operations Application Unless you are also building your own tooling for code generation reporting and or tracking you will employ the profile s as is AS a singleton for example the class needs certain supplementary information The code generator needs the same questions answered for every singleton no more no fewer It makes no sense to have a multithread safe true tagged value for one singleton if the code generator doesn t recognize it If it does recognize it every singleton should have it It really depends on the tool Some teams do build their own tooling Even then only the toolsmith works in the M2 layer and the modelers work in the M1 layer Changes in the M2 layer must be conservative because one new tagged value in a stereotype can imply revisiting tens or hundreds of elements in the model Changes in the M2 layer literally change the fundamental meaning of an M1
250. resents is a signal draw the node as a concave pentagon See Figure 9 37 in Interruptible Activity Regions for an example of a signal in an activity diagram 9 3 3 Pins UML defines a special notation for object nodes called pins to provide a shorthand notation for input to or output from an action For example because the action Ship Parts in Figure 9 14 requires a Part you can define an input pin on Ship Parts labeled Part You show a pin using the same rectangle as for object nodes except the rectangle is small and attached to the side of its action If it is an input pin any edges leading into the action should point to the input pin if it is an output pin any edges leaving the action should leave from the pin Figure 9 15 shows the Create Parts diagram rewritten using pins Figure 9 15 Actions with input and output pins Create Parts d Part Part Process Steel a Ship Parts O o _ O i o E a O M O o If the output from an action is related to an exception error condition you indicate that the pin is an exception pin by inserting a small arrow near the pin Figure 9 16 shows the Create Parts action with error handling Figure 9 16 Activity diagram with an exception pin This page was created by the unregistered version of CHM To POF Converter by Theta Sottware _ Create Parts f If there is a problem I s Notify Maintenance during steel processi
251. rgone significant changes with UML 2 0 they have been promoted to first class elements and no longer borrow elements from state diagrams A PREY NEXT W This page was created by the unregistered version of CHM To POF Converter by Theta Sottware PREY NEXT 1 9 1 Activities and Actions An activity is a behavior that is factored into one or more actions An action represents a single step within an activity where data manipulation or processing occurs in a modeled system Single step means you don t break down the action into smaller pieces in the diagram it doesn t necessarily mean the action is simple or atomic For example actions can be e Mathematical functions e Calls to other behaviors modeled as activities e Processors of data attributes of the owning object local variables etc Translating these into real examples you can use actions to represent e Calculating sales tax e Sending order information to a shipping partner e Generating a list of items that need to be reordered because of low inventory When you use an activity diagram to model the behavior of a classifier the classifier is said to be the context of the activity The activity can access the attributes and operations of the classifier any objects linked to it and any parameters if the activity is associated with a behavior When used to model business processes this information is typically called process relevant data Activities are intended
252. ronment is expected to provide specific services to hosted artifacts by means of mutually agreed upon interfaces For example a Java 2 Enterprise Edition J2EE application expects to run in a software environment called an Application Server The J2EE specification enumerates several services that should be provided by an Application Server such as database connectivity lifecycle contracts and resource location You can express that a node is an Application Server and therefore provides the required services by defining a stereotype for the node For example a typical This page was created by the unregistered version of CHMI To POF Converter by Theta Sottware stereotype for an Application Server is J2EE Container Figure 6 6 shows an Application Server execution environment Figure 6 6 A J2EE execution environment aJZEE Container JBoss You can specify how services provided by the execution environment are configured using configuration files or deployment specifications see Deployment Specifications An execution environment is technically a node by itself but is typically shown as part of another hardware based node For example a J2EE Container may itself be hosted on a machine named AppServerl You can show the hosting relationship by embedding the execution environment in the hardware node or by using a composition arrow Figure 6 7 shows both representations Figure 6 7 Two representations of an execution environm
253. roperties to the UML collection type Note that the collection types shown in Table 2 1 are UML mappings and may not map directly to classes in a target language Table 2 1 Collection types for attributes Order Uniqueness Associated collection type False False Bag True True OrderedSet False True Set True False Sequence For example to show that a bank s clients should be represented using an orderedSet YOU can model the clients attribute as shown in Figure 2 10 Figure 2 10 Example attribute stored in an OrderedSet Bank clients AccountHolder 0 ordered unique 2 2 5 Attribute Properties In addition to the properties associated with multiplicity an attribute may have a number of properties set to convey additional information to the reader of the diagram The common properties defined by UML are This page was created by the unregistered version of CHM To POF Converter by Theta Sottware readOnly Specifies that the attribute may not be modified once the initial value is set This typically maps to a constant in a development language UML doesn t specify when the initial value must be set though if you specify the default value for an attribute it is considered the initial value and may not be changed union Specifies that the attribute type is a union of the possible values for this attribute Frequently this is used with the derived property to indicate that an attribute is a derived union of another
254. rrence to capture the time of the occurrence or place a timing constraint on it Typically you use a variable to capture a specific instance in time and then represent constraints as offsets from that time Constraints are expressed like state invariants and placed next to the event occurrence For example if you want to express that a credit card authorization system must return approval or denial within three seconds of placing the request you can place time constraints on the event occurrence as shown in Figure 10 37 PRE NEXT W This page was created by the unregistered version of CHM To POF Converter by Theta Sottware fa Prey NEXT 10 13 Alternate Interaction Notations UML provides several notations for capturing interactions The first part of this chapter used the sequence diagram notation The remainder of this chapter describes the other notations available and when they may be more appropriate than sequence notation Figure 10 36 The final sequence with all continuations expanded sd Login EncmptionSerice Authentication Service perena anti i authentcateUseriusername password e encryptString password retievePassword username creates alt ma encrypledPassword sloredPassword setValid true p seticcessPrivionivs logSuccess credentials Usemame date H else setValidifalse setReason invalid password E logFailure credentials Reason credenti
255. rter by Theta Sottware This page was created by the unregistered version of CHM To POF Converter by Theta Sottware PREY NEXT 1 6 2 Nodes A node is a physical entity that can execute artifacts Nodes can vary in size from a simple embedded device to a server farm Nodes are a critical piece of any deployment diagram because they show where a particular piece of code executes and how the various pieces of the system at the execution level communicate You show a node as a 3D box with the name of the node written inside However possibly more than any other classifier in UML modelers typically use specific icon representations of nodes to help convey the type of hardware represented Figure 6 5 shows a simple node as a cube as well as example icon representations Figure 6 5 Several nodes using the cube representation and some example icon representations WebServer WebServer ae Database Database Previous versions of UML did not define any specializations of a node UML 2 0 specializes a node into two different aspects of hosting code the required software and the required hardware Therefore it is less common to see a generic node in UML 2 0 diagrams than it was in UML 1 x See Execution Environments and Devices for more information 6 2 1 Execution Environments Anexecution environment is a specialized node that represents a software configuration hosting specific types of artifacts An execution envi
256. s As you ve seen in Figure A 1 the number of models increases as you go from the abstract to the concrete How abstract models become transformed into more concrete models will be discussed a little later For now suffice it to say that some function transforms them Several concrete models can come from a single abstract model At any one level of abstraction the model presents the system without the messiness of implementation details found in the more concrete downstream models Effective model transformation demands precise implementation details Decisions at one layer imply gross differences at the next more concrete layer Consider the following business rules e There are only a few 50 states and they don t change e Account transactions can be added but never changed or deleted and there can be hundreds of thousands of transactions for one account e Account balances are updated very often but account contact information is updated relatively rarely compared to the number of times it s read Changes must be audited If similar code were to be generated to manage these data entities you would have a very poor system To live up to its moniker MDA must provide some clue in the business model to differentiate between these cases The business layer doesn t involve itself with design issues such as data access patterns but it must provide hints These hints are design decisions Models provide implicit hints through the stru
257. s Figure 2 26 shows an example aggregation between a class namedwindow and a class named Rectangle Figure 2 26 Window owns a Rectangle Window Rectangle As with the association relationship you can show navigability and multiplicity on an aggregation line See Association for examples 2 6 4 Composition Composition represents a very strong relationship between classes to the point of containment Composition is used to capture a whole part relationship The part piece of the relationship can be involved in only one composition relationship at any given time The lifetime of instances involved in composition relationships is almost always linked if the larger owning instance is destroyed it almost always destroys the part piece UML does allow the part to be associated with a different owner before destruction thus preserving its existence but this is typically an exception rather than the rule A composition relationship is usually read as is part of which means you need to read the composition from the part to the whole For example if you say that a window in your systemmust have a titlebar you can represent this with a class named Titlebar that is part of a class named Window You show a composition relationship using a filled diamond next to the owning class and a solid line pointing to the owned class Figure 2 27 shows an example composition relationship between a class named Window and a class na
258. s and joins leading to a set of target states High level transition A transition from a composite state If the destination of the transition is outside the composite state all the substates are exited and their exit activities are run followed by the exit activity of the composite state If the transition ends with a target inside the composite state the exit activity of the composite state isn t run This page was created by the unregistered version of CHM To POF Converter by Theta Sottware Figure 8 12 A state machine with several transitions I p ard ponibio bo preve changng Stabe unb the Lower hes dopo bod af kirE the Arink Gost i r E E o E l a l M o M o l k 4 Sada Machine gree se ees ne rye s Aee PEETA Sino capos comniiencsiied funds lt drink coal hold coin in tame bin state wa deposd cgin hold coin in teenp ban depost coinfdeposited funds gt drink cost boki coin in tamp ban ado i i act i Witing for funds Waiting for selection iF E a aid amp z aai Gof display ammount entered doi display Maka Seinction T See GHDH Capen ek Dispamsing Gull nur Ge bee reha bumis Gis persai Refunding chaage a change naluma Puii jetu Geen kvaj renum funds a e F Internal transition A transition between states within the same composite state The containing state isn t exited or reentered during the transition A transition directly from one region
259. s overview Abstract Windowing Toolkit AWT abstraction depicting diagrams and 2nd account concept of actions activity partitions defined event occurrences exception handlers active state 2nd activities defined 2nd overview 2nd 3rd protocol state machines and representation state machines and transitions and activity diagrams actions activities activity nodes defined design view and example interaction overview diagrams modeling notations process view and SPEM and tokens use cases and activity edges activity final nodes activity nodes activity partitions 2nd actor generalization actors generalization and overview use case diagrams and use cases and This page was created by the unregistered version of CHMI To POF Converter by Theta Sottware acyclic graphs 2nd adornments after keyword aggregation aliases attributes and alt interaction operator alternatives and logical operator 2nd 3rd angle brackets gt Application Server arguments boolean expressions and interaction occurrences messages arrows 2nd 3rd artifacts defined deployed deployment specifications and nodes and 2nd overview representation 2nd assembly connectors 2nd assert interaction operand assert interaction operator assertions 2nd association classes 2nd association qualifiers 2nd associations actors and use cases 2nd classifiers and 2nd instances of overview representation 2nd
260. s they remain up to date with the latest software changes Remember that diagramming requires neither model nor modeling tool UML practitioners often simply draw diagrams by hand or with simple drawing tools Modeling tools are expensive acquisitions in terms of time and distraction if not in money open source or proprietary UML tools take time to master Whiteboards notepads and simple drawing tools deliver much project value with no learning curve Use them until you are comfortable with UML and its place in the project With a firm understanding of UML and your process choosing a dedicated UML tool and changing your process to incorporate it becomes less risky Figure 12 9 Code generation directives dao impl impl from data from model from dao z3 Faj i ra B lt lt Implementation gt gt s eeDADnterface gt gt lt lt DA lmplementation gt gt madel from data deploymentdes _ criptors impl imp from ccb from entity from businessagent A x lt lt Descriptorimplementation gt gt lt lt Implementation gt gt lt lt mplementation gt gt lt lt LammdaProperties gt gt businessagent from och LamidaProperties from generic from Logical View This page was created by the unregistered version of CHM To POF Converter by Theta Sottware PREY NEXT W Appendix A MDA Model Driven Architecture This appendix summarizes Model Driven Architecture MDA Severa
261. s and 2nd representation SPEM and white box view internal activities compartment internal transitions 2nd interruptible activity regions inv keyword OCL invariant condition invariants assertions and constraints as expressions as overview states and isEmpty _ operation KEE NEXT I This page was created by the unregistered version of CHM To POF Converter by Theta Sottware 4 PREV NEXT Index SYMBOL A B C D E F G H H 3 K M N O P Q R S CO U M W X J2EE Java 2 Enterprise Edition J2EE Container java util package Javadoc tool join nodes 2nd join specification junction pseudostate 4 PREY NEKT I This page was created by the unregistered version of CHM To POF Converter by Theta Sottware 4 PREV NEXT Index SYMBOL A B C D E F G H CY J K M N O P Q R S K Y M W X keys 2nd 4 PREY NEXT W This page was created by the unregistered version of CHM To POF Converter by Theta Sottware PREY NEXT Index SYMBOL A B C D E F G H CY J K L M N O P Q R S L Y M W X labels 2nd 3rd language constructs 2nd less than lt let keyword lifelines communication between decomposed defined guard conditions interaction overview diagram labels and representation stacking state invariants and state variants and strict sequencing and
262. sactionissatonlevel VoerclionLock Boolean k be i DSCOMMAMAME Sring eSterotypirs Regured i EJBEntityBoan Reu reae a Supports sReadOny Boolean Mandatory Stereotypes DalaSource Shing Supata EJBPrimaryKay DBTableMame String Naar pla chad reba randon Dogisan TransactonAlintute TransactonlsclationLeveat VersionLock Boolean CSCoumnName String Figure 11 7 shows a portion of a model using the profile declared in Figure 11 6 Figure 11 8 indicates how the tagged value structures in the model relate back to the profile declaration The notes containing the tagged values make the notation bulky if you need to show a set of tagged values for every class attribute operation and relationship When aiming to expose the structure and relationships of a system class diagrams rarely show tagged values Referring again to Figure 11 7 one tiny class having two attributes becomes a constellation of four diagram elements A modest class diagram of 10 classes can easily require 100 extra notes to show the tagged values hopelessly confusing the diagram and destroying its impact Instead modelers often maintain the tagged values invisibly in the model where tools can extract them as needed This page was created by the unregistered version of CHM To POF Converter by Theta Sottware Figure 11 7 A stereotyped class and its stereotyped attributes with their respective tagged values EJBEntityBean IsReadOnly false DataSource
263. se case is typically not i complete on its own and is a required part of the larger use cases 7 3 3 Use Case Extension UML provides the ability to plug in additional functionality to a base use case if specified conditions are met For example if you are modeling a banking application you can have a use case named Open Account that specifies how the user can create a new account with the bank You can offer a joint account that allowed a user to add other people to his account The joint account functionality can be captured with a different use case named Add Joint Member In this case the specified condition for the extension is more than one member on the bank application UML clearly specifies that a base use case should be a complete use case on its own The extension use cases are typically smaller in scope and represent additional functionality so they may not be useful outside the context of the base use case Any use case you want to extend must have clearly defined extension points An extension point is a specification of some point in the use case where an extension use case can plug in and add functionality UML doesn t have a particular syntax for extension points they are typically freeform text or step numbers if the use case functionality is represented as a numbered list You list extension points in a use case oval or in a separate compartment when using the classifier notation Figure 7 14 shows a use case wi
264. se cases or add on to base use cases using use caseextension 7 3 1 Actor and Use Case Generalization Though not officially mentioned in the specification actors and use cases can be generalized like many other classifiers Actor generalization is typically used to pull out common requirements from several different actors to simplify modeling For example Figure 7 10 shows several administrators and the use cases they need to invoke You may have a Database Administrator a Backup Administrator and a Deployment Administrator all with Slightly different needs However the majority of the needs of the individual actors may overlap You can factor out a generic System Administrator actor to capture the common functionality and then specialize to identify the unique needs of each actor You represent actor generalization like any other classifier draw a solid line with a closed arrow pointing from the specialized actor to the base actor Figure 7 11 shows the same information as Figure 7 10 but in a much easier to read diagram Use cases may be generalized as well Typically use case generalization is used to express some high level functional need of a system without going into specifics Specializations of a general use case introduce specific functionality For example a generic use case can be Verify Passenger Identity and specializations of that use case can be Check Passenger Fingerprint and Verify Passenger s RFID Tag It is importan
265. sertion decomposition of the rendering engine example used earlier in this chapter Figure 10 32 Example of a decomposition with extra global fragments This page was created by the unregistered version of CHM To POF Converter by Theta Sottware sd Redraw maps ai _ RengenngEngane ps Maploader redraw Manai B mameri emave liTexiuresih i E toxtura Coun 0 gatMap Dakaj addTextura mapOata d DrawingSurface_Remove Textures The assort fragment paieras ANE Sires Gmphicacontaxi Textured iat 1 beyond the edges of the sequence diagram io indicate the fragrant is l pant of another dagrar i assert removeAll Textures Pe mutexLock i s _ cleat F i _ update Texhare List l rrutexUiniockt TextureCounti0 l toxtureCount 0 O nic eer ee N ENE i a This diagram has one gate I Since this diagram is pat of the assert iepent if mist obey the assertions from the larger diagram inremeveAlTextures p L The UML specification recommends that you name your decomposition diagrams using an abbreviation for the object being decomposed followed by an underscore _ followed by the name of the interaction For example if you are modeling a credit card authorization system and want to show how a card is validated you can name your decomposition CCAS Validation You can also show decompositions inline by showing p
266. set You show a parameter set by drawing a rectangle around Figure 9 8 Activity diagram with a transformation behavior to traverse an object and extract the needed information This page was created by the unregistered version of CHM To POF Converter by Theta Sottware Process Course Registration atranstormation CourseRedgistration student CourseRegistration o J Verify Account Status Student A D M l lll E Zl sa l student information from the course registration since Verify Account Status A requires a student account as input Figure 9 9 Multicast object flows Release RFP amultica st RFP gt Prepare Bid 7 emultireceives Review Proposals _ Proposal the pins included in the set Figure 9 10 shows the Adjust Salary action with parameter sets 9 1 1 3 Connectors To simplify large activity diagrams you can split edges using connectors Each connector is given a name and is purely a notational tool You place the name of a connector in a circle and then show the first half of an edge pointing to the connector and the second half coming out of the connector Figure 9 11 shows two equivalent activity diagrams one with a connector and one without Figure 9 10 Action with parameter sets This page was created by the unregistered version of CHM To POF Converter by Theta Sottware Adjust Salary a r Hire Employee i ig mics New Hire coma re fi
267. set of attributes subsets lt attribute name gt Specifies that this attribute type is a subset of all the valid values for the given attribute This isn t a common property but if used it is typically associated with Subclasses of an attribute type redefines lt attribute name gt Specifies that this attribute acts as an alias for the given attribute Though uncommon this attribute can be used to show that a subclass has an attribute that is an alias for a Superclass s attribute composite Specifies that this attribute is part of a whole part relationship with the classifier See Relationships for more information on composition 2 2 6 Constraints Constraints represent restrictions placed on an element They may be natural language or use a formal grammar such as the OCL however they must evaluate to a boolean expression You typically show constraints between curly braces after the element they restrict though they may be placed in a note and linked to the element using a dashed line You can name a constraint by specifying the name followed by a colon before the boolean expression This is frequently used to identify constraints on an operation see Operation Constraints Figure 2 11 shows several constraints on attributes and operations Figure 2 11 Examples of inlined and note constraints This page was created by the unregistered version of CHM To POF Converter by Theta Sottware ConstrainedElement
268. ssion evaluates to true for all of t elements in a collection The syntax for forall is the same as that for select and reject SO yo can write a constraint that enforces that all students in a Course have paid their tuition context Course inv self students gt forAll tuitionPaid true This page was created by the unregistered version of CHM To POF Converter by Theta Sottware As you can with select you can name and type the variable used in the expression context Course inv self students gt forAll curStudent Student curStudent tuitionPaid tr If you need to check to see if there is at least one element in a collection that satisfies a boolear expression you can use the operation exists The syntax is the same as that for select The following expression ensures that at least one of the students has paid their tuition context Course inv self students gt exists tuitionPaid true Likeselect you can name and type the variables used in the expression context Course inv self students gt exists curStudent Student curStudent tuitionPaid tr You can check to see if a collection is empty using the operations isEmpty Or notEmpty The following expression ensures that the school has at least one course offering context School inv self Course gt notEmpty a PREY NEKT W This page was created by the unregistered version of CHM To POF Converter by Theta Sottware PREY NEXT Colophon About
269. state may be labeled with the event that instantiates the object amp the state machine is modeling This page was created by the unregistered version of CHMI To POF Converter by Theta Sottware Choice Deep history Entry point Exit point Fork and join Junction Allows the execution of a state machine to choose between several different states based on guard conditions on the transitions see Figure 8 17 Used inside a state region a transition to this pseudostate from outside the region indicates the state machine should resume the last substate it was in within the given region no matter how deep the substate is within the region Represents a possible target for a transition into a composite state An entry point can then transition to an internal substate that may differ from the default transition You must label entry points by writing their name next to the symbol Represents a possible source for a transition from a composite state Like entry points exit points are labeled with their names Represents a split in the execution of the state machine into orthogonal regions The join reunites the regions into a single transition The state machine won t transition from the join until all regions have transitioned to the join pseudostate Brings several possible transitions together into one pseudostate One or more transitions may then leave the junction to other states This page was created by
270. structure diagrams Process view The process view of a system is intended to capture concurrency performance and scalability information Process views often use some form of interaction diagrams and activity diagrams to show how a system actually behaves at runtime The four distinct views of a system are brought together with the final view Use case view The use case view captures the functionality required by the end users The concept of end users is deliberately broad in the use case view they include the primary stakeholders the system administrator the testers and potentially the developers themselves The use case view is often broken down into collaborations that link a use case with one or more of the four basic views The use case view includes use case diagrams and typically uses several interaction diagrams to show use case details 1 6 3 Notes UML provides a catchall element or note for adding information to your diagram The note symbol is a dog eared rectangle with an optional dashed line to link it to some element Figure 1 1 shows a simple note Figure 1 1 A simple note This is a simple note It IN can contain text pseudocode URLs etc In general you can use notes to capture just about anything in your diagram Notes are often used to express additional information that either doesn t have its own notation or would clutter a diagram if you drew it right on the element Some tools allow you to embed U
271. syntax used in this example is described in the Collections section context Course getHonorsStudents Student body self students gt select GPA gt 3 5 B 2 3 Constraints on Attributes OCL expressions can specify the initial and subsequent values for attributes of classifiers When using OCL expressions with attributes you state the context of an expression using the classifier name two colons the attribute name another colon and then the type of the attribute You specify the initial value of an attribute using the keyword init This page was created by the unregistered version of CHMI To POF Converter by Theta Sottware context School tuition float init 2500 00 You can specify the value of attributes after their initial value using the derive keyword The following example increases the tuition value by 10 every time you query it context Schooli tuition float derive tution 10 a PREY NEXT B This page was created by the unregistered version of CHM To POF Converter by Theta Sottware PREY NEXT W B 3 Advanced OCL Modeling Like any other language OCL has an order of precedence for operators variable declarations a logical constructs only for evaluating your expressions not for program flow The following sections describe constructs that you can use in any OCL expression B 3 1 Conditionals OCL supports basic boolean expression evaluation using the if then else endif
272. t One of the major motivations for the move from UML 1 5 to UML 2 0 was to add the ability for modelers to capture more system behavior and increase tool automation A relatively new technique called Model Driven Architecture MDA offers the potential to develop executable models that tools can link together and to raise the level of abstraction above traditional programming languages UML 2 0 is central to the MDA effort It is important to realize the UML is not a software process It is meant to be used within a software process and has facets clearly intended to be part of an iterative development approach While UML was designed to accommodate automated design tools it wasn t intended only for tools Professional whiteboarders were kept in mind when UML was designed so the language lends itself to quick sketches and capturing back of the napkin type designs 1 3 2 Business Process Modeling UML has an extensive vocabulary for capturing behavior and process flow Activity diagrams and statecharts can be used to capture business processes involving individuals internal groups or even entire organizations UML 2 0 has notation that helps model geographic boundaries activity partitions worker responsibilities swim lanes and complex transactions statechart diagrams A PREY NEKT W This page was created by the unregistered version of CHM To POF Converter by Theta Sottware PREY NEXT 1 1 4 UML Specifications Physically
273. t to notice that even with use case generalization you should still discuss functionality not implementation You should not have specializations of a use case for different ways to implement the same functionality only to represent different functionality You represent use case generalization just like you do actor generalization using a solid line with a closed arrow pointing from the specialized use case to the base use case If the general use case represents abstract functionality meaning it s a functional concept but doesn t actually explain how a user would do something you show the name of the use case in italics Figure 7 12 shows the verification use cases and their relationships 7 3 2 Use Case Inclusion You can factor out common functionality from several use cases by creating a shared included use case Unlike in use case extension discussed next the use case that includes another use case is typically not complete on its own The included functionality isn t considered optional it is factored out simply to allow for reuse in other use cases You show use case inclusion using a dashed line with an open arrow dependency pointing from the base use case to the included use case Label the line with the keyword include Figure 7 13 shows an example of use case inclusion This page was created by the unregistered version of CHM To POF Converter by Theta Sottware Figure 7 11 Actor generalization in which the System
274. t yet Though a one size fits all offering doesn t exist many offerings are very productive The goal of MDA while simple to voice has yet to be fully implemented PREY NEXT W This page was created by the unregistered version of CHM To POF Converter by Theta Sottware PREY NEXT 1 A 2 The Models of MDA Models play a big role in MDA As a framework for building systems MDA abstracts systems into abstraction layers Traditionally OOAD had analysis detailed design and code roughly representing a system s business perspective the architectural technological perspective and the implementation perspective MDA adds one abstraction on top representing the business context of the system Figure A 1 shows the different abstraction layers and their associated MDA models Abstraction increases toward the left and concreteness increases toward the right Concrete models outnumber abstract models In general the abstract begets the concrete as each model becomes more concrete it realizes the abstractions with respect to one technology or platform The inverse making abstract models from the concrete also known as reverse engineering rarely happens except when the starting point is code Even then because the system must support a business starting from the business needs is generally more appropriate Figure A 1 An example of MDA models and their relationship This page was created by the unregistered version of CHM To POF Con
275. ta Sottware 4 PREV NEXT Index SYMBOL A B C D E F G H H J K M N O P Q R S CO U M W X tagged values defined overview stereotypes and templates terminate node pseudostate test subregion testing 2nd textual representation thrown exceptions tilde 2nd timing sensitivity of sequence timing diagrams and timing diagrams defined interactions and overview tokens join nodes merge nodes and object flows and overview tools profiles and 2nd traces transformation behaviors transformation functions 2nd 3rd transformation language transitions allowable time for completion conflicting data store nodes and dispatched events and events and internal overview pseudostates and representation state machines and 2nd 3rd timing diagrams and types of 2nd trigger transition 2nd 3rd type element operations types This page was created by the unregistered version of CHMI To POF Converter by Theta Sottware artifacts attribute syntax element transition 2nd typing port 4 PREV NEXT This page was created by the unregistered version of CHM To POF Converter by Theta Sottware 4 PREV NEXT Index SYMBOL A B C D E F G H H J K M N O P Q R S CO U M W X UML Unified Modeling Language business process modeling common uses designing software 2nd extending rules of thumb 2nd specificat
276. tabase before the item is shipped You can show transitions from a data store node that have additional information to select a subset of the data stored in a data store node similar to a database query The specification doesn t require any particular syntax and suggests showing the selection criteria in a note labeled with the keyword selection Figure 9 40 shows an activity diagram that uses a data store node to send welcome packets to new customers Figure 9 40 Activity diagram with a data store selection p Process Order datastore _T 25 i Make Sale Ship Item _ Customer Database p selection A raer zd Order Customer Y evOr f Prvome send Welcome Packet lf the customer placing the new order has never ordered anything before the system will execute the Send Welcome Packet action This page was created by the unregistered version of CHMI To POF Converter by Theta Sottware PREY NEXT Chapter 10 Interaction Diagrams A fundamental goal of UML 2 0 is to allow users to capture more than just structural relationships UML 2 0 is intended to capture processes and flows of events Interaction diagrams draw from nearly every other facet of the language to put together a set of diagrams that capture communications between objects UML 2 0 has greatly expanded UML 1 x s ability to describe complex flow of control one of the largest sections of the UML 2 0 specification is the interact
277. te containment If you use this representation you should show the name of the package in the large rectangle rather than in the tab This notation allows you to show more detail of the packaged elements Figure 3 3 shows the same Utilities package but with the classes broken out This page was created by the unregistered version of CHM To POF Converter by Theta Sottware Figure 3 3 Elements owned by a package shown outside of the package Utilities Timer Queue Semaphore timeout int numElements int a l started boolean ee eee tarol ay addElement Object void give int You don t need to show all the elements contained within a package if no elements are shown no assumptions can be made about what the package contains A PREY NEXT This page was created by the unregistered version of CHM To POF Converter by Theta Sottware PREY NEXT 3 2 Visibility A package may specify visibility information for owned and imported elements however elements may have only one of two levels of visibility public or private Public visibility means the element may be used outside the package scoped by the package name Private visibility means the element may be used only by other elements of the same package Private visibility is useful for marking utility classes that help implement a subsystem or component you don t want to expose to the rest of the system You show public visibility by placing a
278. te name Figure 8 4 A state with its name in a tab Within the rectangle a state can be divided into compartments as needed UML defines the following compartments This page was created by the unregistered version of CHM To POF Converter by Theta Sottware Name Shows the name of the state This should not be used if the name is placed in a tab Internal activities Shows a list of internal activities that are performed while in the state See Activities for the syntax Internal transitions Shows a list of internal transitions see Transitions and the events that trigger them Write an internal transition as event attributeList guard condition transition The attribute list which is optional maps the event s parameters to the given attributes of the classifier The guard condition is also optional but if present must be enclosed by square brackets The same event may be listed multiple times as long as each entry has a unique guard condition for the transition Figure 8 5 shows a state with compartments Figure 8 5 A state with compartments i Oo ii a o M i Grinding Coffee sates g Name compartment entry dose dispenser door e M Hy do grind beans Internal activities axit open dispenser door L cae eevee pee ae ee ee el lid opened grinders running true stop grinder E ee intemal transitions i boast paises sass sea Stick ea oe ey A stat
279. ter 10 for more information on interaction diagrams You can specify a boolean condition to indicate under what conditions the join node will emit a token allowing the flow to continue along its single output edge This expression is called a join specification and can use the names of incoming edges and tokens arriving over those edges in the condition You write a join specification near the join node inside of braces Figure 9 24 adds greeting guests to the steps involved in preparing a meal and ensures that you don t serve the meal until all the guests have arrived 9 3 4 4 Final nodes Two types of final nodes are used in activity diagrams activity final and flow final Activity final nodes terminate the entire activity Any tokens that arrive at the activity final node are destroyed and any execution in any other node is terminated without results You can have multiple activity final nodes in a single activity diagram but a token hitting any of them terminates the whole activity You show an activity final node as a black dot with a circle around it as shown in Figure 9 4 Flow final nodes terminate a path through an activity diagram but not the entire activity Flow final nodes are used when the flow of an activity forks and one Figure 9 24 Join node with a join specification This page was created by the unregistered version of CHM To POF Converter by Theta Sottware Prepare Meal Defrost Turkey Roast Turkey gn a
280. ter 9 Activity Diagrams This chapter introduces a close relative to the statechart diagram the activity diagram Activity diagrams resemble old school flowcharts and are typically used to model an algorithm or use case realization Chapter 10 Interaction Diagrams This chapter introduces the large set of interaction diagrams supported by UML 2 0 The two best known diagrams are sequence and collaboration diagrams This chapter also discusses the new timing centric interaction diagram The final part of the book covers extension and applications of UML 2 0 Chapter 11 Tagged Values Stereotypes and UML Profiles This chapter discusses how UML 2 0 may be extended and refined Chapter 12 Effective Diagramming This chapter departs from the specification side of UML 2 0 and offers real world advice on modeling what parts of UML 2 0 to use when and how to effectively convey the right information Appendix A MDA Model Driven Architecture This appendix introduces the Model Driven Architecture MDA While MDA isn t a new idea UML 2 0 has MDA in mind in several places and next generation tools may be able to make MDA a reality Appendix B The Object Constraint Language This appendix describes the Object Constraint Language OCL a simple language defined to express constraints on UML diagrams It can be applied in countless ways This page was created by the unregistered version of CHM To POF Converter by Theta Sottware
281. th extension points This page was created by the unregistered version of CHM To POF Converter by Theta Sottware Figure 7 14 Oval and classifier notation for a use case with extension points a Open Account EN Open Account gt lt lt axtension points gt gt Add account user k lt lt extension points gt gt o Add account user You represent a use case extension by showing a dashed line with an open arrow dependency pointing from the extension use case to the base use case Label the line with the keyword extend Figure 7 15 shows an example of use case extension Figure 7 15 Use case extension fo N pad Joint Open Account lt lt sesetuananainstasiniiaies ssl i 7 lt extend gt gt Aeoount Holker sis 4 Add Joint Account Holder extends Open Account by adding extra functionality but simi ww mee vs A te L To provide more detail you can specify where the new functionality plugs into the base use case by specifying an extension point and a note attached to the dependency line Optionally you can specify under what condition the extension executes such aS applicants gt 1 Figure 7 16 shows use case extension with a note specifying the extension point and the condition to execute the extra functionality Figure 7 16 Use case extension showing conditions in a note Condition applications gt 1 Extension point Add account user _ Sas i a
282. the Author Colophon a PREY NEKT W This page was created by the unregistered version of CHM To POF Converter by Theta Sottware PREY NEXT 1 About the Author Dan Pilone is a software architect with Blueprint Technologies Inc cofounder and president of Zizworks Inc and a terrible rock climber He has designed and implemented systems for Hughes ARINC UPS and the Naval Research Laboratory When not writing for O Reilly he teaches software design and software engineering at the Catholic University in Washington D C He is the author of the UML Pocket Reference and has had several articles published covering software process consulting in the software industry and 3D graphics in Java Neil Pitman is chief technical officer of Mahjong Mania codeveloper of LamMDA from Mindset Corporation and formerly vice president of research and development at Codagen Technologies Neil has 20 years of experience in software development ranging from medical systems to Smalltalk development platforms gaming software to code generation When he does real work it s in J2EE and XSLT as well as UML Look for him at http www architecturerules com a PREY NERT W This page was created by the unregistered version of CHM To POF Converter by Theta Sottware PREY NEXT W Colophon Our look is the result of reader comments our own experimentation and feedback from distribution channels Distinctive covers complement our distinctive
283. the justification of derived elements in the PSM The transformation function must have a way to detect and merge collisions and to remove deadwood Traceability of ownership and generation becomes a serious issue MDA stores the relationships between source models marks and target models in a mapping model The example in Figure A 3 shows how each element in the target model has a mapping to the source model and the appropriate marks and optionally to the marking models Figure A 3 Mapping models ensure traceability between the models and the marks Account reference false editable true sfam Account Account Number Texthietd Account Name TextField Account Type DropDown isSummary reference true name editable false referenceAs n dropdown The mappings provide the traceability necessary for subtle evolution of the whole system The transformation process follows the links when updating a target model from new versions of the source model or source mark model The transformation function detects conflicts between the generated elements and the existing element added or modified by modelers It identifies deadwood in the new target model that exists only because of now deleted elements in the source model This page was created by the unregistered version of CHM To POF Converter by Theta Sottware PREY NEXT 1 A 5 Transforming Models The models up to now provide multiple abstractions of the system T
284. the second arriving before the first You can show out of order reception by having the first message point to a spot below the reception point of the second message as shown in Figure 10 6 This page was created by the unregistered version of CHM To POF Converter by Theta Sottware Figure 10 6 Asynchronous messages received out of order sd Sending Ping Packets HostMachine DestinationMachine Workstation Server T i l l sendPing id 1 sendPinglid 2 7 ai I i send Respons id 2 Wy a a prr m F _ sendResponse id 1 be j j In this example HostMachine sends two ping packets to DestinationMachine Because of network differences in the routes taken the response to the second ping arrives before the response to the first ping If a message represents synchronous communication typically a method call you place a filled arrow head on the receiver s end You can show return values from a method using a dashed line with an open arrowhead pointing back to the caller Figure 10 7 shows a method call to order an item and a confirmation number sent back as a return value If a message represents object creation you show a dashed line with an open arrow pointing to the newly created object s lifeline By convention the message is typically labeled with some variation of create If there are no arguments to the message you can simply label
285. the unregistered version of CHMI To POF Converter by Theta Sottware A larger component that makes up part of a bigger software system UML provides no real definition for a subsystem however subsystem generally means a self contained set of functionality that is larger than a simple component NEXT This page was created by the unregistered version of CHMI To POF Converter by Theta Sottware fa PREV NEXT Chapter 6 Deployment Diagrams Deployment diagrams model the mapping of software pieces of a system to the hardware that is going to execute it Software elements components classes etc are typically manifested usingartifacts and are mapped to the hardware or software environment that will host them callednodes Because many nodes may be associated with the deployment of a system communication between nodes can be modeled using communication paths fa PREY NEXT This page was created by the unregistered version of CHM To POF Converter by Theta Sottware PREY NEXT 6 1 Artifacts Artifacts represent physical pieces of information related to the software development process For example you can use an artifact to represent a DLL needed by your system a user s manual or an executable produced when your software is compiled Typically artifacts are used to represent the compiled version of a component see Chapter 5 however UML 2 0 allows artifacts to represent any packageable element which includ
286. they are made up of internal substates and transitions UML defines a submachine state as a way to encapsulate states and transitions so that they can be reused A submachine state simply means that another state machine a submachine state machine is contained by the state For example the process of establishing a TCP IP connection can be encapsulated into its own state machine and that state machine can then be embedded as the first submachine state of a state machine modeling a web page request A submachine state is shown in the same rounded rectangle as any other state except you show the name of the state followed by a colon followed by the name of the referenced submachine Figure 8 9 shows a submachine state Figure 8 9 A submachine state referencing the credit card validation state machine Typically when showing a submachine state you show the entry and exit points of the This page was created by the unregistered version of CHM To POF Converter by Theta Sottware referenced submachine You show these points as pseudostates on the border of the submachine state see Pseudostates Figure 8 10 shows a submachine state with an explicit exit point Figure 8 10 Credit card validation submachine state with explicit exit point Collect Credit Card Information Varily Gredi Gard Place Order eo Invalid Credit Card Display Error Message p If the submachine state is entered through the default initial pseu
287. though this is outside of the typical notation UML suggests that the class name e Start with a capital letter e Be centered in the top compartment e Be written in a boldface font e Be written in italics if the class is abstract see Abstract Classes Figure 2 1 shows a simple class Figure 2 1 Simple class representation oe ee eee A class can have as many compartments as you want to show things like attributes methods exceptions etc OE TE eee eee eee eee ee J 2 1 1 Objects An object is an instance of a class For example you may have several instances of a class namedcar one two door red car one four door blue car and one hatchback green car Each This page was created by the unregistered version of CHM To POF Converter by Theta Sottware instance of car is an object and may be given its own name though it is common to see unnamed or anonymous objects on object diagrams Typically you show the name of the object followed by a colon followed by its type i e class You show that this is an instance of a class by underlining the name and type Figure 2 2 shows an instance of a class car namedtToyota Note that in this figure we have hidden the empty compartments Figure 2 2 An instance of Car Toyota Car a PREY EN This page was created by the unregistered version of CHM To POF Converter by Theta Sottware PREY NEXT 1 2 2 Attributes Details of a class the co
288. tifact by underlining the name of the artifact Figure 6 3 shows an instance of the logging jar artifact Figure 6 3 An instance of the logging jar artifact logging jar Typically you can determine whether an artifact is intended to be a type or an instance based on context so UML allows the normal nonunderlined representation of an artifact to be interpreted as an instance of that artifact if the context is clear Practically speaking this translates into most models using artifacts as instances but not underlining the title 6 1 2 Manifestations An artifact is a manifestation of another UML element For example logging jar may bea manifestation of the LoggingSubsystem component You capture the manifestation relationship with a dashed line from the artifact to the element it represents and label the line with the keyword manifest Figure 6 4 shows the LoggingSubsystem manifestation Figure 6 4 Showing the manifestation of a component as an artifact LoggingSubsystem I Note that the name of the artifact A does not need to match the name of amanifest the element it represents However they are often similar E 1 p logging jar e 7 In UML 1 x manifestations were known as implementations In UML 2 0 it was decided that implement had been overused so it has been deprecated in favor of the keyword manifest This page was created by the unregistered version of CHMI To POF Conve
289. ting through a transformation definition The transformer can be implemented equally well as a script or a procedural language In any case each transformation requires its own definition the transformer from PIM to presentation PSM can t be reused for the database PSM to SQL code model The concept of reverse engineering or round trip engineering received a great deal of interest a few years ago MDA doesn t address it specifically Each transformation function can have an inverse function to create the abstract from the concrete but nothing requires an This page was created by the unregistered version of CHM To POF Converter by Theta Sottware MDA solution to provide it Reverse engineering generally creates more problems than it solves You reverse engineer only elaborate concrete models Concrete models may not respect the naming conventions or they may have slight or gross variants of expected patterns The resultant abstract model will have no insight into the structures found Furthermore it becomes unclear where ultimate truth lies Remember MDA doesn t stand for program driven modeling PREV EE This page was created by the unregistered version of CHM To POF Converter by Theta Sottware PREY NEXT A 6 Languages to Formally Describe MDA The transformations describe in the preceding section can t work without strict inputs Each model must respect a structure that constrains its expressiveness formally automated
290. tion etc has a way of expressing the time sensitive nature of the event occurrences In a sequence diagram the event occurrences are ordered along the lifelines and are read from top to bottom Figure 10 16 shows a sequence diagram with three of the event occurrences labeled as mentioned earlier any action associated with an object is an event occurrence but to keep the diagram from getting out of control only three are labeled in the figure Figure 10 16 A sequence diagram with three event occurrences labeled sd Review a book Reviewer User Sarera m Book Distrifputor orderBook UML 2 0 in a Nutshell ail shipOrder userinfo orderinfo gt e deliverBook a t S k b i l in M ERR RE readBook UML 2 0 in a Nutshell w O a 4 4 Event occurrences submilReview A S This page was created by the unregistered version of CHM To POF Converter by Theta Sottware PREY NEXT 10 7 Traces UML defines a trace as a sequence of event occurrences The term trace is used when discussing sets of event occurrences and how they may be combined Interaction diagrams allow you to combine fragments in such a way that the event occurrences are interleaved This combined set of event occurrences is considered a new trace Throughout this chapter we will refer to a sequence of event occurrences as event occurrences rather than as a trace to try and reduce the number of keywords PREY NEXT 1
291. tion exit activity protocol state machines and transitions and 2nd triggers for Exit pseudostate 2nd expansion regions 2nd explicit binding explicit entry expressions as invariants attributes and comments in context of 2nd 3rd declaring evaluating 2nd grouping naming naming elements OCL and 2nd 3rd operations and undefined variables in extend keyword extended keyword extends keyword extension state machines use case 2nd extension points 2nd external state extra global combined fragments a PREY NEKT W This page was created by the unregistered version of CHM To POF Converter by Theta Sottware 4 PREV NEXT Index SYMBOL A B C D E F G H H J K M N O P Q R S CO U M W X final state 2nd floor operation flow final nodes focus of control 2nd 3rd forAll operation foreign keys fork and join pseudostate fork nodes 2nd forward slash deferred events derived notation OCL operator 2nd property instances and found messages 2nd functions 4 PREV NEXT This page was created by the unregistered version of CHM To POF Converter by Theta Sottware 4 PREV NEXT Index SYMBOL A B C D E F G H H J K M N O P Q R S CO U M W X gates general ordering generalization relationship casting and defined package merging and representation generalization use case and actor graphi
292. tion occurrences collaborations connectors ports and properties structured classes composition relationship 2nd compound transition computational independent model CIM concat _ operation conditionals OCL 2nd conditions extension points and invariant labels and transitions and configuration deployment diagrams and execution environments implementation view State transitions and connection points 2nd connector ends connectors This page was created by the unregistered version of CHMI To POF Converter by Theta Sottware assembly composite structures and defined 2nd multiple ports and 2nd consider interaction operator constants parameters and readOnly attribute property and value pin constraints attributes and 2nd 3rd 4th collections and looping on classifiers operation 2nd 3rd 4th overview partitions and profiles and 2nd sequence timing and time transitions content management system CMS context activities and of expressions 2nd 3rd context keyword OCL 2nd continuations control flow control nodes CppDoc critical interaction operand critical interaction operator 2nd critical regions 2nd curly braces constraints and extended keyword properties property strings protocol keyword state invariants stream keyword weights 4 PREY NEXT W This page was created by the unregistered version of CHM To POF Converter by Theta Sottware 4 PREV NEXT
293. tion package Figure 3 5 RoutePlanning importing the Transportation package RoutePlanning hrir iranere entan Transportation import By default imported elements are given public visibility in the importing package UML allows you to specify that imported elements should be given private visibility meaning they can t be used by anyone outside the importing package including any packages that may import that package To specify that imported elements should have private visibility you use the access keyword rather than the import keyword Figure 3 6 shows the RoutePlanning package importing the TRansportation package and accessing the Algorithms package If a package imports the RoutePlanning package both packages can use public elements from TRansportation but they can t use anything in Algorithms Figure 3 6 RoutePlanning importing the Transportation package but accessing only the Algorithms package This page was created by the unregistered version of CHM To POF Converter by Theta Sottware Transportation import 7 RoutePlanning access Algorithms What package import and access actually mean in implementation can vary dramatically depending on your target language For example C and Java have an explicit concept of packages and importing elements from packages Java developers often import the java util package into their program so they can reference the Java vector class without qual
294. tion parameter name type multiplicity derault value properties Figure 2 13 shows several example operations on a class Figure 2 13 Example operations on a class Window getSize Rectangle setSize in name String void getComponents Component 0 painti void setVisible visible boolean true void formatTitle void The syntax elements are ViSiIDiiIeY7 Indicates the visibility of the operation Use the following symbols or for public private protected Or package respectively see Visibility in Chapter 3 name Is a short phrase naming the operation Operations are usually verb phrases representing actions the classifier should perform on behalf of the caller The UML This page was created by the unregistered version of CHM To POF Converter by Theta Sottware specification recommends that the first letter of an operation be lowercase with all of the following words starting with a capital letter and running together See Figure 2 13 for an example FeLcurn type Is the type of information the operation will return if any If no information is returned from the operation called a subroutine in some development languages the return type should be void If the operation does return a value called a function in some development languages you should show the type of the returned value such as another classifier a primitive type or a collection The UM
295. to be reused within an application and actions are typically specific and are used only within a particular activity You show an activity as a rectangle with rounded corners Specify the name of the activity in the upper left You can show parameters involved in the activity below the name Alternatively you can use parameter nodes described later in this section Figure 9 1 shows a simple activity Figure 9 1 A simple activity with no details fr Process Sale Purchaseditem Item You can show the details for an activity inside of the rectangle or to simplify a diagram leave off the surrounding rectangle altogether You show actions using the same symbol as an activity a rectangle with rounded corners place the name of the action in the rectangle This page was created by the unregistered version of CHM To POF Converter by Theta Sottware Figure 9 2 shows some actions inside of an activity Figure 9 2 Activity with simple details Process Sale Purchaseditem Item P Fa Bill Customer Ship Item To make activity diagrams more expressive you can write pseudocode or application dependent language inside an action Figure 9 3 shows an example of an action with a domain specific block of code Each activity typically starts with an initial node and ends with an activity final node When an activity reaches an activity final node the activity is terminated You show an initial node as a black dot and an activity f
296. to convey and leave off what you don t need At times there is more than one way to convey the same information use what is familiar to your audience UML models are rarely complete As a consequence of everything being optional it is common for a UML model to be missing some details about a system The trick is to not miss key details that could impact your system design Knowing what is a key detail versus extraneous information comes with experience however using an iterative process and revisiting your model helps to flesh out what needs to be there As UML moves closer to tool automation with practices like MDA and Software Factories the models often become more and more detailed and therefore complete The difference is the tool support that helps vary the level of abstraction depending on your needs UML is designed to be open to interpretation While the UML specification does a good job of laying down the groundwork for a modeling language it is critical that within an organization or group of users you establish how and when to use a language feature For example some organizations use an aggregation relationship to indicate a C pointer and a composition relationship to indicate a C reference There is nothing inherently wrong with this distinction but it s something that isn t going to be immediately obvious to someone not familiar with that organization s modeling technique It is a good practice to put together a document on
297. to think that one diagram can present all the information of a multidimensional model Figure 12 1 An overloaded and ineffective class diagram This page was created by the unregistered version of CHM To POF Converter by Theta Sottware 12 1 1 Modeling Versus Diagramming Before making Figure 12 1 more effective let s distinguish modeling from diagramming The act of modeling furthers your understanding of the system under study You use diagrams to elaborate the model You confirm the model integrity with new views You organize your understanding You extend your knowledge You challenge your understanding By seeing the known you can infer dictate or investigate the yet to be known Figure 12 1 might be seen during modeling but only as an intermediate step such diagrams don t demonstrate UML s true power to communicate Diagramming on the other hand expresses understanding for the benefit of others You may This page was created by the unregistered version of CHM To POF Converter by Theta Sottware be a domain expert by background or you may have recently synthesized expertise from modeling with domain experts You have worked hard to understand and to put your understanding into a model perhaps over weeks or months now you must make that understanding immediately accessible to your readers Your model should be concise so that they understand If there is to be contention let it be about real ideas not ambiguity Diagramm
298. tomic block The interaction operator iS critical Critical regions are typically used inside other interaction fragments such as a parallel fragment to ensure that a group of event occurrences can t be separated Figure 10 25 shows an example rendering engine loop that checks to see if map data is available for drawing Because loading map data may be an expensive operation we ll allow the loading to be executed in parallel with the rendering However compressed map data can t be rendered so the loading and decompression must occur as an atomic operation Figure 10 24 Example of a negative operator This page was created by the unregistered version of CHM To POF Converter by Theta Sottware sd Bad Graphics Sequence You cannot execute calls on Graphies2D once dispose has been called Painter Window Graphics D gelGraphics acreates dispose drawRect x y wh Y 1 m e e e o o o o o oe o e a lt Figure 10 25 Example of a critical region operator d Rendering Loop gettdapDatal addTexture maoDats critical gaapi decompressData e o queveMapData BecauseFigure 10 25 needs to represent a continuously running process the rendering loop it s better to model the looping conditions with the loop operator shown later in this chapter see Loop 10 8 2 9 Ignore consider Ignore specifies a set of messages that aren t shown on the
299. ts and component metainformation are discussed The latter part of this chapter discusses how components are typically realized in a programming language Chapter 6 Deployment Diagrams This chapter introduces the concept of capturing system deployment using deployment diagrams Deployment fundamentals such as nodes node stereotypes and relationships to components are explained This chapter also includes a discussion on modeling a distributed system using deployment diagrams The next set of chapters cover the second half of UMLbehavioral modeling Behavioral modeling captures how the various elements of a system interact during execution Diagrams This page was created by the unregistered version of CHM To POF Converter by Theta Sottware such as the use case diagram can capture requirements from an external actor s perspective and sequence diagrams can show how objects interact to implement a particular use case The behavioral modeling chapters include Chapter 7 Use Case Diagrams This chapter introduces use cases actors and system boundaries It goes slightly beyond pure UML in that the chapter touches on common practices regarding use cases such as use case scoping use case documents and use case realizations Chapter 8 Statechart Diagrams This chapter introduces state machine modeling using states actions and transitions Statecharts can be used to model a simple algorithm all the way up to a complex system Chap
300. tself Figure 11 1 illustrates this situation where the Meta Object Facility MOF explained more fully later in the chapter comprises all UML models as well as UML like models Figure 11 1 The universe of valid models tn UML family he All Models MOF eT UML Models CORBA Models profile Management models profile SysML Models F k SysML Models nO The authors of UML could have specialized UML for common programming languages such as C C Java and Visual Basic and platforms such as embedded systems real time operating systems RTOS EJB and NET This would have created an unworkable modeling language as each programming language or dialect polluted the specification with conflicting definitions It would still require an extension mechanism because some uncommon language such as Smalltalk or new platform technique or version like EJB 3 0 would always be missing from the formal specification On the other hand the authors could have stretched UML to greater abstraction to embrace uses other than software development such as business modeling modeling the process of software development itself or modeling systems engineering This would have made This page was created by the unregistered version of CHM To POF Converter by Theta Sottware everything even more abstract Because designers work in only one specific domain abstraction imped
301. ty The notation for continuations can be particularly confusing You show a continuation using the symbol for states a rectangle with rounded sides however the position of the rectangle changes the meaning of the diagram You place a continuation at the beginning of an interaction to define the behavior for that continuation You use a continuation by showing the rectangle at the end of an interaction Finally continuations with the same name must cover the same lifelines and only those lifelines Figure 10 34 shows the first of three sequence diagrams demonstrating a continuation this one displays the details of a Login sequence After the password is retrieved from the database an alternative interaction is entered If the passwords match various flags are set on the UserCredentials After setting the flags there is a continuation named Login success in which users of this sequence diagram can plug in their own functionality If the passwords don t match the else part of the alternative interaction executes which leads to the Login failed continuation Notice the continuation symbols are at the end of each interaction operand indicating this diagram uses an externally defined continuation Figure 10 34 Using a continuation in a sequence diagram This page was created by the unregistered version of CHM To POF Converter by Theta Sottware sdLogin EncryptionService AuthenticationService ecentiale authentc
302. ually a loop node looks like Figure 9 33 Figure 9 33 Conceptual view of a loop node adecisioninpul Test z J Setup gt lt 4 Body g gt S true A Using activity partitions you can express this as a single node as shown in Figure 9 34 Figure 9 34 A sample looping node notation This page was created by the unregistered version of CHM To POF Converter by Theta Sottware Setup Body Test 9 4 5 Streaming An action is said to be streaming if it can produce output while it is processing input For example an action representing a compression algorithm can take audio input data from a streamed input and send compressed audio along a streamed output You indicate that an action is streaming its input and output by placing the keyword stream in braces near the edges coming in and out of an action Figure 9 35 shows an example audio encoding that is streaming data Figure 9 35 Activity diagram with streaming actions r Audio Encoder Analog Waveform Bitstream Analog Audio In this activity diagram the original analog audio is streamed through a digital to analog converter and the resulting digital data is sent to the encoding algorithm for processing _ i f f hy es D A Converter e Encode Audio Fi hs stream stream UML provides a shorthand notation for streaming edges and input and output pins use a solid arrowhead or rectangle Figur
303. value of UML in projects e The object oriented paradigm and its relation to the UML e An integrated approach to UML diagrams e Class and Object Use Case Sequence Collaboration Statechart Activity Component and Deployment Diagrams e Extension Mechanisms e The Object Constraint Language OCL If you re new to UML a tutorial with realistic examples has even been included to help you quickly familiarize yourself with the system This page was created by the unregistered version of CHM To POF Converter by Theta Sottware NEXT UML 2 0 in a Nutshell ByDan Pilone Neil Pitman Publisher O Reilly Pub Date June 2005 ISBN 0 596 00795 7 Pages 234 Table of Contents Index Overview System developers have used modeling languages for decades to specify visualize construct and document systems The Unified Modeling Language UML is one of those languages UML makes it possible for team members to collaborate by providing a common language that applies to a multitude of different systems Essentially it enables you to communicate solutions in a consistent tool supported language Today UML has become the standard method for modeling software systems which means you re probably confronting this rich and expressive language more than ever before And even though you may not write UML diagrams yourself you ll still need to interpret diagrams written by others UML 2 0 in a Nutshell from O Reilly feels your pain It s been c
304. variant as context Course inv if self courseLevel gt 4000 then salary gt 80000 00 getHonorsStudentselse salary lt 60000 00 endif B 3 3 Operator Precedence OCL operators have the following order of precedence from highest to lowest e pre e dot and arrow gt operations e not and unary minus e xand e and e if then else endif e lt gt lt and gt This page was created by the unregistered version of CHM To POF Converter by Theta Sottware e and lt gt e and or and xor e implies You can use parentheses to group expressions which will be evaluated from the innermost set c parentheses to the outermost B 3 4 Built in Object Properties OCL provides a set of properties on all objects in a system You can invoke these properties in y expressions as you do any other properties The built in properties are oclisTypeOf t Type Boolean Returnstrue if the tested object is exactly the same type as t oclIsKindOf t Type Boolean ReturnstRue if the tested object is the same type or a subtype of t oclInState s State Boolean ReturnstRue if the tested object is in state s The states you can test must be part of a sta machine attached to the classifier being tested oclisNew Boolean Designed to be used in a postcondition for an operation it returns true if the object being tested was created as a result of executing the operation oclAsType t Type Type
305. verter by Theta Sottware Com putational Platform Platform Code Independent Independent Specific Model Model odel Model Presentation PSM xAIL Manua ontro PIM s PIM fans out to sana ti many many Pos target platforms The abstraction models match well with the conceptual layers of a system Computational independent model CIM The CIM represents the highest level business model The CIM uses a specialized business process language and not UML although its language could well be derived from the meta object facility MOF The CIM transcends computer systems Each process interacts with human workers and or machine components The CIM describes these interactions between these processes and the responsibilities of each worker be it human or otherwise Anyone understanding business and business processes can understand a CIM It avoids specialized knowledge of procedures internal to a worker computer system such as accounting procedures or sales commissions Platform independent model PIM A PIM represents the business model to be implemented by an information system Commonly UML or some UML derivative describes the PIM This page was created by the unregistered version of CHM To POF Converter by Theta Sottware The PIM describes the processes and structure of the system without reference to the delivery platforms The PIM ignores operating systems programming languages hardware and networking Anyo
306. verything in UML notation is optional so there is no specific notation to indicate an optional field If a particular piece of syntax is required it is noted in the text This page was created by the unregistered version of CHM To POF Converter by Theta Sottware PREY NEXT W Safari Enabled Safari ALGE When you see a Safari Enabled icon on the cover of your favorite technology book it means the book is available online through the O Reilly Network Safari Bookshelf Safari offers a solution that s better than e books It s a virtual library that lets you easily search thousands of top tech books cut and paste code samples download chapters and find quick answers when you need the most accurate current information Try it for free at NEXT amp http safari oreilly com This page was created by the unregistered version of CHM To POF Converter by Theta Sottware PREY NEXT W Comments and Questions Please address comments and questions concerning this book to the publisher O Reilly Media Inc 1005 Gravenstein Highway North Sebastopol CA 95472 800 998 9938 in the United States or Canada 707 829 0515 international local 707 829 0104 fax There is a web page for this book that lists errata examples or any additional information You can access this page at http www oreilly com catalog umInut2 To comment or ask technical questions about this book send email to bookquestions oreilly c
307. wn to the current substate is called the state configuration For example a state configuration for Figure 8 6 could be Dispensing gt Releasing drink 8 2 1 1 Regions A region is shown using a dashed line dividing the decomposition compartment You may name each region by writing its name within the region s area Figure 8 8 shows a composite state with two regions Figure 8 8 A composite state with two regions This page was created by the unregistered version of CHM To POF Converter by Theta Sottware Dispensing Hamda drink Rotating drink rack Releasing drink Opening dispenser door entry start dink rack nalion _ entry telease cunent drink aniry release dispenser door dof bate drink rack F exit chee depansar door Marnie Gookkespeng e _ Leg Drink J Update f Purchase Inventory Each region has its own initial pseudostate see Pseudostates and a fina state A transition to a composite state is a transition to the initial pseudostate in each region Each region within a composite state executes in parallel and it is perfectly acceptable for one region to finish before another A transition to the final state of a region indicates completing the activity for that region Once all regions have completed the composite state triggers a completion event and a completion transition if one exists triggers 8 2 2 Submachine States Submachine states are semantically equivalent to composite states in that
308. xpression context and interfaces mapping attributes modeling and OCL and partitions and ports and states and 2nd 3rd CMS content management system code generators code model MDA collaboration diagram collaboration occurrences collaborations composite structures and interactions and Collection class collection types collections 2nd colon constraints and interaction overview diagram object names and OCL and 2nd 3rd 4th parameter name and 2nd port typing submachine states templated classes and combined fragments extra global interaction overview diagrams overview comma 2nd comments expressions and communication diagrams defined interactions and 2nd overview communication paths nodes and overview 2nd compartments artifacts in Classes and This page was created by the unregistered version of CHMI To POF Converter by Theta Sottware classifiers and components and 2nd decomposition operations and states and completion event completion transition 2nd component diagrams component views components defined deployment view and linking SPEM and components artifacts and black box view defined overview stereotypes white box view composite icon composite property attributes composite states defined overview transitions composite structure diagrams defined design view and implementation view and relationships between properties composite structures collabora
309. y Image k d J he a F 9 4 3 Expansion Regions You can show that an action or set of actions executes over a collection of input data by placing the actions in an expansion region For example if you had an action named Check Out Books that checked each of the provided books out of a library you can model the checkout book action using an expansion region with a collection of books as input You show an expansion region using a dashed rectangle with rounded corners surrounding the actions that should execute for each piece of input data Place a row of four input pins on the dashed boundary to represent a collection of data coming into the region You show a line with an arrow to the row of input pins and then from the input pins to the input pin of the first internal action Likewise you show a row of four output pins on the dashed boundary with edges coming from the last action s output pin to the row of four output pins on the region Figure 9 31 shows the Check Out Book expansion region Figure 9 31 Activity diagram with an expansion region Checkout Books ee ja Check Out eS chow Due is are S F Book Date J F The use of four input pins simply represents a collection of input data it doesn t specify how much data is actually presented to the expansion region The region executes for each piece of data in the collection and assuming there are no errors offers one piece of output data from each execution
310. y not named and don t have any kind of multiplicity UML allows for multiple inheritance meaning a class can have more than one generalization with each representing an aspect of the decedent class However some modern languages e g Java and C don t support multiple inheritance interfaces and interface realization are used instead This page was created by the unregistered version of CHM To POF Converter by Theta Sottware 2 6 6 Association Classes Often the relationship between two elements isn t a simple structural connection For example a football player may be associated with a league by virtue of being on a team If the association between two elements is complex you can represent the connection using an association class An association class is an association that has a name and attributes like a normal class You show an association class like a regular class with a dashed line connecting it to the association it represents Figure 2 29 shows a football player s relationships to a league Figure 2 29 Example association class FootballLeague FootballPlayer name String numTeams int playoffDale Date name String number int FootballTeam name String numPlayers int homecCity String When translated into code relationships with association classes often result in three classes one for each end of the association and one for the association class itself There may or may not b

Download Pdf Manuals

image

Related Search

Related Contents

Avaya 1120E User Guide  - Murdoch Research Repository  Manuel d`utilisation Nokia C2–03/C2–06  NMP-200U User`s Manual  

Copyright © All rights reserved.
Failed to retrieve file