You are on page 1of 40

,ch04.

17526 Page 71 Wednesday, May 9, 2001 4:02 PM

Chapter 4UML Tutorial

CHAPTER 4

A Unified Modeling Language Tutorial

UML Tutorial

This chapter presents a tutorial on the UML. I start with the example briefly mentioned in Chapter 2 and Chapter 3, and examine this problem using the various UML diagrams. This brief tutorial will introduce you to the different diagrams and elements of the UML. The tutorial is not intended to prescribe a particular process for developing models, but provides a learning mechanism by starting with small and intuitive models that are elaborated using the UML. The complete details of each diagram type are found in the reference chapters.

The Unified Modeling Language Diagrams
The UML defines nine types of diagrams: class, object, use case, sequence, collaboration, statechart, activity, component, and deployment diagrams. All of these diagrams are based on the principle that concepts are depicted as symbols and relationships among concepts are depicted as paths (lines) connecting symbols, where both of these types of elements may be named. The example of Chapter 2 and Chapter 3 involved an organization that desires an information system to better utilize employees (resources) on projects.

Use Case Diagrams
Use case diagrams describe the functionality of a system and users of the system. These diagrams contain the following elements: • • Actors, which represent users of a system, including human users and other systems. Use cases, which represent functionality or services provided by a system to users.

Figure 4-1 shows a Resource Manager actor who uses the functionality of the system to manage resources, a Project Manager actor who uses the functionality of the system to manage projects, a System Administrator actor who is responsible for

71

,ch04.17526 Page 72 Wednesday, May 9, 2001 4:02 PM

Project and Resource Management System (P&RMS)

Resource Manager

Manage Resources

Manage Projects

Project Manager

<<actor>> Backup System

Administer System

System Administrator

Figure 4-1: High-Level Use Case Diagram administrative functions of the system, and a Backup System actor that houses backup data for the system. The large rectangle represents the boundary of the system. The name of the system appears above the rectangle. The stick person icon represents an actor who is a human user. The Backup System rectangle icon represents an actor that is another system. The name of the Backup System actor is preceded by an “<<actor>>” string. This string is called a stereotype and indicates that the Backup System is an actor. This stereotype and the stick person icon are equivalent. The stick person icon is usually used to represent humans, whereas the “<<actor>>” string is usually used to represent systems. The ellipses represent use cases. The lines connecting actors and use cases indicate that the actors use or participate in the functionality provided by the use cases. This line is called a communicates relationship. Figure 4-2 elaborates the Manage Resources use case by detailing the functionality a Resource Manager actor expects of the system. Resource managers may add, remove, or update skills information. Because a skill must be found in the system database before it may be removed or updated, a Find Skill use case is utilized. The arrows from the Remove Skill use case and the Update Skill use case to the Find Skill use case are labeled with a “uses” stereotype to indicate that the Find Skill use case is called or included in the Remove Skill use case and the Update Skill use case. This arrow is called a uses relationship. Resource managers may also add, remove, or update resource information. The Remove Resource and Update Resource use cases utilize a Find Resource use case. 72 Chapter 4 – A Unified Modeling Language Tutorial

,ch04.17526 Page 73 Wednesday, May 9, 2001 4:02 PM

Add Skill

Remove Skill

<<uses>>

Find Skill

Update Skill

<<uses>>

UML Tutorial

Resource Manager Add Resource

Remove Resource

<<uses>>

Find Resource

Update Resource Assign Skill to Resource <<extends>> <<extends>>

<<uses>> Unassign Skill from Resource

Figure 4-2: Manage Resources Use Case Diagram Resource managers may assign a skill to a resource or unassign a skill from a resource while updating resource information. An Assign Skill to Resource use case and an Unassign Skill from Resource use case are utilized to depict this functionality. The arrows from these use cases to the Update Resource use case are labeled with an “extends” stereotype to indicate that these use cases are options from the Update Resource use case. This arrow is called an extends relationship. Use it when you want to make functionality optional to a use case. Figure 4-3 elaborates the Manage Projects use case by detailing the functionality a Project Manager actor expects of the system. The elements are similar to Figure 4-2. Use Case Diagrams 73

,ch04.17526 Page 74 Wednesday, May 9, 2001 4:02 PM

Find Project is required by the Remove Project and Update Project use cases, so they are connected by a uses relationship. A number of other use cases are optionally invoked by Update Project, so they are connected to it by an extends relationship.

Add Project

Find Project

<<uses>>

Remove Project Update Project Project Manager

<<uses>>

<<extends>>

<<extends>>

Add Activity <<extends>> Remove Activity <<extends>> Update Activity <<extends>> Assign Resource to Task

Add Task <<extends>> Remove Task <<extends>> <<extends>> Unassign Resource from Task Update Task

Figure 4-3: Manage Projects Use Case Diagram Figure 4-4 elaborates the Administer System use case by detailing the functionality a System Administrator actor and Backup System actor expect of the system. System administrators may start up the system, shut down the system, back up data to the Backup System actor, or restore data from the Backup System actor. Because backing up data is very common before a system is shut down, the Back Up Data use case is a connected option to the Shut Down System use case through an extends relationship. Because restoring data is very common after a system is started up, the Restore Data use case is a connected option to the Start Up System use case through an extends relationship. Because the Backup System actor is involved only in backing up or restoring data and is not directly involved in starting up or shutting down the system, the Backup System actor communicates only with the Restore Data use case and Back Up Data use case. The Back Up Data use case uses the combined functionality of a Back Up Project Data use case and a Back Up Resource Data use case. The Restore Data use case uses the 74 Chapter 4 – A Unified Modeling Language Tutorial

which represent relationships that relate two or more other classes where the relationships have common characteristics or features. 2001 4:02 PM Restore Resource Data <<uses>> <<uses>> Restore Project Data Restore Data <<extends>> Startup System <<actor>> Backup System Shutdown System <<extends>> Backup Data Backup Resource Data <<uses>> <<uses>> Backup Project Data System Administrator UML Tutorial Figure 4-4: Administer System Use Case Diagram combined functionality of a Restore Project Data use case and a Restore Resource Data use case. Class Diagrams 75 ..ch04. which represent entities with common characteristics or features. or how it is structured rather than how it behaves.17526 Page 75 Wednesday. These diagrams contain the following elements: • • Classes. operations. Use case diagrams are described in greater detail in Chapter 8. May 9. These features include attributes and operations. The combination of these use case diagrams and their supporting documentation is known as a use case model. These features include attributes. Use cases are usually described in a textual document that accompanies the use case diagram. Associations. and associations. Class Diagrams Class diagrams describe the static structure of a system.

. . and each activity may only belong to a single project. activities are related to tasks. The multiplicity indicators on this association specify that each project must have one or more activities. 76 Chapter 4 – A Unified Modeling Language Tutorial . The multiplicity specifies how many objects of the class are associated with a single object of the other class in the association. Project 1 1 . The paths represent relationships or associations. A similar relationship holds between the Activity class and the Task class. The “1” string attached to the Project class of the association between the Project class and the Activity class indicates that only one project is involved in the relationship. Projects contain one or more activities.*” string attached to the Activity class of the association between the Project class and the Activity class indicates that one or more activities are involved in the relationship. A project does not have any hours associated with it. Such a hollow diamond is used to indicate an aggregation relationship rather than a composition relationship. Each class must have a name within the rectangle.ch04. the diamond may be hollow. Thus.* Activity 1 1 . A project consists of activities. The association between the Activity class and the Task class specifies that each activity must have one or more tasks. 2001 4:02 PM Figure 4-5 shows that the system is concerned with projects. May 9..17526 Page 76 Wednesday.. If activities could exist without being associated with a project or a project could be removed without having to remove its activities. whereas tasks have associated resources for doing the work. activities. and each task may only belong to a single activity. The filled diamond attached to the Project class of the association between the Project class and the Activity class indicates that the project contains activities and that if the project is removed. Activities have associated deliverables or work products. and each association may have a name attached. and resources. The “1. The figure also shows that projects are related to activities. and activities consist of tasks.* Task * Assigned To 1 Resource Figure 4-5: High-Level Project Class Diagram Projects. but activities and tasks have hours indicating the duration required to do the work. so are its associated activities. tasks. activities. the filled diamond is used to indicate a composition relationship. The rectangles represent these concepts or classes. and tasks are all efforts of work. An activity may be associated with only one project. This is called the multiplicity of the Activity class within the relationship. and tasks are related to resources.

and the particular relationship between the Resource class and the others would be called an is-a-kind-of inheritance. salaried and hourly. a Salaried class object or Hourly class object may be used in its place. 2001 4:02 PM Resources may be assigned zero or more tasks. The arrows from the Salaried class and the Hourly class to the Resource class indicate that the Salaried class and the Hourly class inherit or receive all the characteristics of the Resource class. and a start date. which requires at least one instance. This arrow is called a generalization relationship. description. This class is called an association class. a Resource-Skill class is used. Association classes are used to maintain information about the relationship rather than the objects involved in the relationship. and the “*” multiplicity. Figure 4-6 shows that zero or more resources may be associated with zero or more skills. The association between the Task class and the Resource class specifies that zero or more tasks are associated with a single resource. May 9. any number of resources may have the same skill. The Resource class is reused by the Salaried class and Hourly class. The “*” string attached to the Task class of the association between the Task class and the Resource class indicates that zero or more tasks are involved in the relationship. Note the difference between the “1. The compartment below Class Diagrams 77 .. which permits zero as an option. In object-oriented languages.ch04. Thus. The association name has a small arrow indicating the direction in which to read the association name. and each resource may be associated with zero or more tasks. activities. Skill * Resource-Skill * Resource UML Tutorial Salaried Hourly Figure 4-6: High-Level Resource Class Diagram There are two kinds of resources. the arrow is not required. and tasks. the term inheritance is often used instead of generalization relationship. Because we want to maintain information about the relationship between a resource and a skill. The dashed line connecting the Resource-Skill class to the actual path indicates that the class maintains information about the relationship. Projects have a name. In this case. associations are read from left to right and top to bottom.*” multiplicity. If no arrow is attached. Each task may only be assigned to one resource.. This also indicates that whenever a Resource class object is used.17526 Page 77 Wednesday. Figure 4-7 details Figure 4-5 by defining what constitutes projects. The “1” string attached to the Resource class of the association between the Task class and the Resource class indicates that only one resource is involved in the relationship.

* + setNumber (Number : Integer) + getNumber () : Integer + setDesc (Desc : String) + getDesc () : String + setStartDate (StartDate : Date) + getStartDate () : Date + setHours (Hour : Integer) + getHours () : Integer + setDeliverable (Delv : String) + getDeliverable () : String + setResourceId (ResId : Integer) + getResourceId () : Integer + destroy () 1 Figure 4-7: Detailed Project Class Diagram Projects must provide services for setting and getting the values of their attributes. that is.StartDate : Date .Deliverable : String + create () : Activity + setNumber (Number : Integer) + getNumber () : Integer + setDesc (Desc : String) + getDesc () : String + setStartDate (StartDate : Date) + getStartDate () : Date + setHours (Hour : Integer) + getHours () : Integer + setDeliverable (Delv : String) + getDeliverable () : String + destroy () Resource 1 Assigned To * Task .Hours : Integer .. May 9. Project .Hours : Integer . Operations are behavioral features of the class.Names : String . Attributes are structural features of the class. This is known as private visibility. 2001 4:02 PM the name represents the attributes of the class. information about the class. the description attribute will hold a string value. The name attribute will hold a string value. and the getName operation returns the value of the Name attribute.ResourceId : Integer + create () : Task 1. The “create” operation is used to create an object of the class. The compartment below the attribute compartment represents the operations of the class.* Activity . and the start date attribute will hold a date value.ch04.StartDate : Date . the services (often known as methods in object-oriented languages) provided by the class. There are operations for setting and getting the values of all of the attributes.Number : Integer . The Project class must also provide services for creating and destroying objects of the class.Desc : String . The attributes are all inaccessible outside the class..Number : Integer . This oper- 78 Chapter 4 – A Unified Modeling Language Tutorial .Desc : String .StartDate : Date + create () : Project + setName (Name : String) + getName () : String + setDesc (Desc : String) + getDesc () : String + setStartDate (StartDate : Date) + getStartDate () : Date + destroy () 1 1.. Thus.Desc : String . that is. as indicated by the preceding “-” visibility character. the setName operation requires a string parameter to set the value of the Name attribute.17526 Page 78 Wednesday.

This operation is known as a constructor operation. The Salaried class and Hourly class also provide similar operations. a start date. with the only distinction being that activities have an associated deliverable and tasks have an associated resource. This operation is know as a destructor operation. The Resource-Skill class has a Prof attribute that may have the values of Expert or Novice. Because the operation is applied to the class rather than an object of the class. we use protected visibility. which is part of this chapter’s hypothetical system. and hourly resources have an associated hourly rate. a description. The information maintained about the relationship between a resource and a skill includes the proficiency of the resource and the years experience the resource has with the skill. Tasks have a number to describe the order in which they are done within an activity. May 9. The Task class provides appropriate operations for setting and getting the values of these attributes. Activities have a number to describe the order in which they are done within a project. Figure 4-8 shows that a Work Effort class represents everything common to activities and tasks. This operation requires no parameters and does not return anything. it is underlined. and operations for creating and destroying objects of the class. 2001 4:02 PM ation requires no arguments and returns a Project. the number of hours they require. a description. The “destroy” operation is used to destroy objects of the class. a start date. UML Tutorial Class Diagrams 79 . a Work Effort class is used as a base from which to define activities and tasks. This is known as public visibility. and operations for creating and destroying objects of the class. Resources have a name.ch04. When we want to make an attribute or operation inaccessible outside a class. the number of hours they require.17526 Page 79 Wednesday. and the deliverable product that results from the activity. details Figure 4-6 by defining what constitutes skills and resources. whereas the Activity class and the Task class have a generalization relationship to the Work Effort class. Because activities and tasks are very similar. The class also provides appropriate operations for setting and getting the values of these attributes. The Skill class provides appropriate operations for setting and getting the values of these attributes. The Work Effort class is reused to define the Activity class and the Task class Figure 4-9. Protected visibility is indicated by a preceding “#” character. The Activity class provides appropriate operations for setting and getting the values of these attributes. and an identification number of the resource who is responsible for the task. and operations for creating and destroying objects of the class. and operations for creating and destroying objects of the class. The operation may be applied to an object of the Project class just like the other operations. All of these operations are accessible outside the class. Salaried resources have an associated salary. but accessible to classes with a generalization relationship to the class. and a YearsExpr attribute for representing the number of years of experience.. The Resource class provides appropriate operations for setting and getting the values of this attribute. Skills have two attributes: a name and a description. and operations for creating and destroying objects of the class. as indicated by the preceding “+” visibility character.

StartDate : Date . they merely provide attributes and services shared by the classes that inherit them. the Resource class object and a SkillId attribute value of the Resource-Skill class are used to find the 80 Chapter 4 – A Unified Modeling Language Tutorial .* + create () : Task + setResourceId (ResId : Integer) + getResourceId () : Integer + destroy () Figure 4-8: Detailed Activities and Tasks Class Diagram Figure 4-10 details Figure 4-9 by defining how the relationship between skills and resources will be implemented. The class is specified as abstract by including the constraint string “abstract” in curly braces following the class name. and the ResourceId attribute of the Resource-Skill class stores the Id attribute of the associated Resource class object. We introduce the Identifiable class as an abstract class that simply provides an identification integer. The SkillId attribute of the Resource-Skill class stores the Id attribute of the associated Skill class object.17526 Page 80 Wednesday. Because we now know enough detail about how the Resource-Skill class maintains information about the association. 2001 4:02 PM Work Effort . To determine if a particular resource has a particular skill. May 9.ResourceId : Integer 1. the association may be refined. . Abstract classes cannot have instances. that is.Desc : String .Deliverable : String + create () : Activity + setDeliverable (Delv : String) + getDeliverable () : String + destroy () 1 Task . objects of these classes are now identifiable via their Id attribute.ch04. The Resource-Skill class must provide the capability to associate any number of resources with any number of skills. The Resource-Skill class stores the Id attributes of the associated Resource class object and Skill class object pairs..Hours : Integer + create () : Work Effort + setNumber (Number : Integer) + getNumber () : Integer + setDesc (Desc : String) + getDesc () : String + setStartDate (StartDate : Date) + getStartDate () : Date + setHours (Hours : Integer) + getHours () : Integer + destroy () Activity . The Skill class and the Resource class both inherit the characteristics of the Identifiable class.Number : Integer .

Name : String .. not every Resource class object must be associated with a Skill class object. Classes.YearsExpr : Real + create () : Resource-Skills + setProf (Prof : enum {Expert. The multiplicity on the association is changed to “0. and operations are usually described in a textual document that accompanies the class diagrams. The SkillId attribute of the Resource-Skill class is attached. They are elaborated with more and more detail until they can be virtually implemented.Desc : String + create () : Skill + setName (Name : String) + getName () : String + setDesc (Desc : String) + getDesc () : String + destroy () * * Resource . Novice} .17526 Page 81 Wednesday.ch04.Name : String + create () : Resource + setName (Name : String) + getName () : String + destroy () Resource-Skill . as a small rectangle. 2001 4:02 PM Skill . attributes. to the Resource class to indicate that a Resource class object and a SkillId value are used to partition or select zero or one Skill class object. The combination of these class diagrams and their supporting documentation is known as a class model.1” to specify that pairing a Resource class object and a qualifier value may or may not select a Skill class object. Class Diagrams 81 . This model is often referred to as an object model because it represents the possible configurations of objects within the system. associations. That is.Prof : enum {Expert.Salary : Real + create () : Salaried + setSalary (Salary : Real) + getSalary () : Real + destroy () Figure 4-9: Detailed Resource Class Diagram Hourly . May 9.. This collection of class diagrams is used to understand the system’s structure. Novice}) + getProf () : enum {Expert. Novice} + setYearsExpr (YearsExpr : Real) + getYearsExpr () : Real + destroy () UML Tutorial Salaried . There are situations where a particular resource simply does not have an associated skill.Rate : Real + create () : Hourly + setRate (Rate : Real) + getRate () : Real + destroy () associated Skill class object. The SkillId attribute attached to the Resource class is called a qualifier.

17526 Page 82 Wednesday. Links. Novice}) + getProf () : enum {Expert.” As you can see.” the second task is named “Test.. 82 Chapter 4 – A Unified Modeling Language Tutorial . The first task is named “Review.Id : Integer + getId () : Integer + setId () : Integer Resource-Skill .” and the third task is named “Deploy.” and the second task is named “Design. These are instances of associations. Novice} + setYearsExpr (YearExpr : Real) + getYearsExpr () : Real + destroy () * SkillId Resource . Each object has actual values for their attributes. Figure 4-11 shows a project named “Human Resource System Development” that consists of three activities. These are instances of classes.Name : String + create () : Resource + setName (Name : String) + getName () : String + destroy () Figure 4-10: Detailed Skills and Resources Class Diagram Class diagrams are described in greater detail in Chapter 7. an activity and a task) without confusion in the UML. The first task is named “Code. and the paths represents links. The object names are underlined and indicate the class of the object. May 9. which represent particular entities.ch04.1 Identifiable {abstract} . an object model describes a particular situation. . which represent particular relationships between objects. The first task is named “Analysis.YearsExpr : Real + create () : Resource-Skill + setProf (Prof : enum {Expert.” The third activity is named “Implementation” and consists of three tasks.” and the second task is named “Scope. The second activity is named “AnalysisDesign” and consists of two tasks. Object Diagrams Object diagrams describe the static structure of a system at a particular time. the same name can be assigned to two different elements (here. 2001 4:02 PM Skill .Prof : enum {Expert.SkillId : Integer . Object diagrams contain the following elements: • • Objects. Whereas a class model describes all possible situations. The first activity is named “Scope” and consists of two tasks. Novice} .Name : String .Desc : String + create () : Skill + setName (Name : String) + getName () : String + setDesc (Desc : String) + getDesc () : String + destroy () 0.” The rectangles in this diagram represent objects.ResourceId : Integer .

' Desc = 'This is our project' StartDate = Jan 5. 1998 Hours = 80 Deliverable = 'Scope Document' Review : Task Number = 1 Desc = 'Review existing system' StartDate = Jan 5. 1998 Hours = 40 ResourceId = 2 Scope : Task Number = 2 Desc = 'Scope new system' StartDate = Jan 19.. and the attributes of each person’s skills are shown in the Resource-Skill class objects connected by a dotted line to the relationships to Skill class objects. Dev. Each Resource class object represents a person in this figure. 1998 Hours = 40 ResourceId = 2 Design : Task Number = 2 Desc = 'Design solution' StartDate = Feb 16. follow the lines from each Resource class object to the related Skill class object. and each project contains one or more activities. each task belongs to only one activity. 1998 Hours = 40 ResourceId = 3 Deploy : Task Number = 3 Desc = 'Deploy solution' StartDate = March 30.ch04. May 9. 1998 Scope : Activity Number = 1 Desc = 'Scope project' StartDate = Jan 5. 2001 4:02 PM Human Resource System Development : Project Name = 'Human Resource Sys. 1998 Hours = 40 ResourceId = 3 Implementation : Activity Number = 3 Desc = 'Implementation' StartDate = March 2. 1998 Hours = 40 ResourceId = 2 Test : Task Number = 2 Desc = 'Test solution' StartDate = March 16. To understand the connections. 1998 Hours = 40 ResourceId = 1 AnalysisDesign : Activity Number = 2 Desc = 'Analysis and Design' StartDate = Feb 2. and seven years’ experience in Object Diagrams 83 . Andy has three years’ experience in gathering requirements. three years’ experience in doing analysis and design. 1998 Hours = 80 Deliverable = 'Anal/Des Doc' UML Tutorial Analysis : Task Number = 1 Desc = 'Analyze requirements' StartDate = Feb 2. 1998 Hours = 20 ResourceId = 3 Figure 4-11: Project Object Diagram All the multiplicity rules identified in the class diagram are adhered to. Figure 4-12 shows resources and their skills. 1998 Hours = 100 Deliverable = 'System' Code : Task Number = 1 Desc = 'Code solution' StartDate = March 2. For instance. each activity contains one or more tasks. each activity belongs to one project.17526 Page 83 Wednesday. that is.

ch04. A name is useful if we want to refer to an object independent of the values of its characteristics.17526 Page 84 Wednesday. Notice that the object has no name. 84 Chapter 4 – A Unified Modeling Language Tutorial . Id and Name). but instead may be identified by its characteristics (here. but is identified by its attributes. Andy is represented as an object.. May 9. Each of Andy’s skills are objects of the Skill class. 2001 4:02 PM Nora : Resource Id = 2 Name = 'Nora' : Resource Id = 3 Name = 'Phillip' : Resource-Skill SkillId = 1 ResourceId = 2 Prof = Expert YearsExpr = 9 : Skill Id = 1 Name = 'Req' Desc = 'Gathering requirements' : Resource-Skill SkillId = 1 ResourceId = 1 Prof = Novice YearsExpr = 3 : Resource-Skill SkillId = 2 ResourceId = 3 Prof = Expert YearsExpr = 5 : Skill Id = 2 Name = 'A/D' Desc = 'Analysis and Design' : Resource-Skill SkillId = 2 ResourceId = 1 Prof = Novice YearsExpr = 3 : Resource-Skill SkillId = 3 ResourceId = 3 Prof = Novice YearsExpr = 2 : Skill Id = 3 Name = 'Impl' Desc = 'Coding and Testing' : Resource-Skill SkillId = 3 ResourceId = 1 Prof = Expert YearsExpr = 7 : Resource Id = 1 Name = 'Andy' Figure 4-12: Resource Object Diagram coding and testing. This emphasizes the idea that an object need not be identified by its name. Such an object is called an anonymous object. and each relationship between the object representing Andy and his skills has an associated ResourceSkill class object.

” This invalidates the rule. This condition is called a guard condition Sequence Diagrams 85 . These interactions are modeled as exchanges of messages. which represent the existence of an object over a period of time. May 9. Nora has nine years’ experience in gathering requirements. which represent communication between objects. In this case. but the information about the relationships is actually maintained within Resource-Skill class objects. UML Tutorial Sequence Diagrams Sequence diagrams describe interactions among classes. and five years’ experience in doing analysis and design. If we discover an object diagram that invalidates the class model. Figure 4-13 shows a project named “Payroll System Development” in which the Task class object named “Design” belongs to the Activity class object named “AnalysisDesign” and the Activity class object named “Implementation. Figure 4-14 elaborates the Assign Skill to Resource use case. which represent roles that objects may play within the interaction. to find a resource. Messages. 2001 4:02 PM Phillip has two years’ experience in coding and testing. A resource manager will use the resource manager window. Sequence diagrams are a type of interaction diagram. Object diagrams are often used to validate the class model of a system. Object diagrams are described in greater detail in Chapter 7.ch04. It shows how a resource manager uses the system to assign a skill to a resource. and assign the skill to the resource. Activations. Notice that the Resource class object representing Nora is named “Nora. find a skill. The horizontal arrows between lifelines indicate the messages exchanged between objects. and how the classes within the system work together to provide this functionality. We either must change the class model to support this possibility or determine that the object diagram is invalid. and a skill using a Skill class object. The resource manager window will find a resource using a Resource class object. The horizontal arrows are labeled with the message that is sent between the class roles. Lifelines. Sequence diagrams contain the following elements: • • • • Class roles. A message triggers an operation in the receiving object. which represent the time during which an object is performing an operation.17526 Page 85 Wednesday. and the rule is valid. that a task may only belong to one activity. The objects at the top of the diagram represent class roles.. Notice that the Skill class objects are shared between the Resource class objects. which is a user interface. the object diagram is ill formed. These diagrams focus on classes and the messages they exchange to accomplish some desired behavior. The dashed lines that extend from each object represent lifelines. we must either change the class model or determine that the object diagram is invalid. They are named just like objects since they represent the objects that participate in the interaction. within the class model. For example. The thin rectangles placed on lifelines represent activations. The window will assign a skill to a resource if the skill is not already assigned to the resource.” This is optional.

17526 Page 86 Wednesday. 1998 Hours = 40 ResourceId = 2 Design : Task Number = 2 Desc = 'Design solution' StartDate = Feb 16. May 9. 1998 Scope : Activity Number = 1 Desc = 'Scope project' StartDate = Jan 5. 2001 4:02 PM Payroll System Development : Project Name = 'Payroll Sys.. The messages are replaced with actual messages sent between the objects. 1998 Hours = 40 ResourceId = 3 Implementation : Activity Number = 3 Desc = 'Implementation' StartDate = March 2. which are anonymous in this case. The message originating from the window lifeline to the Resource-Skill 86 Chapter 4 – A Unified Modeling Language Tutorial . 1998 Hours = 20 ResourceId = 3 Figure 4-13: Invalid Project Object Diagram and is indicated within square brackets on the message originating from the window lifeline to the Resource-Skill class role. Figure 4-15 shows how a resource manger assigns the “A/D” skill to Nora. 1998 Hours = 80 Deliverable = 'Scope Document' Review : Task Number = 1 Desc = 'Review existing system' StartDate = Jan 5.' StartDate = Jan 5. 1998 Hours = 40 ResourceId = 2 Test : Task Number = 2 Desc = 'Test solution' StartDate = March 16. 1998 Hours = 100 Deliverable = 'System' Code : Task Number = 1 Desc = 'Code solution' StartDate = March 2. 1998 Hours = 40 ResourceId = 1 AnalysisDesign : Activity Number = 2 Desc = 'Analysis and Design' StartDate = Feb 2. 1998 Hours = 40 ResourceId = 2 Scope : Task Number = 2 Desc = 'Scope new system' StartDate = Jan 19. Figure 4-16 shows a scenario in which a resource manager assigns the “Impl” skill to Andy.ch04. This diagram is called a scenario since it shows one possible use of the sequence diagram in Figure 4-14. 1998 Hours = 40 ResourceId = 3 Deploy : Task Number = 3 Desc = 'Deploy solution' StartDate = March 30. Notice that the condition on the message originating from the window lifeline to the Resource-Skill class role is satisfied and the message is sent.' Desc = 'This is an invalid proj. Dev. The class roles represent actual objects. 1998 Hours = 80 Deliverable = 'Anal/Des Doc' Analysis : Task Number = 1 Desc = 'Analyze requirements' StartDate = Feb 2.

2001 4:02 PM : Resource Manager Res Manager Win : User Interface Find Resource by Name : Resource : Skill : Resource-Skill Find Resource Find Skill Find Skill by Name Assign Skill to Resource [Resource is not assigned skill] Assign Skill to Resource UML Tutorial Figure 4-14: Assign Skill to Resource Sequence Diagram : Resource Manager Res Manager Win : User Interface Find Resource "Nora" : Resource : Skill : Resource-Skill Find Resource Find Skill Find Skill "A/D" Assign Skill to Resource Assign Skill "A/D" to Resource "Nora" Figure 4-15: Assign the A/D Skill to Nora Scenario (Sequence Diagram) class role is not shown since this skill is already assigned to Andy and the guard condition is not satisfied.17526 Page 87 Wednesday. and how the classes within the system work together to provide this functionality.ch04. This scenario and the scenario of Figure 4-15 are both satisfied by the sequence diagram of Figure 4-14.. The rectangles enclosing a Sequence Diagrams 87 . scenarios validate sequence diagrams. May 9. Figure 4-17 elaborates the Remove Project use case. Just as object diagrams may be used to validate class models. It shows how a project manager uses the system to remove a project from the database.

. or a loop.ch04. The condition for exiting a loop is shown at the bottom of the rectangle (“No More Tasks” or “No More Activities”).17526 Page 88 Wednesday. 2001 4:02 PM : Resource Manager Res Manager Win : User Interface Find Resource "Andy" : Resource : Skill : Resource-Skill Find Resource Find Skill Find Skill "Impl" Assign Skill to Resource Figure 4-16: Assign the Impl Skill to Andy Scenario (Sequence Diagram) set of messages represent repetition. : Project Manager Proj Manger Win : User Interface Find Project by Name : Project : Activity : Task Remove Project Find Activity by Project Find Task by Activity Remove Task [No more Tasks] Remove Activity [No more Activities] Remove Project Figure 4-17: Remove Project Sequence Diagram (Version 1) 88 Chapter 4 – A Unified Modeling Language Tutorial . May 9.

It shows how a system administrator uses the system to back up the database. modeled by Figure 4-11. 2001 4:02 PM A project manager will use the project manager window. the two are concurrently active and Sequence Diagrams 89 .ch04. The window completes processing by removing the project entry from the database. Figure 4-20 elaborates the Backup System use case. to specify a project to remove. The only difference is in how the repetition is depicted. the loops are not represented using rectangles but using a dashed line with an attached constraint string. and remove the activities. Once the project is found. The repetition continues until all the tasks and activities are removed. this scenario is used to validate the sequence diagrams of Figures 4-17 and 4-18. Because the Backup System actor is actually another system and not part of the original system. and how the Backup System actor is used within this interaction. from the system. May 9.. remove their tasks. In this case. and a Task class object to find and remove tasks. Again. the project manager window will repeatedly find the activities within the project.17526 Page 89 Wednesday. and the messages sent within the loops are shown. Notice that all the loops within the diagram are removed. The window uses an Activity class object to find and remove activities. which is a user interface. The constraint string specifies the extent of the loop. Figure 4-18 is equivalent to Figure 4-17. UML Tutorial : Project Manager Proj Manger Win : User Interface Find Project by Name : Project : Activity : Task Remove Project Find Activity by Project Find Task by Activity Remove Task {[Until No More Tasks]} Remove Activity {[Until No More Activities]} Remove Project Figure 4-18: Remove Project Sequence Diagram (Version 2) Figure 4-19 shows a scenario in which a project manager removes the “Human Resource System Development” project. Then the project manager window will find the project using a Project class object. The two diagrams are simply two alternative conventions for representing the same loops. and the dashed line specifies those messages that are sent within the loop.

May 9." Find 1st Activity ("Scope") Find 1st Task ("Review") Remove 1st Task ("Review") Find 2nd Task ("Scope") Remove 2nd Task ("Scope") Remove 1st Activity ("Scope") Find 2nd Activity ("AnalysisDesign") Find 1st Task ("Analysis") Remove 1st Task ("Analysis") Find 2nd Task ("Design") Remove 2nd Task ("Design") Remove 2nd Activity ("AnalysisDesign") Find 3rd Activity ("Implementation") Find 1st Task ("Code") Remove 1st Task ("Code") Find 2nd Task ("Test") Remove 2nd Task ("Test") Find 3rd Task ("Deploy") Remove 3rd Task ("Deploy") Remove 3rd Activity ("Implementation") Remove Project "Human Resource Sys. Dev.17526 Page 90 Wednesday..ch04. Dev. An active object or system may 90 Chapter 4 – A Unified Modeling Language Tutorial ." Figure 4-19: Remove Project Scenario (Sequence Diagram) communicate in an asynchronous manner. 2001 4:02 PM : Project Manager Proj Manger Win : User Interface : Project : Activity : Task Remove Project Find Project "Human Resource Sys. Both systems are active. as indicated by the “active” constraint attached to their names.

17526 Page 91 Wednesday. <<actor>> : Backup System {active} Prepare to Backup Data Acknowledged : P&RMS {active} Backup Data : System Administrator UML Tutorial Prepare for Projects Acknowledged Backup Project Data Acknowledged Prepare for Activities Acknowledged Backup Activity Data Acknowledged Prepare for Tasks Acknowledged Backup Task Data Acknowledged [No More Tasks] Tasks Complete Acknowledged [No More Activities] Activities Complete Acknowledged [No More Projects] Projects Complete Acknowledged Figure 4-20: Back Up Project Data Sequence Diagram (Version 1) Sequence Diagrams 91 . and their tasks. Synchronous messages (represented by full arrowheads) indicate that the sender actually passes control to the receiver and waits until control is returned before continuing. An asynchronous message indicates that the sender does not wait for the receiver to return control before continuing. Furthermore. The diagram shows how the systems will send messages back and forth asynchronously to coordinate the backing up of all the projects.. May 9. The half-arrowhead messages represent asynchronous messages sent between objects. their activities. two active objects may communicate asynchronously.ch04. 2001 4:02 PM request services from other objects.

Messages are sent asynchronously.ch04. 2001 4:02 PM Figure 4-21 is equivalent to Figure 4-20. 92 Chapter 4 – A Unified Modeling Language Tutorial .. All the loops within the diagram are removed. this scenario is used to validate the sequence diagrams of Figures 4-20 and 4-21. <<actor>> : Backup System {active} Prepare to Backup Data Acknowledged Prepare for Projects Acknowledged Backup Project Data Acknowledged Prepare for Activities Acknowledged Backup Activity Data Acknowledged Prepare for Tasks Acknowledged Backup Task Data Acknowledged { [Until No More Tasks] } Tasks Complete Acknowledged { [Until No More Activities] } Activities Complete Acknowledged { [Until No More Projects] } Projects Complete Acknowledged : P&RMS {active} Backup Data : System Administrator Figure 4-21: Back Up Project Data Sequence Diagram (Version 2) Figure 4-22 shows a scenario in which a system administrator backs up the “Human Resource System Development” project data. and the messages sent within the loops are shown. using dashed lines rather than rectangles.17526 Page 92 Wednesday. May 9. The only difference is in how the repetition is depicted. Again.

May 9.. Dev. 2001 4:02 PM <<actor>> : Backup System {active} : P&RMS {active} Backup Data : System Administrator Prepare to Backup Data Acknowledged Prepare for Projects Acknowledged Backup Project "Human Resource Sys.ch04.17526 Page 93 Wednesday." Data Acknowledged Prepare for Activities Acknowledged Backup 1st Activity ("Scope") Data Acknowledged Prepare for Tasks Acknowledged Backup 1st Task ("Review") Data Acknowledged Backup 2nd Task ("Scope") Data Acknowledged Tasks Complete Acknowledged Backup 2nd Activity ("AnalysisDesign") Data Acknowledged Prepare for Tasks Acknowledged Backup 1st Task ("Analysis") Data Acknowledged Backup 2nd Task ("Design") Data Acknowledged Tasks Complete Acknowledged Backup 3rd Activity ("Implementation") Data Acknowledged Prepare for Tasks Acknowledged Backup 1st Task ("Code") Data Acknowledged Backup 2nd Task ("Test") Data Acknowledged Backup 3rd Task ("Deploy") Data Acknowledged Tasks Complete Acknowledged Activities Complete Acknowledged Projects Complete Acknowledged UML Tutorial Figure 4-22: Back Up Project Data Scenario (Sequence Diagram) Sequence Diagrams 93 .

The class roles represent actual objects. The arrows between class roles indicate message flows exchanged between objects. Within nesting level 1.17526 Page 94 Wednesday. Messages that differ in one integer form a sequence at the same level of nesting. and a collection of sequence diagrams is part of the dynamic model of a system. Collaboration Diagrams Collaboration diagrams describe interactions among classes and associations. 2001 4:02 PM Sequence diagrams are used to understand the messages (and operations) that classes within a system must support in order to perform some desired behavior or functionality. Association roles. which are anonymous in this case. Sequence diagrams are described in greater detail in Chapter 9. messages are concurrent. Each collaboration diagram starts with message 1. May 9.3. Class roles are named just like objects since they represent the objects that participate in the interaction. that is. Sequence diagrams are said to specify use cases because they specify the messages exchanged between class roles to realize use cases. message 1 and message 2 are concurrent when originating from different class roles. and how the classes and their associations within the system work together to provide this functionality. message 1. Figure 4-23 is equivalent to Figure 4-14. The 94 Chapter 4 – A Unified Modeling Language Tutorial . and message 1. Figure 4-23 elaborates the Assign Skill to Resource use case. and a skill using a Skill class object. Collaboration diagrams are a type of interaction diagram. Figure 4-24 shows how a resource manger assigns the “A/D” skill to Nora. It shows how a resource manager uses the system to assign a skill to a resource. Scenarios are used to validate sequence diagrams.2. which represent messages sent between objects via links. etc. Among nesting levels (or when messages originate from different class roles). The message flows are labeled with both the sequence number of the message and the message that is sent between the class roles. This condition is called a guard condition and is indicated within square brackets on the message flow originating from the window class role to the Resource-Skill class role.2 precedes message 1. A message triggers an operation in the receiving object. which represent roles that links may play within the interaction. which represent roles that objects may play within the interaction. Collaboration diagrams contain the following elements: • • • Class roles.ch04.. The sequence numbers indicate the sequence of messages within the next higher level of nesting or passing of control. Links transport or implement the delivery of the messages. Other numbering schemes may also be used. The window will assign a skill to a resource if the resource is not already assigned the skill. A resource manager will use the resource manager window. which is a user interface.1 precedes message 1. The resource manager window will find a resource using a Resource class object. The links (lines or paths) represent association roles. Message flows. The objects in rectangles represent class roles. and assign the skill to the resource. find a skill. but they must be defined in the context in which they are used. to find a resource. These interactions are modeled as exchanges of messages between classes through their associations.

1 : Find Resource by Name : Resource-Skill : Resource Figure 4-23: Assign Skill to Resource Collaboration Diagram message flows are replaced with actual messages sent between the objects. The validation involves both the class roles used within the collaboration and the association roles that exist between the class roles. Figure 4-26 elaborates the Remove Project use case.1 Assign Skill "A/D" to Resource "Nora" UML Tutorial Res Manager Win : User Interface : Resource-Skill 1.1 : Find Skill by Name 1 : Find Resource 2 : Find Skill 3 : Assign Skill to Resource : Resource Manager 3.1 : Find Skill "A/D" 1 : Find Resource 2 : Find Skill 3 : Assign Skill to Resource : Resource Manager 3.1 [Resource is not assigned skill] : Res Manager Win Assign Skill to Resource : User Interface 1. This scenario and the scenario of Figure 424 are both satisfied by the collaboration diagram of Figure 4-23.17526 Page 95 Wednesday. May 9. 2001 4:02 PM : Skill 2. Notice that the condition on the message originating from the window class role to the Resource-Skill class role is satisfied and the message is sent.1 : Find Resource "Nora" : Resource Figure 4-24: Assign the A/D Skill to Nora Scenario (Collaboration Diagram) Figure 4-25 shows a scenario in which a resource manager assigns the “Impl” skill to Andy. Just as object diagrams may be used to validate class models. and how the Collaboration Diagrams 95 . : Skill 2. This diagram is called a scenario since it shows one possible use of the collaboration diagram. The message flow originating from the window class role to the Resource-Skill class role is not shown since this skill is already assigned to Andy and the guard condition is not satisfied. scenarios may be used to validate collaboration diagrams as well as sequence diagrams. It shows how a project manager uses the system to remove a project from the database..ch04.

The window completes processing by removing the project entry from the database. to specify a project to remove. The window uses an Activity class object to find and remove activities.3 : Find Task by Activity 1.ch04.1 : Find Skill "Impl" 1 : Find Resource 2 : Find Skill 3 : Assign Skill to Resource : Resource Manager Res Manager Win : User Interface 1.17526 Page 96 Wednesday. which is a user interface.4 : Remove Task {* [For all TAsks within Activities]} : Task Figure 4-26: Remove Project Collaboration Diagram A project manager will use the project manager window. or a loop. Then the project manager window will find the project using a Project class object.6 : Remove Project : Project {* [For all Activities] } 1 : Remove Project 1. and remove the activities. remove their tasks. May 9. 1. Notice that all of the 96 Chapter 4 – A Unified Modeling Language Tutorial .5 : Remove Activity Project Manager Win : User Interface : Activity : Project Manager 1.1 : Find Project by Name 1. Once the project is found. The specification of the loop is enclosed in square brackets.1 : Find Resource "Andy" : Resource-Skill : Resource Figure 4-25: Assign the Impl Skill to Andy Scenario (Collaboration Diagram) classes and their associations within the system work together to provide this functionality. The constraint strings enclosing an asterisk represent repetition. The repetition continues until all the tasks and activities are removed.2 : Find Activity by Project 1. the project manager window will repeatedly find the activities within the project.. 2001 4:02 PM : Skill 2. Figure 4-27 shows a scenario in which a project manager removes the “Human Resource System Development” project from the system. and a Task class object to find and remove tasks.

21 : Remove 3rd Activity ("Implementation") Proj Manager Win : Activity : User Interface 1 : Remove Project "Human Resource Sys. and all messages originating from the other system are synchronized with the messages from the Backup System actor." : Project 1. All the loops within the diagram are Collaboration Diagrams 97 .15 : Find 1st Task ("Code") 1. and their tasks.. Both systems are active. as indicated by the “active” constraint attached to their names. and the messages sent between class roles are shown.10 : Remove 1st Task ("Anaysis") 1. It shows how a system administrator uses the system to back up the database. Some of the sequence numbers are preceded by other sequence numbers and a forward slash. Dev. and how the Backup System actor is used within this interaction. Because the Backup System actor is actually another system and not part of the original system. The sequence numbers before the forward slash specify the messages that must have occurred to enable the message flow. 2001 4:02 PM loops are removed.14 : Find 3rd Activity ("Implementation") 1.19 : Find 3rd Task ("Deploy") 1. All messages originating from the Backup System actor are synchronized with the messages from the other system. 1.22 : Remove Project "Human Resource Sys.16 : Remove 1st Task ("Code") 1.8 : Find 2nd Activity ("AnaysisDesign") 1. Figure 4-29 shows a scenario in which a system administrator backs up the “Human Resource System Development” project data. the two are concurrently active and communicate in an asynchronous manner. This is used to synchronize concurrent active objects. this scenario is used to validate the collaboration diagram of Figure 4-26.17526 Page 97 Wednesday.20 : Remove 3rd Task ("Deploy") UML Tutorial : Task Figure 4-27: Remove Project Scenario (Collaboration Diagram) Figure 4-28 elaborates the Backup System use case.4 : Remove 1st Task ("Review") 1. May 9.5 : Find 2nd Task ("Scope") 1.2 : Find 1st Activity ("Scope") 1. The diagram shows how the systems will send messages back and fourth asynchronously to coordinate the backing up of all the projects.17 : Find 2nd Task ("Test") 1.12 : Remove 2nd Task ("Design") 1. Dev. their activities." 1.7 : Remove 1st Activity ("Scope") 1.9 : Find 1st Task ("Anaysis") 1.3 : Find 1st Task ("Review") 1.13 : Remove 2nd Activity ("AnaysisDesign") 1.6 : Remove 2nd Task ("Scope") 1.1 : Find Project "Human Resource Sys.18 : Remove 2nd Task ("Test") 1.ch04.11 : Find 2nd Task ("Design") 1. Again. Dev." : Project Manager 1.

5 : Acknowledged 1. this scenario is used to validate the collaboration diagram of Figure 4-28.6 / 1. performs some activity. or waits for some occurrence.5 : Backup Activity Data 2.3 : Acknowledged 1.7 / 1.7 : 2.7 : Ackowledged <<actor>> : Backup System {active} : Project Manager Figure 4-28: Back Up Project Data Collaboration Diagram removed.9 : Acknowledged {* [For all Projects]} : P&RMS {active} {* [For all Activities within Projects]} 1 : Backup Data {* [For all Tasks within Activities]} 2. which represent the situations during the life of an object in which it satisfies some condition. Statechart Diagrams Statechart (or state) diagrams describe the states and responses of a class. and the message flows are shown with their synchronization. 2001 4:02 PM 1.9 / 1.4 / 2.6 : Prepare for Tasks 2.1 : Acknowledged 1.5 / 2.5 / 1.10 : Projects Complete 1.6 / 2.4 : Prepare for Activities 2. Collaboration diagrams are used to understand the messages (and operations) that classes within a system must support in order to perform some desired behavior or functionality. Collaboration diagrams are said to realize use cases because they specify the messages exchanged between class roles and their association roles.10 : Acknowledged 2.8 / 1.1 : Prepare to Backup Data 2. Statechart diagrams describe the behavior of a class in response to external stimuli.3 / 1.2 : Prepare for Projects 2. May 9.8 : Tasks Complete 1.8 : Acknowledged 2.3 / 2.1 / 1.2 : Acknowledged 1.2 / 2.. and the associations that must exist between classes to enable the messages to flow among them.8 / 2.9 : Activities Complete 1. Chapter 4 – A Unified Modeling Language Tutorial 98 . These diagrams contain the following elements: • States.3 : Backup Project Data 2.4 : Acknowledged 1.1 / 2.6 : Acknowledged 1.4 / 1.ch04. Collaboration diagrams are described in greater detail in Chapter 10. Again.10 / 2.7 : Backup Task Data 1.17526 Page 98 Wednesday.2 / 1. A collaboration diagram is really the result of overlaying the messages from a sequence diagram onto a class diagram. Scenarios are used to validate collaboration diagrams.9 / 2. and a collection of collaboration diagrams are part of the dynamic model of a system.

May 9.2 / 2.16 : Prepare for Tasks 2.19 / 2." Data 2.3 : Backup Project "Human Resource Sys.1 / 1.8 : Acknowledged 1.18 / 1.12 : Backup 1st ("Anaysis") Task Data 2. Figure 4-30.8 : Backup 2nd ("Scope") Task Data 2. The figure also shows that a resource is initially not assigned to any tasks.6 : Prepare for Tasks 2.22 : Acknowledged 2.10 / 1.5 / 1.19 : Acknowledged <<actor>> : Backup System {active} 1 : Backup Data UML Tutorial : Project Manager Figure 4-29: Back Up Project Data Scenario (Collaboration Diagram) • Transitions.ch04.10 / 2.4 / 2.21 : Acknowledged : P&RMS {active} 2.2 : Acknowledged 1.8 / 2.15 : Backup 3rd Activity ("Implementation") Data 2..6 / 2.14 / 1.4 / 1.17 / 2.18 : Backup 2nd("Test") Task Data 2.12 : Acknowledged 1.20 : Acknowledged 2. Each state has a name.19 : Backup 3rd ("Deploy") Task Data 1.5 : Acknowledged 1.14 : Acknowledged 1.10 : Backup 2nd Activity ("AnaysisDesign") Data 2.4 : Prepare for Activities 2.5 : Backup 1st Activity ("Scope") Data 2. Statechart Diagrams 99 .17 : Acknowledged 1.14 : Tasks Complete 2.20 / 1. 2001 4:02 PM 1.9 : Tasks Complete 2.17 : Backup 1st ("Code") Task Data 2.1 : Acknowledged 1.7 : Acknowledged 1.18 / 2.11 : Acknowledged 1.2 / 1.20 / 2.22 : Projects Complete 1.22 / 2.9 : Acknowledged 1.6 : Acknowledged 1.9 / 2.6 / 1.20 : Tasks Complete 1.11 / 1.15 / 2.15 / 1.13 / 1.5 / 2. The small filled circle with an arrow points to the initial state.7 / 1.9 / 1.19 / 1. a statechart diagram that might be associated with our sample project.16 / 1.7 : Backup 1st ("Review") Task Data 2.11 / 2.7 / 2.13 : Acknowledged 1.15 : Acknowledged 1.12 / 2.10 : Acknowledged 1. The rectangles with rounded corners represent states.8 / 1.1 / 2.13 : Backup 2nd ("Design") Task Data 2.3 / 1. shows that a resource may be assigned no tasks or may be assigned some tasks.17 / 1.4 : Acknowledged 1.16 : Acknowledged 1.21 : Activities Complete 1.3 / 2.3 : Acknowledged 1.1 : Prepare to Backup Data 2.11 : Prepare for Tasks 2.13 / 2.18 : Acknowledged 1.2 : Prepare for Projects 2.21 / 2.17526 Page 99 Wednesday.12 / 1.16 / 2.14 / 2.21 / 1. Dev. which represent relationships between the different states of an object.

When a resource is unassigned from a task. when the incoming transition to “Deploy Systems” fires. An old value greater than 1 leaves the resource in the Assigned state. The transition is labeled with an event that triggers the transition. two resulting transitions fire and multiple states become active. In this case. the NumAssTasks is incremented to keep track of the number of tasks assigned to the resource. When the resource returns to the Not Assigned state. That is. When both systems are inactive. The short heavy bar with two transitions leaving it represents a splitting of control. May 9.17526 Page 100 Wednesday. whereas an old value of exactly 1 causes a state transition so that the resource is in the Not Assigned state. The short heavy bar with two transitions entering it represents a synchronization of control. the NumAssTasks attribute is decremented. we may retire the systems concurrently. The solid arrow between these two states represents a transition. a message is sent to inform the resource manager that the resource is idle..ch04. which is specified in square brackets following the event that triggers the transition. in which case the resource remains in the Assigned state and the NumAssTasks attribute is incremented. 100 Chapter 4 – A Unified Modeling Language Tutorial . 2001 4:02 PM Resource Manager Resource is Idle Not Assigned Assign Resource to Task / Increment NumAssTasks Un-assign Resource from Task [NumAssTask = 1] / Decrement NumAssTasks Assigned Un-assign Resource from Task [NumAssTask > 1] / Decrement NumAssTasks Assign Resource to Task/ Increment NumAssTasks Figure 4-30: Resource Statechart Diagram Assigning a task to a resource changes it from the Not Assigned state to the Assigned state. they will both be inactive. The effect of unassigning a resource thus depends on a condition. and an action that results from the transition. and the P&RMS’s state will depend on the state of the Backup System. When a resource is assigned. The dashed arrow from the transition to the Resource Manager actor represents a message sent to the object when the transition fires. Figure 4-31 shows that when the overall system to which all the models belong (P&RMS) and the Backup System are deployed. the resource may be assigned more tasks.

When the P&RMS becomes active. and system administrator functionality are all inactive. When the Backup System is shut down. the objects whose states are depicted in the diagram are destroyed. Then. the P&RMS backup utility is enabled.17526 Page 101 Wednesday.. The left side shows that when the Backup System is started. The circle surrounding a smaller filled circle represents the final state. the Back Up Data action occurs and the system enters the P&RMS Inactive state. when the P&RMS is shut down and the Backup System is enabled.ch04. the resulting transition fires. The right side of Figure 4-31 shows that when the P&RMS is started for the first time. 2001 4:02 PM Deploy Systems Backup System Inactive P&RMS Inactive Startup Backup System / Enable P&RMS Backup Utilities Startup P&RMS Startup P&RMS [First Usage] [Not First Usage] / Restore Data UML Tutorial Backup System Active Shutdown Backup System / Disable P&RMS Backup Utilities [Retire Systems] P&RMS Active Shutdown P&RMS [Backup System Enabled] / Backup Data Figure 4-31: System Statechart Diagram That is. the P&RMS backup utility is disabled. May 9. Once the two systems are retired. when all the incoming transitions fire. nothing else occurs. the system simply becomes active. project manager functionality. when the P&RMS system is restarted (not the first use). the system becomes active and data is restored from the Backup System. However. The P&RMS Active state is called a superstate and has its name displayed at the top of Statechart Diagrams 101 . the resource manager functionality. Once the final state is reached. Figure 4-32 elaborates the P&RMS Active state by detailing the states of the different parts of the system.

ch04. When a resource manager starts processing. May 9. which represent responsibilities of one or more objects for actions within an overall activity. the parts of the system that provide the resource manager functionality become busy until the processing is complete. but activity diagrams describe the behavior of a class in response to internal processing rather than external events as in statechart diagrams. These diagrams are similar to statechart diagrams and use similar conventions. These diagrams are part of the dynamic model of a system.. Activity Diagrams Activity diagrams describe the activities of a class. 102 Chapter 4 – A Unified Modeling Language Tutorial . Statechart diagrams are described in greater detail in Chapter 11. Statechart diagrams are used to understand the messages (and operations) and attributes that classes within a system must support in order to perform some desired behavior or functionality. that is. Similar effects take place when a project manager starts processing or a system administrator starts processing.17526 Page 102 Wednesday. The superstate is divided into three concurrent substates for each part of the system. they divide the activity states into groups and assign these groups to objects that must perform the activities. 2001 4:02 PM P&RMS Active Resource Manager Functionality Resource Manager Starts Processing Complete Processing Project Manager Functionality Project Manager Starts Processing Complete Processing Idle Busy Idle Busy System Administrator Functionality System Administrator Starts Processing Complete Processing Idle Busy Figure 4-32: System Substate Statechart Diagram the state. These diagrams contain the following elements: • Swimlanes.

The regions denoted by vertical solid lines are swimlanes. Notice that an initial and a final state are used. 2001 4:02 PM • • • Action states. Action flows. The dashed arrows represent object flows. Object flows originating from an action state indicate that the action creates or influences the object. as in statechart diagrams. The solid arrows represent action flows that are automatically triggered at the completion of the action states. Once a resource is found by name. which represent relationships between the different action states of an entity. Once a skill is found by name. the skill is found by name and is assigned to the resource. which represent the utilization of objects by action states and the influence of action states on objects. a skill object is created. actions of entities or steps in the execution of an algorithm. and the objects at the top of the swimlanes are responsible for the action states within the swimlane. The shapes with straight top and bottom lines and convex arcs on the sides are action states.. Object flows from an object to an action state indicate that the action state uses the object. a Skill class object will find the skill by name. or noninterruptible. Object flows. : Resource : Skill : Resource-Skill UML Tutorial Find Resource by Name [Resource is assigned skill] Find Skill by Name S : Skill R : Resource [Resource is not assigned skill] Assign Skill to Resource : Resource-Skill Figure 4-33: Assign Skill to Resource Activity Diagram After a resource is found by name. May 9. Assigning a skill to a resource uses the two objects created by the previous steps. Activity Diagrams 103 . Figure 4-33 shows how the Assign Skill to Resource use case is performed.17526 Page 103 Wednesday. which represent atomic. and a Resource-Skill class object will assign the skill to the resource. The figure shows how the classes within the system work together and perform actions to provide this functionality: A Resource class object will find the resource by name.ch04. a resource object is created.

ch04. These diagrams are used to understand the operations that classes within a system must support in order to perform some desired behavior or functionality. Figure 4-34 shows the development-time and run-time physical objects implementing the system. Deployment Diagrams Deployment diagrams describe the configuration of processing resource elements and the mapping of software implementation components onto them. in Figure 4-34. Component diagrams are described in greater detail in Chapter 13. These diagrams contain components. which represent distributable physical units. Activity diagrams are described in greater detail in Chapter 12. (Object) System Admin. (Source) System Admin. the System Administrator executable program is dependent on the System Administrator object code component. and the System Administrator object code component is dependent on the System Administrator source code file. including source code. The rectangles with two small rectangles projected from the side represent components.17526 Page 104 Wednesday.. The small labeled circle attached via a line to a component represents an interface. and to understand how these objects interact with other objects in the system. Thus. May 9. Business (Source) Business Operations System Admin. Component Diagrams Component diagrams describe the organization of and dependencies among software implementation components. These 104 Chapter 4 – A Unified Modeling Language Tutorial . These diagrams are part of the dynamic model of a system. (Executable) Manage Res (Source) Manage Res (Object) Manage Res (Executable) Manage Proj (Source) Manage Proj (Object) Manage Proj (Executable) Figure 4-34: System Component Diagram The object code components are dependent on their associated source code components. Similar dependencies are shown for the Manage Resource and Manage Project executable programs. and executable code. Their source code files use the business operations provided by the Business component. object code. 2001 4:02 PM Activity diagrams are similar to statechart diagrams. The dashed arrows represent dependencies between components.

Other Notation and Information Figure 4-36 shows how model elements may be grouped into packages and related.” Deployment diagrams are described in greater detail in Chapter 14.17526 Page 105 Wednesday. (Executable) Res. the User Interface package contains classes that implement the user interface of a system.. This figure also shows that the project manager application will execute on a project manager desktop client computer. which represent processing or computational resources. In Figure 4-36. 2001 4:02 PM diagrams contain components and nodes. (Executable) Common App. Manage Desktop Client Manage Res (Executable) Proj. Figure 4-35 shows that the resource manager application will execute on a resource manager desktop client computer. Manager Desktop Client Manage Proj (Executable) Figure 4-35: System Deployment Diagram The system administrator application and other common application components will execute on the server and access a database server containing the database object named “DB. The large rectangles with a small rectangle attached on one corner represent packages. The Business package contains classes that represent business objects.ch04. Packages are general-purpose grouping mechanisms used to organize model elements. Server System Admin. The three-dimensional cubes represent nodes. The solid paths represent lines of communication between nodes. They are used within the other diagrams. May 9. and so forth. The Communication package contains classes that are used to Other Notation and Information 105 . printers. Database Server DB : Database Printer Printer UML Tutorial App. Both types of computers have access to printers and an application server. including computers.

The User Interface package is dependent on the Business package and the Utility package. The term “project” references the Project class object of or linked with an Activity object. The constraint string attached to the Resource class represents this rule. and Report Processing package are dependent on the Utility package. They may be attached to specific model elements using dashed lines or attached to the whole diagram rather than any specific model element. notes. Business Communication Database File Processing Report Processing Utility Figure 4-36: Packages communicate with other systems. The Utility package contains general utility classes. The Communication package. Figure 4-37 shows a class diagram with rules or constraints attached to different elements. Database package. Note that there may only be one Project class object for any Activity class object (as specified by the multiplicity). and Utility package. 2001 4:02 PM User Interface This package contains core business-related classes. Packages. The term “task” references the collection of Task class objects of the Resource object. and the “size” is a predefined attribute of a collection (as explained in Chapter 16). All activities must belong to projects that start after January 1. The Business package is dependent on the Communication package. Database package. File Processing package. Note that there 106 Chapter 4 – A Unified Modeling Language Tutorial . All resources must have less than 15 tasks assigned to them. and the StartDate references the StartDate attribute of the Project class object.ch04. The Report Processing package contains classes used for generating reports. 1999. May 9. The Database package contains classes used to access a database. Notes may be placed on diagrams to attach text to model elements. The constraint string attached to the Activity class represents this rule.. Rectangles with a bent upper right corner represent notes. The File Processing package contains classes used for processing files. All projects in this diagram must start before January 1.17526 Page 106 Wednesday. Report Processing package. and general diagramming are described in greater detail in Chapter 6. to which all objects of the class must adhere. The constraint string attached to the Project class represents this rule. File Processing package. 1998.

Desc : String . The constraint string attached to the Task class represents this rule.Number : Integer . No two tasks within the same activity may have the same number.Number : Integer .* + getNumber () : Integer + setDesc (Desc : String) + getDesc () : String + setStartDate (StartDate : Date) + getStartData () : Date + setHours (Hours : Integer) + getHours () : Integer + setDeliverable (Delv : Integer) + getDeliverable () : Integer + setResourceId (ResId : Integer) + getResourceId () : Integer + destroy () {allInstances->forAll (t1. The “forAll” specifies that all objects of the class are iterated over.Number<>t2.Name: String . and the “t2” variable references another object. 1999} Resource . t2 | t1<>t2 implies t1.activity=t2.Number)} UML Tutorial Figure 4-37: Detailed Project Class Diagram with OCL Expressions may be any number of Task class objects associated with any Resource class objects (as specified by the multiplicity). May 9. The “t1” variable references one object.StartDate > January 1.StartDate : Date .StartDate : Date .17526 Page 107 Wednesday. 2001 4:02 PM Project .Hours : Integer .activity implies t1.. . this is why the arrow operator is used..Hours : Integer .StartDate : Date + create () : Project + setName (Name : String) + getName () : String + setDesc (Desc : String) + getDesc () : String + setStartDate (StartDate : Date) + getStartData () : Date + destroy () 1 {StartDate < January 1.ResourceId : Integer + create () : Task + setNumber (Number : Integer) 1. “t1<>t2” dictates that we have two Other Notation and Information 107 .Desc : String .Deliverable : String + create () : Activity + setNumber (Number : Integer) 1 + getNumber () : Integer + setDesc (Desc : String) + getDesc () : String + setStartDate (StartDate : Date) + getStartData () : Date + setHours (Hours : Integer) + getHours () : Integer + setDeliverable (Delv : Integer) + getDeliverable () : Integer + destroy () {project.Desc : String .Name : String + create () : Resource + setName (Name : String) + getName () : String + destroy () 1 {task->Size <15} Assigned To 1. 1998} * Task .* Activity .ch04.

and Task classes are entity stereotypes representing database information. or an icon with a class rectangle. The string “actor” enclosed in guillemets (<< >>). An actor is a stereotype of a class. The first property is a constraint specifying that an object of the class is created. Figure 4-40 shows a Skill class with two properties or characteristics. The second property indicates that objects of the class have a keyword “documentation” and a value associated with this keyword. If we do. if so. and a natural language may be used in place of the OCL.17526 Page 108 Wednesday. These stereotypes are predefined in the UML. and. <<actor>> Resource Manager <<actor>> Resource Manager Resource Manager Resource Manager Figure 4-38: Stereotypes The UML allows new types of elements to be established using a stereotype. Activity. including the standard stereotypes. Figure 4-39 shows a project manager who is removing a project. The OCL is described in greater detail in Chapter 16.ch04. constraints.activity” dictates that the tasks belong to the same activity. the object model is ill formed. The Remove Project is a control class that is responsible for controlling interactions among a collection of objects. If this rule fails for any objects. Properties of model elements are used by modeling tools and enable us to associate information with model elements. They are described in greater detail in Chapter 15. The UML stereotypes enable the UML to be extended with new types of modeling elements. preceding the name of the element indicates the type of the element. May 9. Stereotype icons are used within the diagram to emphasize the types of objects involved. 2001 4:02 PM different tasks.activity=t2. or double angle brackets. the task numbers should be different. The Project. a stereotype string. The Project Manager Window is an interface class.. and the second property is called a keyword-value pair or tagged value. there are four ways to depict an instance of the element: an icon. and are explained in Chapter 15. Once a new type of element is established. these expressions specify rules to which objects of the class must adhere. The Object Constraint Language (OCL) is a language for expressing conditions attached to model elements. These are called extension mechanisms. 108 Chapter 4 – A Unified Modeling Language Tutorial . Some expressions can be very complex. Figure 4-38 shows four different ways to represent an actor. “t1. and tagged values. both an icon and a stereotype string. When attached to a class. and properties enable the UML to be customized to support specialized characteristics of model elements.

ch04. 2001 4:02 PM 3. May 9..17526 Page 109 Wednesday.2 : Find Activity by Project 3. documentation = This class is created in an interaction and represents a skill of a resource} Figure 4-40: Constraints and Tagged Values Other Notation and Information 109 .3 : Remove Activity 1 : Remove Project 2 : Remove Project : Project Manager : Project Manager Window : Remove Project Activity Task 3.6 : Remove Project {* [For all Activities]} Project 3.1 : Find Project by Name 3.4 : Find Task by Activity 3.5 : Remove Task {* [For all Tasks within Activities]} UML Tutorial Figure 4-39: Remove Project Collaboration Diagram Skill {new.

May 9.17526 Page 110 Wednesday. 2001 4:02 PM ..ch04.