+ All Categories
Home > Documents > Introduction to UML

Introduction to UML

Date post: 02-Jan-2016
Category:
Upload: james-blankenship
View: 50 times
Download: 3 times
Share this document with a friend
Description:
Introduction to UML. Fall 2005 OOPD John Anthony. What We’ll Discuss. What is UML (and a bit of history) Why we need UML Three UML usage modes Some Important Diagrams Use Case Diagrams Class Diagrams Sequence Diagrams State Diagrams Deployment Diagrams. What is UML. - PowerPoint PPT Presentation
Popular Tags:
29
Introduction to Introduction to UML UML Fall 2005 OOPD Fall 2005 OOPD John Anthony John Anthony
Transcript
Page 1: Introduction to UML

Introduction to Introduction to UMLUML

Fall 2005 OOPDFall 2005 OOPDJohn AnthonyJohn Anthony

Page 2: Introduction to UML

What We’ll DiscussWhat We’ll Discuss

What is UML (and a bit of history)What is UML (and a bit of history) Why we need UMLWhy we need UML Three UML usage modesThree UML usage modes Some Important DiagramsSome Important Diagrams

Use Case DiagramsUse Case Diagrams Class DiagramsClass Diagrams Sequence DiagramsSequence Diagrams State DiagramsState Diagrams Deployment DiagramsDeployment Diagrams

Page 3: Introduction to UML

What is UMLWhat is UML Unified Modeling Language Unified Modeling Language

(UML) is a family of (UML) is a family of graphical (and textual) graphical (and textual) notations that describes notations that describes different aspects of a different aspects of a software system.software system.

UMLUML helps you specify, helps you specify, visualize, and document visualize, and document models of software systems, models of software systems, including their structure and including their structure and design.design.

An Open standard controlled An Open standard controlled by the Object Management by the Object Management Group (OMG).Group (OMG).

http://www.omg.org/gettingstarted/what_is_uml.htm

http://www.omg.org/

Page 4: Introduction to UML

History of UMLHistory of UMLPre 1988

Peter Coad

Ivar Jacobson Jim Odell

Sally ShlaerSteve Mellor

Rebecca Wirfs-Brock

Jim Rumbaugh

Grady Booch

1994 Booch (Rational) & Rumbaugh (left IBM) begin to unify under Rational Software Corporation

1995Rational buys Objectory and aquires Ivar Jacobson brining the Object Oriented Software Engineering (OOSE)

Rational releases 0.8 of the Unified Method at OOPLSA ‘95

1996 OMG gets more involved to ensure CASE tool interoperability. Need to keep Rational honest!!!!

1997

UML .9 and .91 released

UML 1.0 released Contributors icnlude: DEC, HP, i-Logix, Intellicorp, INBM, ICON Computing, MCI Systemhouse, Microsoft, Oracle, Rational Software, Unisys, etc.

2004 OMG releases UML 2.0

1997 - 2003 OMG releases UML versions 1.2, 1.2, 1.3, 1.4, 1.5

Page 5: Introduction to UML

Goals of UMLGoals of UML

•Provide users with a ready-to-use, expressive visual modeling language so they can develop and exchange meaningful models.

•Provide extensibility and specialization mechanisms to extend core concepts.

•Be independent of particular programming languages and development processes.

•Provide a formal basis for understanding the modeling language.

•Encourage the growth of the OO tools market.

•Support higher-level development concepts such as collaborations, frameworks, patterns and components.

•Integrate best practices.

Page 6: Introduction to UML

Why Do We Need UML?Why Do We Need UML?

public Athlete(String name ) {

if(name == null || name.equals("")) {

this.name = this.DEFAULT_NAME;

}

this.name = name;

}

/**

*Creates a new instance of Athlete.

*@param name - the name of the athlete

*/We need a standard notation for describing the structure and behavior of a system.

Page 7: Introduction to UML

UML Diagram TypesUML Diagram TypesDiagramDiagram PurposePurpose TypeType LineageLineage

ActivityActivity Procedural and Procedural and parallel behaviorparallel behavior

BehaviorBehavior UML 1UML 1

ClassClass Class, features, Class, features, and relationshipsand relationships

StructureStructure UML 1UML 1

Communication Communication (formerly (formerly Collaboration)Collaboration)

Interaction Interaction between objects; between objects; emphasis on linksemphasis on links

InteractionInteraction UML 1UML 1

ComponentComponent Structure and Structure and connections of connections of componentscomponents

StructureStructure UML 1UML 1

Composite Composite StructureStructure

Runtime Runtime decomposition of a decomposition of a classclass

StructureStructure UML 2UML 2

DeploymentDeployment Deployment of Deployment of artifacts (software artifacts (software entities) to nodes entities) to nodes

StructureStructure UML 1UML 1

Interaction Interaction OverviewOverview

Mix of Sequence Mix of Sequence and activity and activity diagramsdiagrams

BehaviorBehavior UML 2UML 2

Page 8: Introduction to UML

DiagramDiagram PurposePurpose TypeType LineageLineageObjectObject Example Example

configurations of configurations of instancesinstances

StructureStructure Unofficially in UML 1Unofficially in UML 1

PackagePackage Compile-time Compile-time hierarchic hierarchic structurestructure

StructureStructure Unofficially in UML 1Unofficially in UML 1

SequenceSequence Interaction Interaction between objects; between objects; emphasis on emphasis on sequencesequence

BehaviorBehavior UML 1UML 1

State MachineState Machine Describes state of Describes state of an object based on an object based on eventsevents

BehaviorBehavior UML 1UML 1

TimingTiming Interaction Interaction between objects; between objects; emphasis on emphasis on timingtiming

BehaviorBehavior UML 2UML 2

Use CaseUse Case How users (and How users (and systems) interact systems) interact with a systemwith a system

BehaviorBehavior UML 1UML 1

UML Diagram Types UML Diagram Types (con’t)(con’t)

Page 9: Introduction to UML

Use Case(s)Use Case(s) A technique for capturing the functional requirements A technique for capturing the functional requirements

of a system.of a system.

They describe the interaction between the user They describe the interaction between the user (actor) and the system.(actor) and the system.

They help to communicate the scope of a development They help to communicate the scope of a development project.project.

An actor can be any entity that performs a role with a An actor can be any entity that performs a role with a given systemgiven system

UML provides guidance on Use Case diagrams but UML provides guidance on Use Case diagrams but not the contents of a Use Case (not the contents of a Use Case (referred to as a Use referred to as a Use Case SpecificationCase Specification).).

Page 10: Introduction to UML

ScenarioScenarioManagers are responsible for creating teams that, in Managers are responsible for creating teams that, in turn, are responsible for creating various products. turn, are responsible for creating various products. The creation of the team is based on approval from a The creation of the team is based on approval from a product development advisory committee. product development advisory committee.

Products are often created by assembling existing Products are often created by assembling existing components in novel ways. Each team may be components in novel ways. Each team may be composed of any number of team members. On composed of any number of team members. On occasion, teams may be combined to form larger occasion, teams may be combined to form larger teams. teams.

The state of a team can be described as following; The state of a team can be described as following; formed, on hold, active, and completed. formed, on hold, active, and completed.

Teams follow a process during the discovery and Teams follow a process during the discovery and creation of a product. The major steps include creation of a product. The major steps include Survey, Focus, Investigate, Transition, Develop.Survey, Focus, Investigate, Transition, Develop.

Page 11: Introduction to UML

Alternative BehaviorsAlternative Behaviors

What happens if the investigation What happens if the investigation phase does not warrant moving into phase does not warrant moving into the transition phase?the transition phase?

What if the Advisory Committee does What if the Advisory Committee does not approve the creation of a team?not approve the creation of a team?

Page 12: Introduction to UML

Example Use Case Example Use Case SpecificationSpecification

Form a TeamForm a TeamType: Main Success Scenario | AlternateType: Main Success Scenario | Alternate

Main Success Scenario:Main Success Scenario:1.1. Manager logs into the Idea Generation system.Manager logs into the Idea Generation system.2.2. Manager enters a new idea into the Idea Generation (the system) Manager enters a new idea into the Idea Generation (the system)

application.application.3.3. Manager creates a business case and cost benefit model to justify the Manager creates a business case and cost benefit model to justify the

creation of the team.creation of the team.4.4. Manager enters the proposes team members, start date, and estimated Manager enters the proposes team members, start date, and estimated

completion date into the system.completion date into the system.5.5. Manager uploads business case and cost benefit model into the system.Manager uploads business case and cost benefit model into the system.6.6. Manager receives appointment to present the new idea to the advisory Manager receives appointment to present the new idea to the advisory

committee.committee.7.7. Manager adds any additional details that me relevant to the new idea.Manager adds any additional details that me relevant to the new idea.8.8. Manager receives approval from the advisory committee.Manager receives approval from the advisory committee.9.9. Manager notifies team members and holds a kick-off meeting.Manager notifies team members and holds a kick-off meeting.

Extensions:Extensions:5a. Manager does not receive approval from advisory committee due missing 5a. Manager does not receive approval from advisory committee due missing

information in cost benefit modelinformation in cost benefit model1. Manager adds missing information to cost benefit model (return to 1. Manager adds missing information to cost benefit model (return to MSS step 4).MSS step 4).

Page 13: Introduction to UML

Use Case DiagramsUse Case Diagrams Provides a summarized graphical representation of a set of Provides a summarized graphical representation of a set of

Use Case Specifications.Use Case Specifications.

They reveal the actor(s), the Use Cases, and the They reveal the actor(s), the Use Cases, and the relationships between them.relationships between them.

Two types of Use Case relationships:Two types of Use Case relationships:

<<include>><<include>> - used when a Use Case - used when a Use Case willwill invoke another invoke another Use Case. Use Case. Analogy: method invocationAnalogy: method invocation

<<extend>><<extend>> - used when a Use Case - used when a Use Case maymay invoke another invoke another Use Case. Analogy: hardware interrupt Use Case. Analogy: hardware interrupt inheritanceinheritance – represents a specialization of the parent use – represents a specialization of the parent use casecase

Page 14: Introduction to UML

Example Use Case Example Use Case DiagramDiagram

actor

system bounda

ry

use case

Page 15: Introduction to UML

Class DiagramsClass Diagrams

Provides a structural view of the Provides a structural view of the classes of a system, their classes of a system, their features, features, andand the inter-relationships between the inter-relationships between the classesthe classes

Probably the most popular UML Probably the most popular UML diagram used to convey system diagram used to convey system structurestructure

Page 16: Introduction to UML

The Class IconThe Class Iconclass name

attributes

methods

+ updateStatus( status: int) : void

typemethodname

variablename

visibility return type

Page 17: Introduction to UML

VisibilityVisibilityVisibilityVisibility SymbolSymbol Accessible toAccessible to

PublicPublic ++ All objects within All objects within your system.your system.

ProtectedProtected ## Instances of the Instances of the implementing class implementing class and its subclasses.and its subclasses.

PrivatePrivate -- Instances of the Instances of the implementing class.implementing class.

PackagePackage ~~ Instance of classes Instance of classes within the same within the same package.package.

Page 18: Introduction to UML

AssociationsAssociations

When should you model a relationship as an attribute vs. an association?

• Associations are any type of relationship between two classes.• Composition – when something is part of something else.• Aggregation – when something contains a collection of things that are not part of it.

Another way to tell them apart – if the “part” has the same lifespan as the whole, then its composition.

At the end of the day, the most important goal is to model the association. Don’t fret about Composition vs. Aggregation.

Page 19: Introduction to UML

DependencyDependency There are other types of relationships that are There are other types of relationships that are

not based on composition or aggregation.not based on composition or aggregation. A dependency exists when one class depends on A dependency exists when one class depends on

behavior of another.behavior of another.

For example, consider the relationship between For example, consider the relationship between a team and a product.a team and a product.

Page 20: Introduction to UML

MultiplicityMultiplicity

The multiplicity of a property is The multiplicity of a property is an indication of how many an indication of how many objects may fill the property.objects may fill the property.

11 – only one object can be – only one object can be associated with the propertyassociated with the property

0..10..1 – zero or one object may – zero or one object may be associated with the be associated with the propertyproperty

** - any number of objects may - any number of objects may be associated with the be associated with the propertyproperty

Page 21: Introduction to UML

GeneralizationGeneralization

Depicts the “is a” relationship.Depicts the “is a” relationship.

Page 22: Introduction to UML

Sequence DiagramsSequence Diagrams

Shows the sequence of interactions between Shows the sequence of interactions between objects.objects.

Benefits include:Benefits include: Validate and flesh out the logic and completeness of a particular Validate and flesh out the logic and completeness of a particular

scenarioscenario Explore designs by allowing you to visually step through the Explore designs by allowing you to visually step through the

sequence of messagessequence of messages Indicates which classes may be highly coupled (i.e. receiving Indicates which classes may be highly coupled (i.e. receiving

many messages)many messages) Depicts instantiation and length of life of an object. Depicts instantiation and length of life of an object.

Major ChallengeMajor Challenge The level of detail is dependent on the intent of the diagram (more The level of detail is dependent on the intent of the diagram (more

on this later).on this later).

Page 23: Introduction to UML

Consider the Below Code Consider the Below Code SampleSample

public void createNewTeam() {public void createNewTeam() {

Team aTeam = new Team(this.generateUniqueTeamID());Team aTeam = new Team(this.generateUniqueTeamID());

for(int developerCount=0; developerCount < 3; developerCount++) {for(int developerCount=0; developerCount < 3; developerCount++) {

InnovationLabDeveloper developer = new InnovationLabDeveloper();InnovationLabDeveloper developer = new InnovationLabDeveloper();

developer.setEmployeeID(new Double(Math.random()).toString());developer.setEmployeeID(new Double(Math.random()).toString());

aTeam.addTeamMember(developer);aTeam.addTeamMember(developer);

}}

aTeam.updateStatus(Team.FORMED);aTeam.updateStatus(Team.FORMED);

this.sendNotification();this.sendNotification();

}}

From the class Manager

Page 24: Introduction to UML

Example Sequence Example Sequence DiagramDiagram

Page 25: Introduction to UML

Types of Interaction Types of Interaction FramesFrames

altalt AlternativeAlternative multiple frames; only the one whose condition is true multiple frames; only the one whose condition is true will execute. The guard indicates the expression to be evaluated. will execute. The guard indicates the expression to be evaluated. (Equivalent to an if, then, else construct.)(Equivalent to an if, then, else construct.)

optopt OptionalOptional; the fragment executes only if the supplied condition is ; the fragment executes only if the supplied condition is true. Equivalent to an alt with only on trace. true. Equivalent to an alt with only on trace. (Equivalent to an if (Equivalent to an if statement.)statement.)

parpar ParallelParallel; each fragment is executed in parallel. ; each fragment is executed in parallel. (Equivalent to (Equivalent to starting a new thread of execution).starting a new thread of execution).

looploop LoopLoop; the fragment may execute multiple times and the guard ; the fragment may execute multiple times and the guard indicates the basis of iteration. indicates the basis of iteration. (Equivalent to a looping construct.)(Equivalent to a looping construct.)

RegionRegion Critical RegionCritical Region; the fragment can have only one thread ; the fragment can have only one thread executing in it at once. executing in it at once. (Equivalent to “synchronize”).(Equivalent to “synchronize”).

negneg NegativeNegative; the fragment shows an invalid interaction. ; the fragment shows an invalid interaction. (Equivalent (Equivalent to an Exception.)to an Exception.)

refref ReferenceReference; refers to an interaction drawn on another diagram. ; refers to an interaction drawn on another diagram. Parameters and return values can be indicated. Parameters and return values can be indicated. (Provides a drill (Provides a drill down effect.)down effect.)

Page 26: Introduction to UML

(simple) State Diagram(simple) State DiagramState diagrams are used to describe the behavior of a system.  State diagrams describe all of the possible states of an object as events occur.  Each diagram usually represents objects of a single class and track the different states of its objects through the system. 

Page 27: Introduction to UML

Activity DiagramActivity Diagram

Activity Diagrams support the description of Activity Diagrams support the description of business processes and workflows. They can also business processes and workflows. They can also be used to depict a complex sequence of events be used to depict a complex sequence of events that may not be reflective a functional requirement.that may not be reflective a functional requirement.

A key feature of Activity diagrams is the ease of A key feature of Activity diagrams is the ease of showing parallelism.showing parallelism.

Page 28: Introduction to UML

Example Activity Example Activity DiagramDiagram

Page 29: Introduction to UML

Example Activity Example Activity Diagram (con’t)Diagram (con’t)


Recommended