unified modeling language (uml)

281
nu Institute of technology – Website: www.vishnu.edu.in Unified Modeling Language (UML) P.S.Suryateja Asst. Professor CSE Department Vishnu Institute of Technology The Three Amigos

Upload: morey

Post on 14-Jan-2016

73 views

Category:

Documents


2 download

DESCRIPTION

The Three Amigos. Unified Modeling Language (UML). P.S.Suryateja Asst. Professor CSE Department Vishnu Institute of Technology. Outline. Introduction to UML Importance of modeling Principles of modeling Object oriented modeling Overview of UML Conceptual model of the UML - PowerPoint PPT Presentation

TRANSCRIPT

Unified Modeling Language (UML)

Unified Modeling Language (UML)P.S.SuryatejaAsst. ProfessorCSE DepartmentVishnu Institute of Technology

The Three AmigosVishnu Institute of technology Website: www.vishnu.edu.inOutlineIntroduction to UMLImportance of modelingPrinciples of modelingObject oriented modelingOverview of UML Conceptual model of the UMLArchitectureSoftware development life cycle (RUP)Structural ModelingClassesRelationshipsCommon mechanismsDiagrams Class diagramsAdvanced classesAdvanced relationshipsObject diagrams

Vishnu Institute of technology Website: www.vishnu.edu.inOutline (cont)Behavioral ModelingInteractionsInteraction diagramsUse casesUse case diagramsActivity diagramsEvents and signalsState machinesState chart diagramsArchitectural ModelingComponentsDeploymentComponent diagramsDeployment diagramsCommon modeling techniques

Vishnu Institute of technology Website: www.vishnu.edu.inPrerequisitesObject orientation concepts

Software engineeringVishnu Institute of technology Website: www.vishnu.edu.inObjectivesLearn what is UML.

Learn why UML is relevant to developing software systems.

Learn how to speak the language effectively.

Learn how to apply UML.Vishnu Institute of technology Website: www.vishnu.edu.inOutcomesAbility to read UML models.

Ability to develop UML models.Vishnu Institute of technology Website: www.vishnu.edu.inSoftware System - DefinitionSoftware [Set of programs](Source Code)Configuration files, system documentation, end-user documentation, test results, maintenance records etc

+Vishnu Institute of technology Website: www.vishnu.edu.inSoftware System - ExamplesOperating systemsComputer reservation systemsAir traffic control systemsMilitary command and control systemsTelecommunication networksContent management systemsDatabase management systemsExpert systems etcVishnu Institute of technology Website: www.vishnu.edu.inIntroduction to ModelingVishnu Institute of technology Website: www.vishnu.edu.inModeling

What?Where?Why?How?Vishnu Institute of technology Website: www.vishnu.edu.inModelA model is a simplified representation of the real thing/system.

A model captures the important aspects of the thing being modeled.

A model is expressed in a medium that is convenient for working.Vishnu Institute of technology Website: www.vishnu.edu.inModel (cont)

ConstructionVishnu Institute of technology Website: www.vishnu.edu.inModel (cont)

Software DesignVishnu Institute of technology Website: www.vishnu.edu.inModeling (cont)What?The art and science of developing models.

Why?To understand the system in a better/easier way.

Where?Design phase (most of the time).

How?That is what UML is for.Vishnu Institute of technology Website: www.vishnu.edu.inImportance of ModelingWe build models to:Communicate the structure and behavior of the system.Visualize and control the system's architecture.Understand the system we are building in a better manner.Manage risks.Vishnu Institute of technology Website: www.vishnu.edu.inPrinciples of ModelingThe choice of what models to create has a profound influence on how a problem is attacked and how a solution is shaped.

Every model may be expressed at different levels of precision.

The best models are connected to reality.

No single model is sufficient. Every non-trivial system is best approached through a small set of nearly independent models.Vishnu Institute of technology Website: www.vishnu.edu.inSoftware Design

Vishnu Institute of technology Website: www.vishnu.edu.inObject Oriented Analysis and DesignOOAD is a software engineering approach that models a system as a group of interacting objects.

The notation for representing these models is UML.

OOA focuses on what the system does. Models consists of use-case, class and interaction diagrams.

OOD focuses on how the system does it. Detailed diagrams.

Vishnu Institute of technology Website: www.vishnu.edu.inObject Oriented ModelingTwo approaches fordeveloping modelsAlgorithmicPerspectiveObject-OrientedPerspective Traditional approach Fundamental unit is function Functional decomposition Difficult to maintain Modern approach Fundamental unit is object or class Communication through messages Easy to maintain and enhanceVishnu Institute of technology Website: www.vishnu.edu.inWhat are Models For?To capture and precisely state requirements and domain knowledge so that all stakeholders may agree and understand them.

To think about the system design.

To capture design decisions in a mutable form separate from the requirements.

To generate usable work products.Vishnu Institute of technology Website: www.vishnu.edu.inWhat are Models For? (cont)To organize, find, filter, retrieve, examine, and edit information about large systems.

To explore multiple solutions economically.

To master complex systems.Vishnu Institute of technology Website: www.vishnu.edu.inWhat is in a Model?Syntax

Semantics

PresentationVishnu Institute of technology Website: www.vishnu.edu.inModeling work process

Ref: UML 2 Tool Kit by Eriksson, Penker, Lyons, FadoVishnu Institute of technology Website: www.vishnu.edu.inSketching: Use informal tools such as whiteboard and Post-It notes

Organization: Organize the informal sketch in a tool to produce more formal diagrams

Specifying: Specify the details of the diagram (iterative process as more and more is learned about the model)

Integrating, Verifying and Validating: Check the diagram against other diagrams, and verify and validate that requirements are correctly met.

Prototyped and Tested: Make a prototype and test it (a number of diagrams may be prototyped in one step)

Evaluate: Evaluate the result. Go back and correct any deficiencies.23Introduction to UMLVishnu Institute of technology Website: www.vishnu.edu.inUML - Introduction

What?Where?Why?How?Vishnu Institute of technology Website: www.vishnu.edu.inUML Introduction (cont)What?A modeling language for visualizing, specifying, constructing and documenting the artifacts of a software system.

Why?UML is a industry standard modeling language.

Where?Design phase (most of the time).

How?That is what the subject is about.Vishnu Institute of technology Website: www.vishnu.edu.inUML Applicable DomainsEnterprise information systemsBanking and Financial servicesTelecommunicationsTransportationDefenseRetailMedical electronicsScientificDistributed web-based servicesVishnu Institute of technology Website: www.vishnu.edu.inWhy Unified?UML is unified across several domains:Across historical methods and notationsAcross the development lifecycleAcross application domainsAcross implementation languages and platformsAcross development processesAcross internal conceptsVishnu Institute of technology Website: www.vishnu.edu.inHistory of UML

PrehistoryFusion1st unificationattemptOMT, Booch, CRCBooch &Rumbaugh(OMT) joinRationalJacobson (Objectory) joinsRationalUML work beginsObject ManagementGroup RFPUML proposalaccepted byOMG1994199519961997Schlaer/MellorBoochRumbaugh(OMT)Jacobson(Objectory)Coad/YourdonUML becomesan industrystandard20042003UML 1.xUML 2.0Ongoing UML developmentA major upgrade to UML at the end of 2003:Greater consistencyMore precisely defined semanticsNew diagram typesBackward compatibleLatest Version: 2.4.1Published on Aug 2011The Three AmigosVishnu Institute of technology Website: www.vishnu.edu.inOverview of UMLVishnu Institute of technology Website: www.vishnu.edu.inUML is a Language for VisualizingProblems with non-standard modeling (textual):Communicating conceptual models to others is error-prone unless everyone involved speaks the same language.

There are some things about a software system you can't understand unless you build models.

If the developer who created the code never wrote down the models that are in his or her head, that information would be lost forever.Vishnu Institute of technology Website: www.vishnu.edu.inUML is a Language for SpecifyingSpecifying means building models that are precise, unambiguous and complete.

UML addresses the specification of all important decisions regarding:AnalysisDesignImplementationVishnu Institute of technology Website: www.vishnu.edu.inUML is a Language for ConstructingUML models can be directly connected to various programming languages such as Java, C#, VB etc.

Forward engineering

Reverse engineering

Round trip engineeringVishnu Institute of technology Website: www.vishnu.edu.inForward Engineering ExampleCustomer- cid- cname- mobile- email+ purchase( )+ login( )+ logout( )+ search( )class Customer{private int cid;private String cname;private String mobile;private String email;

public void purchase( ) { }public void login( ) { }public void logout( ) { }public void search( ) { }}Vishnu Institute of technology Website: www.vishnu.edu.inReverse Engineering Exampleclass Customer{private int cid;private String cname;private String mobile;private String email;

public void purchase( ) { }public void login( ) { }public void logout( ) { }public void search( ) { }}Customer- cid- cname- mobile- email+ purchase( )+ login( )+ logout( )+ search( )Vishnu Institute of technology Website: www.vishnu.edu.inRoundtrip Engineering ExampleCustomer- cid- cname- mobile- email+ purchase( )+ login( )+ logout( )+ search( )class Customer{private int cid;private String cname;private String mobile;private String email;

public void purchase( ) { }public void login( ) { }public void logout( ) { }public void search( ) { }}Vishnu Institute of technology Website: www.vishnu.edu.inUML is a Language for DocumentingUML addresses the documentation of a system's architecture and all of its details.

UML provides a language for expressing requirements and for tests.

UML provides a language for modeling the activities of project planning and release management.Vishnu Institute of technology Website: www.vishnu.edu.inConceptual Model of UMLVishnu Institute of technology Website: www.vishnu.edu.inConceptual Model of UMLUML building blocks (syntax)Rules (semantics)Common mechanismsVishnu Institute of technology Website: www.vishnu.edu.inUML Building Blocks

Vishnu Institute of technology Website: www.vishnu.edu.inStructural Things

Vishnu Institute of technology Website: www.vishnu.edu.inBehavioral Things

Vishnu Institute of technology Website: www.vishnu.edu.inGrouping Things

Vishnu Institute of technology Website: www.vishnu.edu.inAnnotational Things

Vishnu Institute of technology Website: www.vishnu.edu.inRelationships in UML

DependencyAssociationGeneralizationRealizationVishnu Institute of technology Website: www.vishnu.edu.inDiagramsClass diagramObject diagramUse case diagramSequence diagramCollaboration diagramStatechart diagramActivity diagramComponent diagramDeployment diagramVishnu Institute of technology Website: www.vishnu.edu.inRules

Vishnu Institute of technology Website: www.vishnu.edu.inCommon MechanismsSpecificationsAdornmentsCommon divisionsExtensibility mechanismsStereotypesTagged valuesConstraints

Vishnu Institute of technology Website: www.vishnu.edu.inSoftware ArchitectureVishnu Institute of technology Website: www.vishnu.edu.inArchitecture

End user

Integrator

Programmers& software managers

System EngineerLogical ViewDevelopment ViewPhysical ViewDeveloped by Philippe KruchtenVishnu Institute of technology Website: www.vishnu.edu.inArchitecture Vs Design

Overall System (Architecture)Specific Subsystem (Design)Vishnu Institute of technology Website: www.vishnu.edu.inUnified ProcessVishnu Institute of technology Website: www.vishnu.edu.inSoftware Development Life Cycle

Rational Unified Process (RUP)Vishnu Institute of technology Website: www.vishnu.edu.inUnified ProcessThe Unified Software Development Process is an industry standard software engineering processIt is commonly referred to as the "Unified Process" or UPIt is the generic process for the UML It is free - described in "The Unified Software Development Process", ISBN:0201571692"UP is:Use case (requirements) drivenRisk drivenArchitecture centricIterative and incrementalUP is a generic software engineering process. It has to be customised (instantiated) for your projectIn house standards, document templates, tools, databases, lifecycle modifications, Rational Unified Process (RUP) is an instantiation of UPRUP is a product marketed and owned by Rational CorporationRUP also has to be instantiated for your projectVishnu Institute of technology Website: www.vishnu.edu.inRUP - InceptionInceptionElaborationConstructionTransitionRequirements establish business case and scope. Capture core requirementsAnalysis establish feasibilityDesign design proof of concept or technical prototypesImplementation build proof of concept or technical prototypeTest not generally applicableFocusGoalsEstablish feasibility of the project - create proof of concept/technical prototypesCreate a business caseScope the system - capture key requirementsIdentify critical risksVishnu Institute of technology Website: www.vishnu.edu.inRUP - ElaborationInceptionElaborationConstructionTransitionRequirements refine system scope and requirementsAnalysis establish what to buildDesign create a stable architectural baselineImplementation build the architectural baselineTest test the architectural baselineFocusGoalsCreate an executable architectural baselineRefine Risk Assessment and define quality attributes (defect rates etc.)Capture use cases to 80% of the functional requirementsCreate a detailed plan for the construction phaseFormulate a bid which includes resources, time, equipment, staff, costVishnu Institute of technology Website: www.vishnu.edu.inRUP - ConstructionInceptionElaborationConstructionTransitionRequirements uncover any requirements that had been missedAnalysis finish the analysis modelDesign finish the design modelImplementation build the Initial Operational CapabilityTest test the Initial Operational CapabilityFocusGoalsComplete use case identification, description and realizationFinish analysis, design, implementation and testMaintain the integrity of the system architectureRevise the Risk AssessmentVishnu Institute of technology Website: www.vishnu.edu.inRUP - TransitionCorrect defectsPrepare the user site for the new software and tailor the software to operate at the user siteModify software if unforeseen problems ariseCreate user manuals and other documentationProvide customer consultancyConduct post project reviewInceptionElaborationConstructionTransitionRequirements not applicableAnalysis not applicableDesign modify the design if problems emerge in beta testingImplementation tailor the software for the user site. Fix bugs uncovered in beta testingTest perform beta testing and acceptance testing at the user siteFocusGoalsVishnu Institute of technology Website: www.vishnu.edu.inHello World ExampleVishnu Institute of technology Website: www.vishnu.edu.inExample : Hello Worldimport java.awt.*;import java.applet.*;public class HelloWorld extends Applet{public void paint(Graphics g){g.drawString(Hello World, 10, 10);}}Vishnu Institute of technology Website: www.vishnu.edu.inExample : Hello World (cont)HelloWorldpaint( )g.drawString(Hello World, 10, 10)Vishnu Institute of technology Website: www.vishnu.edu.inExample : Hello World (cont)HelloWorldpaint( )AppletGraphicsVishnu Institute of technology Website: www.vishnu.edu.inExample : Hello World (cont)HelloWorldAppletPanelContainerComponentObjectVishnu Institute of technology Website: www.vishnu.edu.inExample : Hello World (cont)

Vishnu Institute of technology Website: www.vishnu.edu.inStructural ModelingVishnu Institute of technology Website: www.vishnu.edu.inStructural ModelingStructural models represents the structural elements composing a system or function.

These models reflect the static relationships of a structure.

Class diagrams, object diagrams, component diagrams and deployment diagrams.Vishnu Institute of technology Website: www.vishnu.edu.inClassesVishnu Institute of technology Website: www.vishnu.edu.inClassesA class is a collection of similar (attributes, operations, relationships) objects.

Classes are used to capture the vocabulary of the system.

Class is represented as a rectangle in UML.Vishnu Institute of technology Website: www.vishnu.edu.inClasses - Example

Vishnu Institute of technology Website: www.vishnu.edu.inClasses - NameA class name is a textual string.

Every class must have a name that distinguishes it from every other class.

A class name may contain any number of letters, numbers and punctuation marks except : which is used to separate a class from its package.

A class name always starts with a uppercase letter.Vishnu Institute of technology Website: www.vishnu.edu.inClasses Name (cont)

Simple namesPath nameVishnu Institute of technology Website: www.vishnu.edu.inClasses - AttributesAn attribute is a named property.

These attributes are similar for all the objects of the class.

Graphically the attributes are listed in a compartment below the class name.

The first letter in the attribute name will be in lowercase and the first letter of the rest of the words will be in uppercase.Vishnu Institute of technology Website: www.vishnu.edu.inClasses Attributes (cont)Attributes may be represented only with names or along with the type and an initial value.

Vishnu Institute of technology Website: www.vishnu.edu.inClasses - OperationsAn operation is an implementation of service that can be requested from any object of the class to affect its behavior.

These operations are similar for all the objects of the class.

Operations are listed in a compartment below the attributes compartment.Vishnu Institute of technology Website: www.vishnu.edu.inClasses Operations (cont)An operation may be represented only with its name or along with the parameters or with the return type.

Vishnu Institute of technology Website: www.vishnu.edu.inClasses - ResponsibilitiesA responsibility is the contract of a class that specifies that the objects of that class will have the same attributes and operations.

The attributes and operations are the features by which the classs responsibilities are carried out.

Graphically responsibilities can be modeled in a separate compartment at the bottom of the class icon.Vishnu Institute of technology Website: www.vishnu.edu.inClasses Responsibilities (cont)Responsibilities are represented just as plain text.

A well-structured class will have one or more responsibilities.

Responsibilities can be gathered by using techniques like CRC cards and use case analysis.Vishnu Institute of technology Website: www.vishnu.edu.inClasses Responsibilities (cont)

Vishnu Institute of technology Website: www.vishnu.edu.inCommon Modeling Techniques - Modeling the Vocabulary of a SystemTo model the vocabulary of a system:

Identify those things that users or implementers use to describe the problem or solution. Use CRC cards and use case-based analysis to help find these abstractions.

For each abstraction, identify a set of responsibilities. Make sure that each class is crisply defined and that there is a good balance of responsibilities among all your classes.

Provide the attributes and operations that are needed to carry out these responsibilities for each class.

Vishnu Institute of technology Website: www.vishnu.edu.inCommon Modeling Techniques - Modeling the Vocabulary of a System

Vishnu Institute of technology Website: www.vishnu.edu.inCommon Modeling Techniques - Modeling the Distribution of Responsibilities in a SystemTo model the distribution of responsibilities in a system:

Identify a set of classes that work together closely to carry out some behavior.

Identify a set of responsibilities for each of these classes.

Look at this set of classes as a whole, split classes that have too many responsibilities into smaller abstractions, collapse tiny classes that have trivial responsibilities into larger ones, and reallocate responsibilities so that each abstraction reasonably stands on its own.

Consider the ways in which those classes collaborate with one another, and redistribute their responsibilities accordingly so that no class within a collaboration does too much or too little.

Vishnu Institute of technology Website: www.vishnu.edu.inCommon Modeling Techniques - Modeling the Distribution of Responsibilities in a System

Vishnu Institute of technology Website: www.vishnu.edu.inCommon Modeling Techniques - Modeling Non-software ThingsTo model non-software things:

Model the thing you are abstracting as a class.

If you want to distinguish these things from the UML's defined building blocks, create a new building block by using stereotypes to specify these new semantics and to give a distinctive visual cue.

If the thing you are modeling is some kind of hardware that itself contains software, consider modeling it as a kind of node, as well, so that you can further expand on its structure.

Vishnu Institute of technology Website: www.vishnu.edu.inCommon Modeling Techniques - Modeling Non-software Things

Vishnu Institute of technology Website: www.vishnu.edu.inCommon Modeling Techniques - Modeling Primitive TypesTo model primitive types:

Model the thing you are abstracting as a type or an enumeration, which is rendered using class notation with the appropriate stereotype.

If you need to specify the range of values associated with this type, use constraints.Vishnu Institute of technology Website: www.vishnu.edu.inCommon Modeling Techniques - Modeling Primitive Types

Vishnu Institute of technology Website: www.vishnu.edu.inRelationshipsVishnu Institute of technology Website: www.vishnu.edu.inRelationshipsThe classes in the models generally collaborate with each other in a number of ways.

Most of the classes will have connections with other classes known as relationships.

Three main relationships:DependencyGeneralizationAssociationVishnu Institute of technology Website: www.vishnu.edu.inRelationships - Example

GeneralizationDependencyAssociationVishnu Institute of technology Website: www.vishnu.edu.inDependencyA dependency is a using relationship.

Dependency is represented graphically as a dashed directed line.

The dependency is directed towards the thing being used.Vishnu Institute of technology Website: www.vishnu.edu.inDependency Example

Vishnu Institute of technology Website: www.vishnu.edu.inGeneralizationGeneralization is often called as is-a relationship.

Generalization is a relationship between a general thing and a specific thing.

Generalization specifies that the object of a child can be used at any place where the object of the parent is used.Vishnu Institute of technology Website: www.vishnu.edu.inGeneralization (cont)Generalization is represented as a solid directed line with a large open arrow head pointing towards the general thing.

Vishnu Institute of technology Website: www.vishnu.edu.inAssociationAn association is a structural relationship. It specifies that objects of one thing are connected to objects of another thing.

An association can be specified on the same class or between two classes or between more classes.

An association is represented graphically as a solid line connecting two things.Vishnu Institute of technology Website: www.vishnu.edu.inAssociation - NameAn association can have a name. It specifies the type of relationship between the things it is connecting.

We can give a direction to the name by providing a direction triangle that point in the direction you intend to read the name

Vishnu Institute of technology Website: www.vishnu.edu.inAssociation - RoleA class plays a specific role in an association relationship.

The role is represented under the association and close to the class icon.

Vishnu Institute of technology Website: www.vishnu.edu.inAssociation - MultiplicityWhile modeling, it is important to specify how many objects may be connected across an association.

That how many is known as the multiplicity of the association.

Vishnu Institute of technology Website: www.vishnu.edu.inAssociation - AggregationWhile modeling, sometimes we might want to represent Whole/Part relationship. In this relationship, one thing acts as whole, while the other thing is a part of this whole thing.

Such relationship is known as aggregation or also called as has-a relationship.

An aggregation is represented graphically by adorning an association with a open diamond at the whole end.Vishnu Institute of technology Website: www.vishnu.edu.inAssociation Aggregation (cont)

Vishnu Institute of technology Website: www.vishnu.edu.inCommon Modeling Techniques - Modeling Simple DependenciesTo model this using relationship:

Create a dependency pointing from the class with the operation to the class used as a parameter in the operation.

Vishnu Institute of technology Website: www.vishnu.edu.inCommon Modeling Techniques - Modeling Single InheritanceTo model inheritance relationships:

Given a set of classes, look for responsibilities, attributes, and operations that are common to two or more classes.

Elevate these common responsibilities, attributes, and operations to a more general class. If necessary, create a new class to which you can assign these elements (but be careful about introducing too many levels).

Specify that the more-specific classes inherit from the more-general class by placing a generalization relationship that is drawn from each specialized class to its more-general parent.

Vishnu Institute of technology Website: www.vishnu.edu.inCommon Modeling Techniques - Modeling Single Inheritance

Vishnu Institute of technology Website: www.vishnu.edu.inCommon Modeling Techniques - Modeling Structural RelationshipsTo model structural relationships:

For each pair of classes, if you need to navigate from objects of one to objects of another, specify an association between the two. This is a data-driven view of associations.

For each pair of classes, if objects of one class need to interact with objects of the other class other than as parameters to an operation, specify an association between the two. This is more of a behavior-driven view of associations.

For each of these associations, specify a multiplicity (especially when the multiplicity is not *, which is the default), as well as role names (especially if it helps to explain the model).

If one of the classes in an association is structurally or organizationally a whole compared with the classes at the other end that look like parts, mark this as an aggregation by adorning the association at the end near the whole.Vishnu Institute of technology Website: www.vishnu.edu.inCommon Modeling Techniques - Modeling Structural Relationships

Vishnu Institute of technology Website: www.vishnu.edu.inCommon MechanismsVishnu Institute of technology Website: www.vishnu.edu.inCommon MechanismsThe extensibility features provided by UML to represent additional information over the basic UML notations are the common mechanisms.

The common mechanisms in UML are:NotesAdornmentsStereotypesTagged ValuesConstraintsVishnu Institute of technology Website: www.vishnu.edu.inNoteNote is an annotational thing in UML.

Note is used to specify: requirements, observations, reviews, explanations, constraints and other comments.

Note is graphically represented as a rectangle with a dog ear at the top right corner.Vishnu Institute of technology Website: www.vishnu.edu.inNote - ExampleServerProcessor: Intel Core i7RAM: 8GBHDD: 1PTBNodeNoteVishnu Institute of technology Website: www.vishnu.edu.inAdornmentsAdornments are textual or graphical elements that are added to the basic UML notations to specify extra information.

Example:Clientbill.exereport.execontacts.exeAnonymous compartment(Adornment)Vishnu Institute of technology Website: www.vishnu.edu.inExtensibility MechanismsTo represent additional information over the basic notations like class, use case, association etc, UML provides extensibility mechanisms.

Extensibility mechanisms in UML are:Stereotypes (extends the building blocks)Tagged Values (extends the properties)Constraints (extends the semantics)Vishnu Institute of technology Website: www.vishnu.edu.inStereotypesAs we know UML provides basic elements or building blocks. For example, consider a class. A classs basic notation is a rectangle with three compartments.

Sometimes while creating software blueprints, we might want to represent some elements visually which are not available in UML. For example, in a deployment diagram, I want to represent a router. UML does not provide a notation for a router.Vishnu Institute of technology Website: www.vishnu.edu.inStereotypes (cont)So, I must create a new visual representation (icon) for a router. How?

UML already provides a concept known as stereotype using which we can create new building blocks.

Using stereotypes we create new or extend the existing building blocks.

Stereotypes are represented using guillemets (>)Vishnu Institute of technology Website: www.vishnu.edu.inStereotypes - Examples

Movable

Underflow

Digicom AX00NamedstereotypeNamedstereotype with iconStereotyped element as iconVishnu Institute of technology Website: www.vishnu.edu.inTagged ValuesEvery UML element has its own properties. For example, a class has its own attributes and operations which apply to all its instances.

To represent i.e., extend the properties of an element UML provides tagged values.

Tagged values are represented as text enclosed in braces { }, and placed under the element name.Vishnu Institute of technology Website: www.vishnu.edu.inTagged Values - ExampleServer{processors = 3}Tagged value

trans.dll{serverOnly}Value of tagVishnu Institute of technology Website: www.vishnu.edu.inConstraintsConstraint is mechanism provided by UML to add a new rule or modify the existing rule (semantics) on an element.

Constraints are represented as text enclose in braces { } and placed beside the associated element.Vishnu Institute of technology Website: www.vishnu.edu.inConstraints - ExampleBank AccountPersonCorporationownerowner{xor}constraintVishnu Institute of technology Website: www.vishnu.edu.inConstraints - Example

Vishnu Institute of technology Website: www.vishnu.edu.inDiagramsVishnu Institute of technology Website: www.vishnu.edu.inDiagramsModeling (creating blueprints) is about creating a simplification or abstraction of the end software system.

Modeling involves creating different diagrams.

A diagram is a collection of vertices and edges according to graph theory (mathematics). In UML, these vertices are things and edges are replaced with relationships.Vishnu Institute of technology Website: www.vishnu.edu.inDiagrams (cont)DiagramsStructural DiagramsBehavioral DiagramsClass DiagramsObject DiagramsImplementation DiagramsComponent DiagramsDeployment DiagramsUse Case DiagramsState Chart DiagramsActivity DiagramsInteraction DiagramsSequence DiagramsCollaboration DiagramsVishnu Institute of technology Website: www.vishnu.edu.inDiagrams - OverviewDiagramElementsPurposeViewClass DiagramClass, Interface, Collaboration and RelationshipsTo model the structure/skeleton of the software systemStatic design viewStatic process view (active classes)Object DiagramObjects and RelationshipsTo model the structure of the software systemStatic design viewStatic process view (active classes)Component DiagramComponents and RelationshipsTo model the components in the software systemStatic Implementation viewDeployment DiagramNodes and RelationshipsTo model the runtime structure of the software systemStatic Deployment viewUse Case DiagramUse cases, actors and relationshipsTo model the behavior of the systemStatic use case viewSequence DiagramObjects and messagesTo model the time ordering of messagesDynamic viewCollaboration DiagramObjects and messagesTo model the structural organization of the objectsDynamic viewStatechart DiagramStates, transitions, events and activitiesTo model the behavior as a sequence of state changesDynamic viewActivity DiagramActivities, transitions and other control flow symbolsTo model the behavior as a set of activitiesDynamic viewVishnu Institute of technology Website: www.vishnu.edu.inAdvanced ClassesVishnu Institute of technology Website: www.vishnu.edu.inClassifiersAn modeling element that can have an instance is a classifier.

Examples: classes, usecases, nodes, components etc..

Vishnu Institute of technology Website: www.vishnu.edu.inClassifiers (cont)

Vishnu Institute of technology Website: www.vishnu.edu.inClassifiers - Examples

Vishnu Institute of technology Website: www.vishnu.edu.inClassifiers Examples (cont)ClassifierDescriptionClassA class is a blueprint or a template for its objectsInterfaceAn interface is a collection of operations that must be realized by another elementDatatypeA type whose values have no identitySignalAn asynchronous event communicated between objectsComponent Physical replaceable part of the systemNodeA physical existing at runtime which represents a computational resourceUse caseCollection of actions that a role performs on the system or the system does for a user.Sub systemA grouping of elements which specify the behavior of a part of the systemVishnu Institute of technology Website: www.vishnu.edu.inAdvanced ClassesWe know that the basic notation of a class in UML is a rectangle with three compartments.

UML also allows to specify more information over this basic notation such as:VisibilityScopeAbstract, root, leaf and polymorphic elementsMultiplicityAdvanced attributesAdvanced operationsVishnu Institute of technology Website: www.vishnu.edu.inVisibilityThe visibility feature of a classifier allows us to specify the accessibility of a certain classifier feature.

Four access specifiers in UML:SymbolNameDescription+PublicAccessible by all other classifiers#ProtectedAccessible only by the descendents and the classifier itself~PackageAccessible by all the classifiers with the same package-PrivateAccessible only by the classifier in which they are availableVishnu Institute of technology Website: www.vishnu.edu.inVisibility - ExampleStudent- sid- sname- rollno# email# mobno+ register( )+ login( )+ logout( )Vishnu Institute of technology Website: www.vishnu.edu.inScopeA feature that can be applied to a classifiers attributes and operations that specifies their existence in all of its instances or existence of only one copy.ScopeDescriptioninstanceEach instance of the classifier contains a value of the featureclassifierOne copy of the features value is shared by all the instances of a classifierVishnu Institute of technology Website: www.vishnu.edu.inScope - ExampleCse Student- sid- sname- rollno# email# mobno+ branch : String = CSE+ register( )+ login( )+ logout( )Classifier scopeVishnu Institute of technology Website: www.vishnu.edu.inAbstract, Root, Leaf and Polymorphic elementsAn abstract class can be represented in UML with the class name represented in italics.

A class without any parents is a root class. A root class can be represented as a class tagged with {root} property.

A class without child class(s) is a leaf class. A leaf class can be represented as a class tagged with {leaf} property.

Abstract methods or polymorphic methods are also represented in italics similar to abstract classes.Vishnu Institute of technology Website: www.vishnu.edu.inAbstract, Root, Leaf and Polymorphic elements - Example

Vishnu Institute of technology Website: www.vishnu.edu.inMultiplicityThe multiplicity feature of a class allows us to specify the number of instances a class can have.

The multiplicity can be applied to the class itself and to attributes also.

The multiplicity of a class is specified at the top right corner of the class symbol.

The multiplicity of an attribute is specified after the attribute name within square brackets.Vishnu Institute of technology Website: www.vishnu.edu.inMultiplicity - ExampleCarengine [1]wheel [4]door [4]hornmove()1Vishnu Institute of technology Website: www.vishnu.edu.inAttributesThe syntax of an attribute is as follows:[visibility] name [multiplicity] [: type] [=initial value] [{property string}]Some examples:originName only+ originName and visibilityorigin : PointName and typehead : *ItemName and complex typename [0..1] : StringName, multiplicity and typeorigin : Point = {0,0}Name, type and initial valueid : Integer {frozen}Name and propertyVishnu Institute of technology Website: www.vishnu.edu.inAttributes (cont)The three predefined properties that can be used with attributes in UML are:changeableNo restrictions on modifying the attributes valueaddOnlyFor attributes with multiplicity greater than one, values may be added but not removed or altered once it is createdfrozenOnce created the value of an attribute cannot be changedVishnu Institute of technology Website: www.vishnu.edu.inAttributes - ExampleStudent- sid {frozen}- sname- rollno {frozen}# email+ marks {addOnly}+ register( )+ login( )+ logout( )Vishnu Institute of technology Website: www.vishnu.edu.inOperationsThe syntax of an operation in UML is as follows:

[visibility] name [(parameters-list)] [: return-type] [{property-string}]Some examples:originName only+ originName and visibilityorigin : PointName and typehead : *ItemName and complex typename [0..1] : StringName, multiplicity and typeorigin : Point = {0,0}Name, type and initial valueid : Integer {frozen}Name and propertyVishnu Institute of technology Website: www.vishnu.edu.inOperations (cont)The syntax of a parameter in the parameters list as follows:[direction] name :type [=initial value]Direction may be any one of the following:inAn input parameter, may not be modifiedoutAn output parameter, may be modifiedinoutAn input parameter, may be modifiedVishnu Institute of technology Website: www.vishnu.edu.inOperations (cont)There are four predefined properties that can be applied to the operations in UML:isQueryExecution of the operation does not change the state of the system.sequentialDenotes that the operation is suitable for sequential access only.guardedIndicates that the operation guarantees integrity in case of concurrent access. Concurrent calls will be performed in a sequential manner.concurrentDenotes that the operation can be called concurrently and the integrity of the object will be preserved. Operation executes on the object concurrently.Vishnu Institute of technology Website: www.vishnu.edu.inAdvanced RelationshipsVishnu Institute of technology Website: www.vishnu.edu.inAdvanced RelationshipsWe can represent additional information over the basic representation of the relationships:DependencyGeneralizationAssociationVishnu Institute of technology Website: www.vishnu.edu.inDependencyDependency relationship is also known as the using relationship.

When one thing uses another thing, such relationship is represented using a dependency.

Basic representation of a dependency is as shown below:SourceTargetVishnu Institute of technology Website: www.vishnu.edu.inDependency (cont)Eight stereotypes that can be applied to dependency between classes are:bindSpecifies that the source instantiates (creates object) the target template using the given actual parametersderiveSpecifies that the source may be computed from the targetfriendSpecifies that the source is accessible by the target regardless of the visibility of the source elementinstanceOfSpecifies that the source object is an instance of the target classifierinstantiateSpecifies that the source creates instances of the targetpowertypeSpecifies that the target is a powertype of the source. A powertype is a classifier whose objects are the children of a given parent.refineSpecifies that the target is at a lower level of abstraction than the sourceuseSpecifies that the source element depends on the target for its functionality.Vishnu Institute of technology Website: www.vishnu.edu.inDependency (cont)Examples:

TListTDoubleListIntegerList

GradeclassEvaluatecalSum()calAvg()calGrade() : Grade

Vishnu Institute of technology Website: www.vishnu.edu.inDependency (cont)

Graphics- drawString()- drawOval()DrawObjectcreate()delete()

manoj : StudentStudent

HTML EditorHTML Page

Vishnu Institute of technology Website: www.vishnu.edu.inDependency (cont)

CarVehicle

Order

OrderdateOfOrderamountshippmentDaterecordShippment()

Order

OrderItemVishnu Institute of technology Website: www.vishnu.edu.inDependency (cont)Two stereotypes that can be applied to dependency between packages:Examples:accessSpecifies that the source package has the right to access the elements of the target packageimportSpecifies that the public elements of the target package enter the namespace of the source package as if they were declared in the source.UIGraphics

UIGraphics

Vishnu Institute of technology Website: www.vishnu.edu.inDependency (cont)Two stereotypes that apply to dependency between use cases:extendSpecifies that the target use case extends the functionality of the source use caseincludeSpecifies that the source use case incorporates the behavior of the target use case to function as a whole.Examples:LoginChange Password

Withdraw MoneyCard Validation

Vishnu Institute of technology Website: www.vishnu.edu.inDependency (cont)Three stereotypes that apply to dependency among objects:becomeSpecifies that the source object becomes the target object at some point in timecallSpecifies that an operation in source calls another operation of the targetcopySpecifies that the target is an exact, but independent copy of the sourceVishnu Institute of technology Website: www.vishnu.edu.inDependency (cont)Examples:e1 : Employeerole = employeee1 : Employeerole = manager

s1: Studentev : Evaluator

c1: Carc2 : Car

Vishnu Institute of technology Website: www.vishnu.edu.inDependency (cont)One stereotype that applies to dependency in the context of state machines:sendSpecifies that the source, an operation whose target is a signal, sends the target signalOne stereotype that applies to dependency in the context of subsystem:traceSpecifies that the source element has a conceptual connection to the target which individually belong to different modelsStudentS1 : Student

Vishnu Institute of technology Website: www.vishnu.edu.inGeneralizationUsed to represent parent-child or generalization- specialization relationships.

Also known as is-a relationship.

Basic representation of a generalization relationship is a solid line with hollow arrow head.Vishnu Institute of technology Website: www.vishnu.edu.inGeneralization (cont)One stereotype can be applied on generalization:implementationSpecifies that the child inherits the implementation of the parent but does not support its interfaces, there by violating the principle of substitutability.Vishnu Institute of technology Website: www.vishnu.edu.inGeneralization (cont)Four constraints can be applied on generalization relationship:completeSpecifies that no additional children are permittedincompleteSpecifies that additional children are permitteddisjointSpecifies that the objects of the parent may not have more than one of the children as a typeoverlappingSpecifies that the objects of the parent may have more than one of the children as a type.Vishnu Institute of technology Website: www.vishnu.edu.inAssociationA semantic relationship which specifies a connection between two things is the association.

Basic representation of an association is a solid line.

Over the basic notation, we can represent much more information like:NavigationVisibilityQualificationCompositionAssociation ClassVishnu Institute of technology Website: www.vishnu.edu.inAssociation - NavigationA directed association specifies the ability to navigate from one thing to another.

Navigability is represented as a stick arrow head.Vishnu Institute of technology Website: www.vishnu.edu.inAssociation - NavigationExampleOrderProductscontainsVishnu Institute of technology Website: www.vishnu.edu.inAssociation - VisibilityWe can specify the visibility of the things that participate in the association relationship.

With the access specifiers on roles we can limit the visibility of a thing from other things outside the association relationship.Vishnu Institute of technology Website: www.vishnu.edu.inAssociation - VisibilityExampleUserGroupUserPassword+user+owner-keyVishnu Institute of technology Website: www.vishnu.edu.inAssociation - QualificationThis feature of an association allows one thing in the association to identify a set of the instances of another thing. Such mechanism is known as qualification.

The attributes set which is used to identify a set of instances is known as a qualifier.

A qualifier is represented as text inside a rectangle which is attached to the corresponding instance.Vishnu Institute of technology Website: www.vishnu.edu.inAssociation - QualificationExampleBankPersonaccountNumber : intaccount holder11..*Vishnu Institute of technology Website: www.vishnu.edu.inAssociation Association ClassIn association relationship, sometimes, the association might have attributes or operations like a class. In such cases, we can model such behavior as an association class.

An association class is represented as a class symbol attached to the association with a dashed line.Vishnu Institute of technology Website: www.vishnu.edu.inAssociation Association ClassExamplePersonCompany1..**employeremployeeJobdescriptiondateHiredsalaryVishnu Institute of technology Website: www.vishnu.edu.inAssociation - CompositionIn association relationship, if one thing is a part of another thing, such relationships are known as aggregations.

In a whole-part relationship like aggregation if the life cycle of the part tightly depends on the life cycle of the whole, such relationships are known as compositions.

Compositions are represented as solid lines with solid diamond head.Vishnu Institute of technology Website: www.vishnu.edu.inAssociation - CompositionExampleDepartmentCollegepart ofVishnu Institute of technology Website: www.vishnu.edu.inAssociation (cont)Along with the features mentioned before there are six constraints which can be applied on the association:implicitSpecifies that the relationship is not physical, but rather conceptualorderedSpecifies that the objects at one end of the association are in a certain orderchangeableLinks between objects can be added, removedaddOnlyNew links may be added from an object on the opposite side of the associationfrozenAfter adding a link it might not be modified laterxorIndicates that among a set of associations, only one can be applied for each objectVishnu Institute of technology Website: www.vishnu.edu.inRealizationA semantic relationship in which one thing provides the specification and the other thing provides the implementation for that specification is the realization.

A realization is graphically represented as a dashed line with hollow arrow head which points the thing providing the specification.Vishnu Institute of technology Website: www.vishnu.edu.inRealization ExamplesHTMLParserParser

scan()parse()Htmlparser.dllParserValidateUserValidationVishnu Institute of technology Website: www.vishnu.edu.inCRC (Class-Responsibility-Collaborator) CardsIntroduced by Beck & Cunningham (1989)

Online Shopping SystemVishnu Institute of technology Website: www.vishnu.edu.inClass DiagramVishnu Institute of technology Website: www.vishnu.edu.inClass diagramClass diagram is used to model the static design view of the system.

A class diagram contains:ClassesInterfacesCollaborationsGeneralization, dependencies and associationsVishnu Institute of technology Website: www.vishnu.edu.inClass diagram Common UsesClass diagrams are commonly used for:Modeling the vocabulary of the systemModeling the collaborationsModeling the logical database schemaVishnu Institute of technology Website: www.vishnu.edu.inClass diagram - Example

Vishnu Institute of technology Website: www.vishnu.edu.inObject DiagramVishnu Institute of technology Website: www.vishnu.edu.inObject diagramAn object diagram allows us to model the instances of classes in a class diagram.

Object diagrams are used to model the static design view of the system.

An object diagram contains:ObjectsLinksVishnu Institute of technology Website: www.vishnu.edu.inObject diagram Example

Vishnu Institute of technology Website: www.vishnu.edu.inClass and Object Diagrams

Vishnu Institute of technology Website: www.vishnu.edu.inBehavioral ModelingVishnu Institute of technology Website: www.vishnu.edu.inBehavioral ModelingBehavioral modeling involves modeling the dynamic aspects of the software system.

The dynamic aspects comprises of the behavior represented as:MessagesStatesActivities and moreVishnu Institute of technology Website: www.vishnu.edu.inUse Case DiagramVishnu Institute of technology Website: www.vishnu.edu.inUse CasesUse cases specify what the system does for its users.

A use case specifies part of the functionality provided by the system.

Use case concept was introduced by Ivar JacobsonVishnu Institute of technology Website: www.vishnu.edu.inUse Cases (cont)An use case is defined as a set of actions performed by the system, which produces an observable result that is, typically, of some value to one or more actors or other stakeholders of the system.

Use cases are connected to actors through associations.Vishnu Institute of technology Website: www.vishnu.edu.inUse Cases (cont)Use case is one of the classifiers in UML.

An instance of use case is known as a scenario.

Use case is graphically represented as a hollow ellipse.Vishnu Institute of technology Website: www.vishnu.edu.inUse Cases ExampleOrder productValidate userLibrary :: Make ReservationSimple NamesPath NameVishnu Institute of technology Website: www.vishnu.edu.inDescribing Use CasesUse case description includes:Objective of the use caseHow the use case is initiatedFlow of messages between actors and the use caseAlternate flow in the use caseHow the use case finishes and its value to the actorVishnu Institute of technology Website: www.vishnu.edu.inActorsAn actor is one which uses or interacts with the software system (subject).

Actor can be a person or another system (logical or physical).

Use case is always initiated by an actor by sending a message. This message is know as the stimulus.Vishnu Institute of technology Website: www.vishnu.edu.inActors (cont)Actors are of two types:Active actorsPassive actors

Actor is graphically represented as a stickman or as a class symbol stereotyped as actor.

Vishnu Institute of technology Website: www.vishnu.edu.inOrganizing Use CasesWe can use packages to group related use cases.

We can use generalization relationship between general and specific use cases.

We can separate common behavior using include dependencies and separate optional behavior using extend dependencies.Vishnu Institute of technology Website: www.vishnu.edu.inOrganizing Use Cases - Packages

College Information SystemVishnu Institute of technology Website: www.vishnu.edu.inOrganizing Use Cases - Packages

Use cases in the library packageVishnu Institute of technology Website: www.vishnu.edu.inOrganizing Use Cases - Generalization

Vishnu Institute of technology Website: www.vishnu.edu.inOrganizing Use Cases (cont)

Vishnu Institute of technology Website: www.vishnu.edu.inUse Case DiagramsUse case diagrams model the static use case view of a software system.

Specifies what the system does.

Use case diagram contains:Use casesActorsAssociations, dependencies and generalizationsVishnu Institute of technology Website: www.vishnu.edu.inUse Case Diagram Example

Vishnu Institute of technology Website: www.vishnu.edu.inUse Case Diagram Example

Vishnu Institute of technology Website: www.vishnu.edu.inInteraction DiagramsVishnu Institute of technology Website: www.vishnu.edu.inInteractionsInteraction is a collection of messages that are exchanged between objects.

A message can be an invocation or operation or a signal.

Using interaction diagrams we can model the flow of control in two ways:By focusing on the time ordering of messages.By focusing on the structural organization of the objects.Vishnu Institute of technology Website: www.vishnu.edu.inInteractions - Exampleu : Userv : ValidatorsendDetails(u,p)objectobjectLinkmessageVishnu Institute of technology Website: www.vishnu.edu.inInteractions (cont)A link is a semantic connection between the objects.

A link is an instance of an association.

Following stereotypes can be applied on links:associationSpecifies that the corresponding object is visible by associationSelfSpecifies that the corresponding object is visible as it is the dispatcher of the operationGlobalSpecifies that the corresponding object is visible as it is in an enclosing scopeLocalSpecifies that the corresponding object is visible as it is in local scopeparameterSpecifies that the corresponding object is visible as it is a parameterVishnu Institute of technology Website: www.vishnu.edu.inInteractions - ExamplePerson+setSalary(s : String)+assign(d : Department)Companyemployeeemployer1..*1p : Person: Companyassign(development)Vishnu Institute of technology Website: www.vishnu.edu.inInteractions (cont)A message is the specification of communication among objects that conveys information with the expectation that activity will succeed.

An action takes place when a message is sent.

UML allows us to model following actions:CallInvokes an operation on an objectReturnReturns a value to the callerSendSends a signal to the objectCreateCreates an objectDestroyDestroys an objectVishnu Institute of technology Website: www.vishnu.edu.inInteractions - Example

Vishnu Institute of technology Website: www.vishnu.edu.inInteractions SequencingIn case of nested messages or to explicitly specify the order of the messages we can use sequence numbers.

Prefix the message name with a sequence number followed by a colon ( : ).Vishnu Institute of technology Website: www.vishnu.edu.inInteractions Sequencing (cont)There are two types of control flows:Procedural flow of controlFlat flow of control

Procedural flow of control is represented as a solid line with solid arrow head.

Flat flow of control is represented as a solid line with stick arrow head.Vishnu Institute of technology Website: www.vishnu.edu.inInteractions Sequencing (cont): Viewc : Controller: Cache2 : clickAt(p)2.1 : I = findAt(p)2.2 : putRecentPick(I)c : Caller: Telephone: Exchange1 : liftHandset()2 : assertCall()Vishnu Institute of technology Website: www.vishnu.edu.inInteraction diagramsInteraction diagrams are used to model the interactions among objects.

There are two types of interaction diagrams:Sequence diagramsCollaboration diagramsVishnu Institute of technology Website: www.vishnu.edu.inSequence DiagramsA sequence diagram focuses on the time ordering of messages.

Objects are arranged at the top along the x-axis.

Messages are arranged from top to bottom along the y-axis.Vishnu Institute of technology Website: www.vishnu.edu.inSequence Diagrams (cont)Two distinctive features of a sequence diagram:Object life lineFocus of control

Vishnu Institute of technology Website: www.vishnu.edu.inSequence Diagrams (cont)

Vishnu Institute of technology Website: www.vishnu.edu.inCollaboration DiagramsA collaboration diagram focuses on the structural organization of the objects in an interaction.

First the objects are plotted and then the objects are connected through links.

Then, the messages are represented.Vishnu Institute of technology Website: www.vishnu.edu.inCollaboration Diagrams (cont)To denote the order of messages we can use sequence numbers.

Two distinctive features of a collaboration diagram:PathsSequence numberVishnu Institute of technology Website: www.vishnu.edu.inCollaboration Diagrams (cont)

Vishnu Institute of technology Website: www.vishnu.edu.inActivity DiagramsVishnu Institute of technology Website: www.vishnu.edu.inActivity DiagramsActivity diagram is used to model the behavior of a system in terms of flow of control between activities.

Activity diagram contains:Action and activity statesTransitionsObjectsVishnu Institute of technology Website: www.vishnu.edu.inActivity Diagrams (cont)Action is an atomic computation.

Activity is a non-atomic computation.

Both action and activity states are represented as a rounded rectangle or the lozenge symbol.Enter User Detailsresult := getAvg() + 20;Simple actionexpressionVishnu Institute of technology Website: www.vishnu.edu.inActivity Diagrams (cont)An activity state can have additional details like entry and exit actions.Make Payment

entry / Select ProductVishnu Institute of technology Website: www.vishnu.edu.inActivity Diagrams - TransitionsA transition is a path from one action or activity state to another which represents the flow of control.Make Payment

Select ProductStart stateStop stateVishnu Institute of technology Website: www.vishnu.edu.inActivity Diagrams - BranchingWe can represent alternate flows of control using the decision symbol which is graphically represented as a diamond.

A decision symbol can have one incoming transition and two or more outgoing transition.

The flow of control branches based on a boolean expression which is known as a guard condition.

A guard condition is represented in square brackets.Vishnu Institute of technology Website: www.vishnu.edu.inActivity Diagrams - Branching

Vishnu Institute of technology Website: www.vishnu.edu.inActivity Diagrams Fork and JoinSometimes, we might want to represent parallel or concurrent flow of control.

To represent the transformation of sequential flow of control into concurrent flow, we use a fork.

To represent the transformation of concurrent flow of control into sequential flow, we use a join.

Vishnu Institute of technology Website: www.vishnu.edu.inActivity Diagrams Fork and JoinTo represent a fork and join we use horizontal or vertical synchronization bars.

At a fork, the flow of control above the synchronization bar is sequential and below the bar, the flow is concurrent.

At a join, the flow of control above the synchronization bar is concurrent and below the bar, the flow is sequential.Vishnu Institute of technology Website: www.vishnu.edu.inActivity Diagrams Fork and Join

ForkJoinVishnu Institute of technology Website: www.vishnu.edu.inActivity Diagrams SwimlanesWhen a activity diagrams become more and more complex and you want to visually distinguish the activities that belong to a certain object, you can use a swimlane.

A swimlane is a semantic group or collection of all the activities that belong to a particular object.Vishnu Institute of technology Website: www.vishnu.edu.inActivity Diagrams SwimlanesA swimlane is visually represented as a vertical box.

Transition can move across from one swimlane to another but never does a activity or action state crosses from one swimlane to another.Vishnu Institute of technology Website: www.vishnu.edu.inActivity Diagrams Swimlanes

Vishnu Institute of technology Website: www.vishnu.edu.inEvents and SignalsVishnu Institute of technology Website: www.vishnu.edu.inEvents and SignalsIn UML, we can model the behavior either through interactions or as a sequence of state changes in a object.

An event is a stimulus which causes an object to move from one state to another.

An event can be any one of the following:SignalCallPassage of timeChange in stateVishnu Institute of technology Website: www.vishnu.edu.inEvents and Signals (cont)An event can be visually represented as text or using a stereotyped class symbol.

Vishnu Institute of technology Website: www.vishnu.edu.inEvents and Signals (cont)There are two types of events:Internal eventsExternal events

External events are the events passed between the system and a user.

Internal events are the events passed within the system.Vishnu Institute of technology Website: www.vishnu.edu.inEvents and Signals (cont)A signal is a named object that is sent asynchronously by one object and then received by another.

Exceptions are the famous examples for signals.

In UML, we can model the signals that an operation can send as a dependency stereotyped with signal.Vishnu Institute of technology Website: www.vishnu.edu.inEvents and Signals (cont)

Vishnu Institute of technology Website: www.vishnu.edu.inEvents and Signals (cont)A call event represents the dispatch of an operation from one object to another.

A call event, in general, is synchronous.

Vishnu Institute of technology Website: www.vishnu.edu.inEvents and Signals (cont)A time event represents the passage of time.

In UML, we model the time event using the after keyword followed by an expression that evaluates a period of time.

A change event represents an event that represents a change in state or the satisfaction of some condition.

In UML, change event is modeled using the keyword when followed by some Boolean expression.Vishnu Institute of technology Website: www.vishnu.edu.inEvents and Signals (cont)

Vishnu Institute of technology Website: www.vishnu.edu.inState MachineVishnu Institute of technology Website: www.vishnu.edu.inState MachinesA state machine is a behavior that represents the sequences of states that an object undergoes during its lifetime in response to events, together with its responses to those events.

The state of an object is a condition or situation during the life of an object during which it satisfies some condition, performs some activity or waits for some event.Vishnu Institute of technology Website: www.vishnu.edu.inState Machines (cont)

Vishnu Institute of technology Website: www.vishnu.edu.inState Machines (cont)A state is graphically represented as a rectangle with rounded corners.

A state can be divided into five parts:NameA textual string which distinguishes one state from other statesEntry/exit actionsActions executed on entering and exiting the stateInternal transitionsTransitions that are handled without causing a change in stateSubstatesThe nested structure of a state, involving disjoint or concurrent substatesDeferred eventsA list of events that are not handled in that state, but are postponed or queued for handling by the object in another stateVishnu Institute of technology Website: www.vishnu.edu.inState Machines (cont)

Vishnu Institute of technology Website: www.vishnu.edu.inState Machines (cont)A transition is a relationship between two states indicating that an object in one state will perform certain actions and enter another state when a specified event occurs and specified conditions are satisfied.

A transition has five parts:Source stateThe state affected by the transitionEvent triggerThe event whose reception changes the state of the objectGuard conditionA boolean expression which is evaluated when the transition is triggeredActionAn executable atomic computation that is performed on or by an objectTarget stateThe state that is active after the completion of the transitionVishnu Institute of technology Website: www.vishnu.edu.inState Machines (cont)A transition is visually represented as a solid directed line from source state to target state.

Vishnu Institute of technology Website: www.vishnu.edu.inState Machines (cont)UML allows us to represent more advanced information in a state like:Entry and exit actionsInternal transitionsActivitiesDeferred events

Advanced StatesVishnu Institute of technology Website: www.vishnu.edu.inState Machines Substates A substate is a state included in another state.

In UML, we render a composite state just like a normal state, but with an optional graphic compartment that shows a nested state machine.

Substates may be nested to any level.Vishnu Institute of technology Website: www.vishnu.edu.inState Machines Substates (cont)

Vishnu Institute of technology Website: www.vishnu.edu.inState Machines Substates (cont)There are situations in which we might want the state machine to remember the last substate that was active prior to leaving the composite state.

A history state allows a composite state that contains sequential substates to remember the last substate that was active in it prior to the transition from the composite state.

In UML, a history is represented as a hollow circle with the symbol HVishnu Institute of technology Website: www.vishnu.edu.inState Machines Substates (cont)

Vishnu Institute of technology Website: www.vishnu.edu.inState Machines Substates (cont)Concurrent substates allow us to specify two or more state machines that execute in parallel in the context of the enclosing object.

Each concurrent substate is divided from each other with a dashed line.Vishnu Institute of technology Website: www.vishnu.edu.inState Machines Substates (cont)

Vishnu Institute of technology Website: www.vishnu.edu.inState Chart DiagramsA state chart diagram models the flow of control from one state to another state of an object.

A state chart diagram contains:StatesTransitionsVishnu Institute of technology Website: www.vishnu.edu.inState Chart Diagrams (cont)

State machine for an ATMVishnu Institute of technology Website: www.vishnu.edu.inArchitectural ModelingVishnu Institute of technology Website: www.vishnu.edu.inComponentsVishnu Institute of technology Website: www.vishnu.edu.inComponentsA component is a physical replaceable part of a system.

Examples of components include:Source code filesExecutablesLibrariesTablesFilesDocumentsVishnu Institute of technology Website: www.vishnu.edu.inComponents (cont)Some more examples:ActiveX ControlJava BeanWeb PageWeb ServerFirewallStyle SheetDatabase etcVishnu Institute of technology Website: www.vishnu.edu.inComponents (cont)Components are the physical elements that contain the logical elements like classes, interfaces etc

A component is graphically represented as tabbed rectangle.Vishnu Institute of technology Website: www.vishnu.edu.inComponents (cont)

Vishnu Institute of technology Website: www.vishnu.edu.inComponents (cont)Components Vs Classes:Components are physical things, whereas, classes are logical abstractions.

Components are at a higher level of abstraction than a class.

Components only contain operations, whereas, a class can have both attributes and operations.Vishnu Institute of technology Website: www.vishnu.edu.inComponents (cont)The relationship between a component and its classes can be represented using dependencies.

Vishnu Institute of technology Website: www.vishnu.edu.inComponents (cont)An interface contains a set of operations which specify a service to a class or a component.

The relationship between a component and an interface can be shown in two ways:Canonical formIconic formVishnu Institute of technology Website: www.vishnu.edu.inComponents (cont)There are three kinds of components:Deployment components (Dlls, Exes)Work product components (Source code files)Execution components (COM+ objects)Vishnu Institute of technology Website: www.vishnu.edu.inComponents (cont)UML defines five stereotypes that can be applied to components:executableSpecifies a component that may be executed on a nodelibrarySpecifies a static or dynamic object librarytableSpecifies a component that represents a database tablefileSpecifies a component that represents a document containing code or datadocumentSpecifies a component that represents a documentVishnu Institute of technology Website: www.vishnu.edu.inComponents (cont)

Vishnu Institute of technology Website: www.vishnu.edu.inComponent DiagramComponent diagram is used to model the static implementation view of a system.

A component diagram contains:ComponentsInterfacesDependency, generalization, association and realization relationshipsVishnu Institute of technology Website: www.vishnu.edu.inComponent Diagram - Example

Vishnu Institute of technology Website: www.vishnu.edu.inDeploymentVishnu Institute of technology Website: www.vishnu.edu.inDeploymentA node is a physical component that exists at runtime.

A node generally comprises of some kind of memory and often processing capabilities.

Examples of nodes can be:PCLaptopRouterOther embedded systemsVishnu Institute of technology Website: www.vishnu.edu.inDeployment (cont)Using nodes we can model the architecture of our software system.

A node in UML is graphically represented as a cube.

Vishnu Institute of technology Website: www.vishnu.edu.inDeployment (cont)Nodes and Components:Both have namesBoth may participate in dependency, generalization and association relationships.Both may be nestedBoth may have instancesBoth may participate in interactionsVishnu Institute of technology Website: www.vishnu.edu.inDeployment (cont)Nodes Vs Components:Components participate in the execution of a software system, whereas, nodes execute components.

Component is a physical package of logical elements like classes, whereas, node physically deploys components.Vishnu Institute of technology Website: www.vishnu.edu.inDeployment (cont)

Vishnu Institute of technology Website: www.vishnu.edu.inDeployment (cont)

Vishnu Institute of technology Website: www.vishnu.edu.inDeployment DiagramsA deployment diagram is used to model the static deployment view of software system.

A deployment diagram contains:NodesDependency and association relationshipsVishnu Institute of technology Website: www.vishnu.edu.inDeployment Diagrams (cont)Common uses:To model embedded systemsTo model client/server systemsTo model fully distributed systemsVishnu Institute of technology Website: www.vishnu.edu.inDeployment Diagrams (cont)

Vishnu Institute of technology Website: www.vishnu.edu.inDeployment Diagrams (cont)

Vishnu Institute of technology Website: www.vishnu.edu.inForward EngineeringVishnu Institute of technology Website: www.vishnu.edu.inCASE STUDYVending MachineVishnu Institute of technology Website: www.vishnu.edu.inVending Machine

Vishnu Institute of technology Website: www.vishnu.edu.in