OOAD
OOAD
com
UML Overview
UML is a standard language for specifying, visualizing, constructing, and documenting the artifacts of software
systems.
UML was created by Object Management Group (OMG) and UML 1.0 specification draft was proposed to the OMG
in January 1997.
So UML can be described as a general purpose visual modeling language to visualize, specify, construct and
document software system. Although UML is generally used to model software systems but it is not limited
within this boundary. It is also used to model non software systems as well like process flow in a manufacturing
unit etc.
UML is not a programming language but tools can be used to generate code in various languages using UML
diagrams. UML has a direct relation with object oriented analysis and design. After some standardization UML is
become an OMG (Object Management Group) standard.
Goals of UML:
A picture is worth a thousand words, this absolutely fits while discussing about UML. Object oriented concepts
were introduced much earlier than UML. So at that time there were no standard methodologies to organize and
consolidate the object oriented development. At that point of time UML came into picture.
There are a number of goals for developing UML but the most important is to define some general purpose
modeling language which all modelers can use and also it needs to be made simple to understand and use.
UML diagrams are not only made for developers but also for business users, common people and anybody
interested to understand the system. The system can be a software or non software. So it must be clear that
UML is not a development method rather it accompanies with processes to make a successful system.
At the conclusion the goal of UML can be defined as a simple modeling mechanism to model all possible practical
systems in today.s complex environment.
A conceptual model can be defined as a model which is made of concepts and their relationships.
A conceptual model is the first step before drawing a UML diagram. It helps to understand the entities in
the real world and how they interact with each other.
As UML describes the real time systems it is very important to make a conceptual model and then proceed
gradually. Conceptual model of UML can be mastered by learning the following three major elements:
An object contains both data and methods that control the data. The data represents the state of the object. A
class describes an object and they also form hierarchy to model real world system. The hierarchy is represented
as inheritance and the classes can also be associated in different manners as per the requirement.
The objects are the real world entities that exist around us and the basic concepts like abstraction,
encapsulation, inheritance, polymorphism all can be represented using UML.
So UML is powerful enough to represent all the concepts exists in object oriented analysis and design. UML
diagrams are representation of object oriented concepts only. So before learning UML, it becomes important to
understand OO concepts in details.
So it is important to understand the OO analysis and design concepts. Now the most important purpose of OO
analysis is to identify objects of a system to be designed. This analysis is also done for an existing system. Now
an efficient analysis is only possible when we are able to start thinking in a way where objects can be identified.
After identifying the objects their relationships are identified and finally the design is produced.
There are three basic steps where the OO concepts are applied and implemented. The steps can be defined as
During object oriented analysis the most important purpose is to identify objects and describing them in a
proper way. If these objects are identified efficiently then the next job of design is easy. The objects
should be identified with responsibilities. Responsibilities are the functions performed by the object. Each
and every object has some type of responsibilities to be performed. When these responsibilities are
collaborated the purpose of the system is fulfilled.
The second phase is object oriented design. During this phase emphasis is given upon the requirements
and their fulfilment. In this stage the objects are collaborated according to their intended association.
After the association is complete the design is also complete.
The third phase is object oriented implementation. In this phase the design is implemented using object
oriented languages like Java, C++ etc.
If we look into class diagram, object diagram, collaboration diagram, interaction diagrams all would basically be
designed based on the objects.
So the relation between OO design and UML is very important to understand. The OO design is transformed into
UML diagrams according to the requirement. Before understanding the UML in details the OO concepts should be
learned properly. Once the OO analysis and design is done the next step is very easy. The input from the OO
analysis and design is the input to the UML diagrams.
As UML describes the real time systems it is very important to make a conceptual model and then proceed
gradually. Conceptual model of UML can be mastered by learning the following three major elements:
This chapter describes all the UML building blocks. The building blocks of UML can be defined as:
Things
Relationships
Diagrams
(1) Things:
Things are the most important building blocks of UML. Things can be:
Structural
Behavioral
Grouping
Annotational
Structural things:
The Structural things define the static part of the model. They represent physical and conceptual elements.
Following are the brief descriptions of the structural things.
Class:
Interface:
Use case:
Use case represents a set of actions performed by a system for a specific goal.
Component:
Node:
Behavioral things:
A behavioral thing consists of the dynamic parts of UML models. Following are the behavioral things:
Interaction:
Interaction is defined as a behavior that consists of a group of messages exchanged among elements to
accomplish a specific task.
State machine:
State machine is useful when the state of an object in its life cycle is important. It defines the sequence of states
an object goes through in response to events. Events are external factors responsible for state change.
Grouping things:
Grouping things can be defined as a mechanism to group elements of a UML model together. There is only one
grouping thing available:
Package:
Package is the only one grouping thing available for gathering structural and behavioral things.
Annotational things:
Annotational things can be defined as a mechanism to capture remarks, descriptions, and comments of UML
model elements. Note is the only one Annotational thing available.
Note:
(2) Relationship :
Relationship is another most important building block of UML. It shows how elements are associated with each
other and this association describes the functionality of an application.
Dependency:
Dependency is a relationship between two things in which change in one element also affects the other one.
Association:
Association is basically a set of links that connects elements of an UML model. It also describes how many
objects are taking part in that relationship.
Generalization:
Generalization can be defined as a relationship which connects a specialized element with a generalized element.
It basically describes inheritance relationship in the world of objects.
Realization:
Realization can be defined as a relationship in which two elements are connected. One element describes some
responsibility which is not implemented and the other one implements them. This relationship exists in case of
interfaces.
The visual effect of the UML diagram is the most important part of the entire process. All the other elements are
used to make it a complete one.
UML includes the following nine diagrams and the details are described in the following chapters.
1. Class diagram
2. Object diagram
3. Use case diagram
4. Sequence diagram
5. Collaboration diagram
6. Activity diagram
7. Statechart diagram
8. Deployment diagram
9. Component diagram
Copyright © tutorialspoint.com
UML Architecture
Any real world system is used by different users. The users can be developers, testers, business people, analysts
and many more. So before designing a system the architecture is made with different perspectives in mind. The
most important part is to visualize the system from different viewer.s perspective. The better we understand the
better we make the system.
UML plays an important role in defining different perspectives of a system. These perspectives are:
Design
Implementation
Process
Deployment
And the centre is the Use Case view which connects all these four. A Use case represents the functionality of
the system. So the other perspectives are connected with use case.
Design of a system consists of classes, interfaces and collaboration. UML provides class diagram, object
diagram to support this.
Implementation defines the components assembled together to make a complete physical system. UML
component diagram is used to support implementation perspective.
Process defines the flow of the system. So the same elements as used in Design are also used to
support this perspective.
Deployment represents the physical nodes of the system that forms the hardware. UML UML
Modeling Types
It is very important to distinguish between the UML model. Different diagrams are used for different type of UML
modeling. There are three important type of UML modelings:
Structural modeling:
Structural modeling captures the static features of a system. They consist of the followings:
Classes diagrams
Objects diagrams
Deployment diagrams
Package diagrams
Composite structure diagram
Component diagram
Structural model represents the framework for the system and this framework is the place where all other
components exist. So the class diagram, component diagram and deployment diagrams are the part of structural
modeling. They all represent the elements and the mechanism to assemble them.
But the structural model never describes the dynamic behavior of the system. Class diagram is the most widely
used structural diagram.
Behavioral Modeling:
Behavioral model describes the interaction in the system. It represents the interaction among the structural
diagrams. Behavioral modeling shows the dynamic nature of the system. They consist of the following:
Activity diagrams
Interaction diagrams
Use case diagrams
Architectural Modeling:
Architectural model represents the overall framework of the system. It contains both structural and behavioral
elements of the system. Architectural model can be defined as the blue print of the entire system. Package
diagram comes under architectural modeling.
UML notations are the most important elements in modeling. Efficient and appropriate use of notations is very
important for making a complete and meaningful model. The model is useless unless its purpose is depicted
properly.
So learning notations should be emphasized from the very beginning. Different notations are available for things
and relationships. And the UML diagrams are made using the notations of things and relationships. Extensibility
is another important feature which makes UML more powerful and flexible.
The chapter describes the UML Basic Notations in more details. This is just an extension to the UML buildling
block section I have discussed in previous chapter.
Structural Things:
Graphical notations used in structural things are the most widely used in UML. These are considered as the
nouns of UML models. Following are the list of structural things.
Classes
Interface
Collaboration
Use case
Active classes
Components
Nodes
Class Notation:
UML class is represented by the diagram shown below. The diagram is divided into four parts.
Classes are used to represent objects. Objects can be anything having properties and responsibility.
Object Notation:
The object is represented in the same way as the class. The only difference is the name which is underlined as
shown below.
As object is the actual implementation of a class which is known as the instance of a class. So it has the same
usage as the class.
Interface Notation:
Interface is represented by a circle as shown below. It has a name which is generally written below the circle.
Interface is used to describe functionality without implementation. Interface is the just like a template where you
define different functions not the implementation. When a class implements the interface it also implements the
functionality as per the requirement.
Collaboration Notation:
Collaboration is represented by a dotted eclipse as shown below. It has a name written inside the eclipse.
Collaboration represents responsibilities. Generally responsibilities are in a group.
Use case is represented as an eclipse with a name inside it. It may contain additional responsibilities.
Actor Notation:
An actor can be defined as some internal or external entity that interacts with the system.
Actor is used in a use case diagram to describe the internal or external entities.
Initial state is defined show the start of a process. This notation is used in almost all diagrams.
The usage of Initial State Notation is to show the starting point of a process.
Final state is used to show the end of a process. This notation is also used in almost all diagrams to describe the
end.
The usage of Final State Notation is to show the termination point of a process.
Active class looks similar to a class with a solid border. Active class is generally used to describe concurrent
behaviour of a system.
Component Notation:
A component in UML is shown as below with a name inside. Additional elements can be added wherever
required.
Component is used to represent any part of a system for which UML diagrams are made.
Node Notation:
A node in UML is represented by a square box as shown below with a name. A node represents a physical
component of the system.
Node is used to represent physical part of a system like server, network etc.
Behavioural Things:
Dynamic parts are one of the most important elements in UML. UML has a set of powerful features to represent
the dynamic part of software and non software systems. These features include interactions and state machines.
Interaction Notation:
Interaction is basically message exchange between two UML components. The following diagram represents
different notations used in an interaction.
State machine describes the different states of a component in its life cycle. The notations are described in the
following diagram.
State machine is used to describe different states of a system component. The state can be active, idle or any
other depending upon the situation.
Grouping Things:
Organizing the UML models are one of the most important aspects of the design. In UML there is only one
element available for grouping and that is package.
Package Notation:
Package notation is shown below and this is used to wrap the components of a system.
Annotational Things:
In any diagram explanation of different elements and their functionalities are very important. So UML has notes
notation to support this requirement.
Note Notation:
This notation is shown below and they are used to provide necessary information of a system.
Relationships
A model is not complete unless the relationships between elements are described properly. The Relationship
gives a proper meaning to an UML model. Following are the different types of relationships available in UML.
Dependency
Association
Generalization
Extensibility
Dependency Notation:
Dependency is an important aspect in UML elements. It describes the dependent elements and the direction of
dependency.
Dependency is represented by a dotted arrow as shown below. The arrow head represents the independent
element and the other end the dependent element.
Association Notation:
Association describes how the elements in an UML diagram are associated. In simple word it describes how many
elements are taking part in an interaction.
Association is represented by a dotted line with (without) arrows on both sides. The two ends represent two
associated elements as shown below. The multiplicity is also mentioned at the ends (1, * etc) to show how many
objects are associated.
Association is used to represent the relationship between two elements of a system.
Generalization Notation:
Generalization describes the inheritance relationship of the object oriented world. It is parent and child
relationship.
Generalization is represented by an arrow with hollow arrow head as shown below. One end represents the
parent element and the other end child element.
Extensibility Notation:
All the languages (programming or modeling) have some mechanism to extend its capabilities like syntax,
semantics etc. UML is also having the following mechanisms to provide extensibility features.
Extensibility notations are used to enhance the power of the language. It is basically additional
elements used to represent some extra behaviour of the system. These extra behaviours are not
coverUML Standard Diagrams
In the previous chapters we have discussed about the building blocks and other necessary elements of UML. Now
we need to understand where to use those elements.
The elements are like components which can be associated in different ways to make a complete UML pictures
which is known as diagram. So it is very important to understand the different diagrams to implement the
knowledge in real life systems.
Any complex system is best understood by making some kind of diagrams or pictures. These diagrams have a
better impact on our understanding. So if we look around then we will realize that the diagrams are not a new
concept but it is used widely in different form in different industries.
We prepare UML diagrams to understand a system in better and simple way. A single diagram is not enough to
cover all aspects of the system. So UML defines various kinds of diagrams to cover most of the aspects of a
system.
You can also create your own set of diagrams to meet your requirements. Diagrams are generally made in an
incremental and iterative way.
There are two broad caetgories of diagrams and then are again divided into sub-categories:
Structural Diagrams
Behavioral Diagrams
Structural Diagrams:
The structural diagrams represent the static aspect of the system. These static aspects represent those parts of
a diagram which forms the main structure and therefore stable.
These static parts are represents by classes, interfaces, objects, components and nodes. The four structural
diagrams are:
Class diagram
Object diagram
Component diagram
Deployment diagram
Class Diagram:
Class diagrams are the most common diagrams used in UML. Class diagram consists of classes, interfaces,
associations and collaboration.
Class diagrams basically represent the object oriented view of a system which is static in nature.
Active class is used in a class diagram to represent the concurrency of the system.
Class diagram represents the object orientation of a system. So it is generally used for development purpose.
This is the most widely used diagram at the time of system construction.
Object Diagram:
Object diagrams can be described as an instance of class diagram. So these diagrams are more close to real life
scenarios where we implement a system.
Object diagrams are a set of objects and their relationships just like class diagrams and also represent the static
view of the system.
The usage of object diagrams is similar to class diagrams but they are used to build prototype of a system from
practical perspective.
Component Diagram:
Component diagrams represent a set of components and their relationships. These components consist of
classes, interfaces or collaborations.
During design phase software artifacts (classes, interfaces etc) of a system are arranged in different groups
depending upon their relationship. Now these groups are known as components.
Finally, component diagrams are used to visualize the implementation.
Deployment Diagram:
Deployment diagrams are a set of nodes and their relationships. These nodes are physical entities where the
components are deployed.
Deployment diagrams are used for visualizing deployment view of a system. This is generally used by the
deployment team.
Note: If the above descriptions and usages are observed carefully then it is very clear that all the diagrams are
having some relationship with one another. Component diagrams are dependent upon the classes, interfaces etc
which are part of class/object diagram. Again the deployment diagram is dependent upon the components which
are used to make a component diagrams.
Behavioral Diagrams:
Any system can have two aspects, static and dynamic. So a model is considered as complete when both the
aspects are covered fully.
Behavioral diagrams basically capture the dynamic aspect of a system. Dynamic aspect can be further described
as the changing/moving parts of a system.
Use case diagrams are a set of use cases, actors and their relationships. They represent the use case view of a
system.
So use case diagram is used to describe the relationships among the functionalities and their internal/external
controllers. These controllers are known as actors.
Sequence Diagram:
A sequence diagram is an interaction diagram. From the name it is clear that the diagram deals with some
sequences, which are the sequence of messages flowing from one object to another.
Interaction among the components of a system is very important from implementation and execution
perspective.
So Sequence diagram is used to visualize the sequence of calls in a system to perform a specific functionality.
Collaboration Diagram:
Collaboration diagram is another form of interaction diagram. It represents the structural organization of a
system and the messages sent/received. Structural organization consists of objects and links.
The purpose of collaboration diagram is similar to sequence diagram. But the specific purpose of collaboration
diagram is to visualize the organization of objects and their interaction.
Statechart Diagram:
Any real time system is expected to be reacted by some kind of internal/external events. These events are
responsible for state change of the system.
Statechart diagram is used to represent the event driven state change of a system. It basically describes the
state change of a class, interface etc.
State chart diagram is used to visualize the reaction of a system by internal/external factors.
Activity Diagram:
Activity diagram describes the flow of control in a system. So it consists of activities and links. The flow can be
sequential, concurrent or branched.
Activities are nothing but the functions of a system. Numbers of activity diagrams are prepared to capture the
entire flow in a system.
Activity diagrams are used to visualize the flow of controls in a system. This is prepared to have an idea of how
the system will work when executed.
Note: Dynamic nature of a system is very difficult to capture. So UML has provided features to capture the
dynamics of a system from different angles. Sequence diagrams and collaboration diagrams are isomorphic so
they can be converted from one another without losing any information. This is also true for statechart and
activity diagram.
Overview:
The class diagram is a static diagram. It represents the static view of an application. Class diagram is not only
used for visualizing, describing and documenting different aspects of a system but also for constructing
executable code of the software application.
The class diagram describes the attributes and operations of a class and also the constraints imposed on the
system. The class diagrams are widely used in the modelling of object oriented systems because they are the
only UML diagrams which can be mapped directly with object oriented languages.
The class diagram shows a collection of classes, interfaces, associations, collaborations and constraints. It is also
known as a structural diagram.
Purpose:
The purpose of the class diagram is to model the static view of an application. The class diagrams are the only
diagrams which can be directly mapped with object oriented languages and thus widely used at the time of
construction.
The UML diagrams like activity diagram, sequence diagram can only give the sequence flow of the application but
class diagram is a bit different. So it is the most popular UML diagram in the coder community.
Class diagrams are the most popular UML diagrams used for construction of software applications. So it is very
important to learn the drawing procedure of class diagram.
Class diagrams have lot of properties to consider while drawing but here the diagram will be considered from a
top level view.
Class diagram is basically a graphical representation of the static view of the system and represents different
aspects of the application. So a collection of class diagrams represent the whole system.
The name of the class diagram should be meaningful to describe the aspect of the system.
For each class minimum number of properties should be specified. Because unnecessary properties will
make the diagram complicated.
Use notes when ever required to describe some aspect of the diagram. Because at the end of the drawing
it should be understandable to the developer/coder.
Finally, before making the final version, the diagram should be drawn on plain paper and rework as many
times as possible to make it correct.
Now the following diagram is an example of an Order System of an application. So it describes a particular
aspect of the entire application.
First of all Order and Customer are identified as the two elements of the system and they have a one to
many relationship because a customer can have multiple orders.
We would keep Order class is an abstract class and it has two concrete classes (inheritance relationship)
SpecialOrder and NormalOrder.
The two inherited classes have all the properties as the Order class. In addition they have additional
functions like dispatch () and receive ().
So the following class diagram has been drawn considering all the points mentioned above:
Where to use Class Diagrams?
Class diagram is a static diagram and it is used to model static view of a system. The static view describes the
vocabulary of the system.
Class diagram is also considered as the foundation for component and deployment diagrams. Class diagrams are
not only used to visualize the static view of the system but they are also used to construct the executable code
for forward and reverse engineering of any system.
Generally UML diagrams are not directly mapped with any object oriented programming languages but the class
diagram is an exception.
Class diagram clearly shows the mapping with object oriented languages like Java, C++ etc. So from practical
experience class diagram is generally used for construction purpose.
Overview:
To model a system the most important aspect is to capture the dynamic behaviour. To clarify a bit in details,
dynamic behaviour means the behaviour of the system when it is running /operating.
So only static behaviour is not sufficient to model a system rather dynamic behaviour is more important than
static behaviour. In UML there are five diagrams available to model dynamic nature and use case diagram is one
of them. Now as we have to discuss that the use case diagram is dynamic in nature there should be some
internal or external factors for making the interaction.
These internal and external agents are known as actors. So use case diagrams are consists of actors, use cases
and their relationships. The diagram is used to model the system/subsystem of an application. A single use case
diagram captures a particular functionality of a system.
So to model the entire system numbers of use case diagrams are used.
Purpose:
The purpose of use case diagram is to capture the dynamic aspect of a system. But this definition is too generic
to describe the purpose.
Because other four diagrams (activity, sequence, collaboration and Statechart) are also having the same
purpose. So we will look into some specific purpose which will distinguish it from other four diagrams.
Use case diagrams are used to gather the requirements of a system including internal and external influences.
These requirements are mostly design requirements. So when a system is analyzed to gather its functionalities
use cases are prepared and actors are identified.
Now when the initial task is complete use case diagrams are modelled to present the outside view.
Use case diagrams are considered for high level requirement analysis of a system. So when the requirements of
a system are analyzed the functionalities are captured in use cases.
So we can say that uses cases are nothing but the system functionalities written in an organized manner. Now
the second things which are relevant to the use cases are the actors. Actors can be defined as something that
interacts with the system.
The actors can be human user, some internal applications or may be some external applications. So in a brief
when we are planning to draw an use case diagram we should have the following items identified.
Actors
Use case diagrams are drawn to capture the functional requirements of a system. So after identifying the above
items we have to follow the following guidelines to draw an efficient use case diagram.
The name of a use case is very important. So the name should be chosen in such a way so that it can
identify the functionalities performed.
Give a suitable name for actors.
Do not try to include all types of relationships. Because the main purpose of the diagram is to identify
requirements.
The following is a sample use case diagram representing the order management system. So if we look into the
diagram then we will find three use cases (Order, SpecialOrder and NormalOrder) and one actor which is
customer.
The SpecialOrder and NormalOrder use cases are extended from Order use case. So they have extends
relationship. Another important point is to identify the system boundary which is shown in the picture. The actor
Customer lies outside the system as it is an external user of the system.
As we have already discussed there are five diagrams in UML to model dynamic view of a system. Now each and
every model has some specific purpose to use. Actually these specific purposes are different angles of a running
system.
So to understand the dynamics of a system we need to use different types of diagrams. Use case diagram is one
of them and its specific purpose is to gather system requirements and actors.
Use case diagrams specify the events of a system and their flows. But use case diagram never describes how
they are implemented. Use case diagram can be imagined as a black box where only the input, output and the
function of the black box is known.
These diagrams are used at a very high level of design. Then this high level design is refined again and again to
get a complete and practical picture of the system. A well structured use case also describes the pre condition,
post condition, exceptions. And these extra elements are used to make test cases when performing the testing.
Although the use cases are not a good candidate for forward and reverse engineering but still they are used in a
slight different way to make forward and reverse engineering. And the same is true for reverse engineering. Still
use case diagram is used differently to make it a candidate for reverse engineering.
In forward engineering use case diagrams are used to make test cases and in reverse engineering use cases are
used to prepare the requirement details from the existing application.
So the following are the places where use case diagrams are used:
Reverse engineering.
Forward engineering.
Overview:
Activity diagram is another important diagram in UML to describe dynamic aspects of the system.
Activity diagram is basically a flow chart to represent the flow form one activity to another activity. The activity
can be described as an operation of the system.
So the control flow is drawn from one operation to another. This flow can be sequential, branched or concurrent.
Activity diagrams deals with all type of flow control by using different elements like fork, join etc.
Purpose:
The basic purposes of activity diagrams are similar to other four diagrams. It captures the dynamic behaviour of
the system. Other four diagrams are used to show the message flow from one object to another but activity
diagram is used to show message flow from one activity to another.
Activity is a particular operation of the system. Activity diagrams are not only used for visualizing dynamic
nature of a system but they are also used to construct the executable system by using forward and reverse
engineering techniques. The only missing thing in activity diagram is the message part.
It does not show any message flow from one activity to another. Activity diagram is some time considered as the
flow chart. Although the diagrams looks like a flow chart but it is not. It shows different flow like parallel,
branched, concurrent and single.
Activity diagrams are mainly used as a flow chart consists of activities performed by the system. But activity
diagram are not exactly a flow chart as they have some additional capabilities. These additional capabilities
include branching, parallel flow, swimlane etc.
Before drawing an activity diagram we must have a clear understanding about the elements used in activity
diagram. The main element of an activity diagram is the activity itself. An activity is a function performed by the
system. After identifying the activities we need to understand how they are associated with constraints and
conditions.
So before drawing an activity diagram we should identify the following elements:
Activities
Association
Conditions
Constraints
Once the above mentioned parameters are identified we need to make a mental layout of the entire flow. This
mental layout is then transformed into an activity diagram.
The following is an example of an activity diagram for order management system. In the diagram four activities
are identified which are associated with conditions. One important point should be clearly understood that an
activity diagram cannot be exactly matched with the code. The activity diagram is made to understand the flow
of activities and mainly used by the business users.
Confirm order
Dispatch order
After receiving the order request condition checks are performed to check if it is normal or special order. After
the type of order is identified dispatch activity is performed and that is marked as the termination of the process.
The basic usage of activity diagram is similar to other four UML diagrams. The specific usage is to model the
control flow from one activity to another. This control flow does not include messages.
The activity diagram is suitable for modeling the activity flow of the system. An application can have multiple
systems. Activity diagram also captures these systems and describes flow from one system to another. This
specific usage is not available in other diagrams. These systems can be database, external queues or any other
system.
Now we will look into the practical applications of the activity diagram. From the above discussion it is clear that
an activity diagram is drawn from a very high level. So it gives high level view of a system. This high level view
is mainly for business users or any other person who is not a technical person.
This diagram is used to model the activities which are nothing but business requirements. So the diagram has
more impact on business understanding rather implementation details.
In many design processes, the use case diagram is the first that designers will work with when starting a project. This
diagram allows for the specification of high level user goals that the system must carry out. These goals are not
necessarily tasks or actions, but can be more general required functionality of the system.
Use Case
More formally, a use case is made up of a set of scenarios. Each scenario is a sequence of steps that encompass an
interaction between a user and a system. The use case brings scenarios together that accomplish a specific goal of the
user.
A use case can be specified by textually describing the steps required and any alternative actions at each step. For
example, the use case for searching a web for a keyword might be shown as:
In Visual Case, you can specify the steps of a use case in its description field. Simply right-click on a use case and select
properties. You can then run a report and print or export the results to html or ascii text. Together, the report and the
diagrams will include all of the details of the use case - their specific scenarios and the actors that carry them out.
Actor
The use case diagram allows a designer to graphically show these use cases and the actors that use them. An actor is a
role that a user plays in the system. It is important to distinguish between a user and an actor (better thought of as a role).
A user of the system may play several different roles through the course of his, her or its job (since an actor may be
another system). Examples of actors are salesperson, manager, support person, and web store system. It is possible that
the same person may be a sales person and also provide support. When creating a use case model, we are not
concerned with the individuals, only the roles that they play.
Associations
On a use case diagram, associations are drawn between actors and use cases to show that an actor carries out a use
case. A use case can be carried out by many actors and an actor may carry out many use cases.
In the above diagram, the actors are shown as the green stick figure shapes on the left, the use cases are the blue
ellipses, and the associations between them are represented by the connecting lines. The developer and the stakeholder
both are responsible for specifying the system roles, but only the developer creates the model.
Includes
Use cases can also be related to each other with three different links. The diagram below shows the use of the includes
link. Both invoice purchase and online purchase include the scenarios defined by purchase valuation. In general, the
includes link is to avoid repetition of scenarios in multiple use cases.
Generalization
When a use case describes a variation on another use case, use a generalization link. In the example below, the use case
limit exceeded describes a situation in which the usual scenario of online purchase is not performed. Use cases that
generalize another use case should only specify an alternative, even exceptional, scenario to the use case being
generalized. The overall goal of the use cases should be the same.
Extends
In some instances you want to describe a variation on behaviour in a more controlled form. In such instances you can
define extension points in the extended use case. In the example below, search by name is said to extend search at the
name extension point. The extends link is more controlled than the generalization link in that functionality can only be
added at the extension points.
When starting a use case model, it is very important to keep it simple. Often it is easiest to first determine the actors of the
system, and then flush out the use cases that they perform. Your use case diagrams can be as simple or complex as you
wish, however simpler, less cluttered diagrams are easier to understand, and are often more powerful in capturing the
tasks of the system.
In Visual Case, you can explode a use case into a new use case diagram. For example, the use case online purchase
may require further specification as you move into the design. You can create a sub-diagram within any use case to help
clarify and understand the tasks involved.
Remember that a use case represents a goal of a user, not an atomic programming operation. Your use case design
should be simple and help to clarify the user's goals and expectations for the system.
The class diagram is core to object-oriented design. It describes the types of objects in the system and the static
relationships between them.
Packages
Packages allow you to break up a large number of objects into related groupings. In many object oriented languages (such
as Java), packages are used to provide scope and division to classes and interfaces. In the UML, packages serve a
similar, but broader purpose.
Any UML diagram in Visual Case can have packages on them. Each package can contain any type and any number of
other UML diagrams, as well as interfaces and classes.
Classes
The core element of the class diagram is the class. In an object oriented system, classes are used to represent entities
within the system; entities that often relate to real world objects.
The Contact class above is an example of a simple class that stores location information.
Top: The name, package and stereotype are shown in the upper section of the class.
In Visual Case, classes shown on a diagram that do not belong to the same package as
the diagram are shown with their entire path name. You can optionally assign a
stereotype to a class.
Bottom: In the lower section are the operations that can be performed on the class.
On any Visual Case class diagram, you can optionally shown and hide both the attribute
and operations sections of all the classes or individual classes. This is useful as often you
will want your class diagrams to highlight specific constructs of your system that
superfluous information only serves to clutter and confuse.
Attributes
An attribute is a property of a class. In the example above, we are told that a Contact
has an address, a city, a province, a country and a postal code. It is generally
understood that when implementing the class, functionality is provided to set and
retrieve the information stored in attributes. Methods to set and retrieve attribute data
are often called accessor methods (also getting and setting methods) and need not
be shown in your model as they are usually inferred.
+ Public
# Protected
~ Package
In object oriented design, it is generally preferred to keep most attributes private as the
accessor methods allow you to control access to the data. The most common exception
to this preference are constants.
In addition to the name, visibility, datatype and default value, Visual Case allows you to
specify the following properties for an attribute:
Array: you can set an attribute to be treated as an array of attributes; shown with
square braces [ ] beside the name.
Static: attributes that are static only exist once for all instances of the class. In the
example above, if we set city to be static, any time we used the Contact class the city
attribute would always have the same value.
Final: if an attribute is declared final, it's value cannot be changed. The attribute is a
constant.
Operations
The operations listed in a class represent the functions or tasks that can be performed
on the data in the class.
In the List class above, there is one attribute (a private array of Objects) and three
operations.
The format is very similar to that of the attribute except with the removal of a default
value and the addition of parameters.
Generalization
The generalization link is used between two classes to show that a class incorporates
all of the attributes and operations of another, but adds to them in some way.
In the above diagram, we again see our Contact class, only now with two child classes.
We can say that Client and Company inherit, generalize or extend Contact. In each of
Client and Company all of the attributes in Contact (address, city, etc.) exist, but with
more information added. In the above situation Contact is said to be the superclass of
Client and Company.
When using a generalization link, the child classes have the option to override the
operations in the parent class. That is, they can include an operation that is defined in
the superclass, but define a new implementation for it.
Sometimes you may want to force children to override methods in a parent class. In this
case you can define the methods in the superclass as abstract. If a class has abstract
operations, the class itself is considered abstract. Abstract methods and classes are
shown in italics. Not all of the operations in an abstract class have to be abstract.
The abstract operation calculateTaxes in AbstractTaxCalculator must be implemented in
the child classes OntarioTaxCalculator and NovaScotiaTaxCalculator. Since the
operations must be implemented, it is not necessary to show them in the child classes,
however you may if you choose. The key is to keep your diagrams as clear as possible.
In the above instance the diagram is simple and the meaning clear, however with
multiple levels of inheritance and more attributes and operations, you may wish to
specify all of the methods that are overriden.
Interfaces
Many object oriented programming languages do not allow for multiple inheritance. The
interface is used to solve the limitations posed by this. For example, in the earlier class
diagram Client and Company both generalize Contact but one or the other child classes
may have something in common with a third class that we do not want to duplicate in
multiple classes.
The interface Sortable, is used in the above example to show that both Company and
Product implement the sort operation. We can say that Company and Product
implement Sortable or that they are Sortable. Because Product already generalizes
Contact, we could not also allow it to generalize Sortable. Instead, we made Sortable an
interface and added a realization link to show the implementation.
Interfaces are very similar to abstract classes with the exception that they do not have
any attributes. As well, unlike a class, all of the operations in an interface have no
implementation. The child classes Company and Product are forced to implement the
sort operation in its entirety.
Associations
Classes can also contain references to each other. The Company class has two attributes that reference the Client class.
Although this is perfectly correct, it is sometimes more expressive to show the attributes as associations.
The above two associations have the same meaning as the attributes in the old version of the Contact class.
The first association (the top one) represents the old contactPerson attribute. There is one contact person in a single
Company. The multiplicity of the association is one to one meaning that for every Companythere is one and only one
contactPerson and for each contactPerson there is one Company. In the bottom association there are zero or many
employees for each company. Multiplicities can be anything you specify. Some examples are shown:
0 zero
1 one
The arrows at the end of the associations represent their navigability. In the above examples, the Company references
Clients, but the Client class does not have any knowledge of the Company. You can set the navigability on either, neither
or both ends of your associations. If there is no navigability shown then the navigability is unspecified.
The composition association is represented by the solid diamond. It is said that ProductGroup is composed of Products.
This means that if a ProductGroup is destroyed, the Products within the group are destroyed as well.
The aggregation association is represented by the hollow diamond. PurchaseOrder is an aggregate of Products. If a
PurchaseOrder is destroyed, the Products still exist.
If you have trouble remembering the difference between composition and aggregation, just think of the alphabet.
Composition means destroy and the letters 'c' and 'd' are next to each other.
Dependencies
A dependency exists between two elements if changes to one will affect the other. If for example, a class calls an
operation in another class, then a dependency exists between the two. If you change the operation, than the dependent
class will have to change as well. When designing your system, the goal is to minimize dependencies.
To help clarify the dependencies in your design, you may wish to draw a Package Diagram. A package diagram is
essentially a class diagram with only packages and dependencies showing. Dependencies can exist between any
components in the UML however at the highest level, dependencies will exist between packages. Within a package, the
dependencies may be too numerous to specify. That is not to say that numerous dependencies are okay. Even within a
package you want to limit the dependencies, however between packages in particular you should be strict about the
number of dependencies that exist. In general, the fewer the dependencies the more scaleable and maintainable your
system will be.
Class diagrams really are the core of most object oriented design so you will likely find yourself using them all the time.
Fortunately class diagrams closely relate to the most object oriented languages, so the basics (classes, operations,
attributes, generalizations, etc.) should be fairly easy to grasp. Start with what you know and then move on.
The most important thing about design is to not let it bog you down with detail. It is better to have a few clear diagrams
than many, overly complex diagrams. Previously we saw the AbstractTaxCalculator that was generalized by
OntarioTaxCalculator and NovaScotiaTaxCalculator. If we tried to create a diagram with all ten Canadian provinces and
the three territories we would have a huge complex mess. If we were designing a tax system for the United States and we
tried to show all of the states, we would be in even more trouble. It is more clear, and just as expressive to show two or
three child classes and add a note to the diagram the explains that the other provinces and territories are implemented in
the same way.
Keeping your designs simple will allow you to be more productive as well as making your designs far more understandable
and useable. Also, as the system is implemented and upgraded, you'll want to keep your design in synch with your
implementation. This will be far easier with a simple design of the key concepts of the system.
Previously we saw how interaction diagrams demonstrate the behaviour of several objects when executing a single use
case. When you want to show the sequence of events on a broader scale use activity and state diagrams.
Activity Diagram
An activity is the execution of a task whether it be a physical activity or the execution of code. Simply put, the activity
diagram shows the sequence of activities. Like the simple flow chart, activity diagrams have support for conditional
behaviour, but has added support for parallel execution as well.
Start: each activity diagram has one start (above) at which the sequence of actions begins.
End: each activity diagram has one finish at which the sequence of actions ends
Activity: activities are connected together by transitions. Transitions are directed arrows flowing from the previous
activity to the next activity. They are optionally accompanied by a textual label of the form:
[guard] label
The guard is a conditional expression that when true indicates that the transition is taken. The label is also optional and is
freeform.
To show conditional behaviour use a branch and a merge. The top diamond is a branch and has only one transition
flowing into it and any number of mutually exclusive transitions flowing out. That is, the guards on the outgoing transitions
must resolve themselves so that only one is followed. The merge is used to end the conditional behaviour. There can be
any number of incoming, and only one outgoing transition.
To show parallel behaviour use a fork and a join. The fork (top) has one transition entering and any number of
transitions exiting, all of which will be taken. The join (bottom) represents the end of the parallel behaviour and has any
number of transitions entering, and only one leaving.
The UML diagram examples below are all created in the case study of describing the QSIG Private
User Mobility Registration (PUMR) service in UML. Only a subset of the available diagram notations in
UML is used. The complete case study, as well as the methodology for creating the UML models, is
available in EG 202 872.
Use Case diagram
Sequence diagram
Activity diagram
Object diagram
Class diagram
The creation of a use case model is an excellent vehicle for elicitation of functional requirements. The
activity consists of identifying use cases and actors and describing the details of each use case.
The use case diagram above describes what services (use cases) that are available for different
categories of users (PUM user, Authorized user).
TOP
Sequence diagram
When describing the details of a use case (service), a sequence diagram is one of the possible
diagram kinds to choose from in UML. When making sequence diagrams, you focus on describing the
sequences of message interactions between communicating entities.
The sequence diagram above describes how the actor (PUM User) initiates the de-registration use
case and how the distributed system entities (Visitor, Home) interacts by message interchange in
order to carry out the service.
TOP
Activity diagram
Activity diagrams is another way to describe use case behaviour, focussing on how the behaviour can
be broken down in functions, internal to the system or system part.
The activity diagram above describes in what order different functions should be carried out and, if
they are optional, under what circumstances the functions should be invoked.
TOP
Class diagram
Class diagrams typically describe the different entities of a system as classes and the relation between
these. This may for example include
system parts and their relation
system data
TOP
Object diagram
The object diagram puts the classes in the class diagrams into context and shows how individual
instances of classes relate to each other.
The object diagram above describes how the communicating entities in the PUMR system
environment relate and the means for communication that exist.