Professional Documents
Culture Documents
Things
Things are the most important building blocks of UML. Things can be −
Structural
Behavioral
Grouping
Annotational
Structural Things
Structural things define the static part of the model. They represent the physical and
conceptual elements. Following are the brief descriptions of the structural things.
Class − Class represents a set of objects having similar responsibilities.
Use case −Use case represents a set of actions performed by a system for a specific
goal.
Node − A node can be defined as a physical element that exists at run time.
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
Relationship
Relationship is another most important building block of UML. It shows how the
elements are associated with each other and this association describes the
functionality of an application.
There are four kinds of relationships available.
Dependency
Dependency is a relationship between two things in which change in one element also
affects the other.
Association
Association is basically a set of links that connects the elements of a UML model. It
also describes how many objects are taking part in that relationship.
Generalization
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.
Visibility
-private : They can’t accessed by any other class or sub class. In UML
private visibility is denoted as -
+public : An attribute or method is public, which can be accessed by any
other class. In UML public visibility is denoted as +
#protected : An attribute or method is protected. These can be accessed
by the same class or sub – classes. In UML protected visibility is
denoted as #
~package / default : This sets the visibility to package or default, which
means it can be used by any other class.
Example :
Employee
-name : string
-empid : int
-phone : int
-dept : string
+updatePhone()
In the above example, Employee is the name the class. name, empid,
phone, dept are attributes for the class Employee and they are declared
as private.
updatePhone() is a method of class Employee and it is declared as
public.
Inheritance :
Animal
- name : string
- id : string
- age : string
- weight : int
- setName()
- eat()
Tortoise Camel
This is an Inheritance relationship.
These sub – classes will inherit all the attributes and methods of the
super class . These sub classes will use the attributes name, id and age.
Association / Multiplicity
Associations show relationships between classes.
There are 2 types of Associations.
Unary Association and Binary Association
Unary Association
Class A Class B
Person Address
has - a
Person Address
Person has – a Address.
Person knows its Address.
Address doesn’t know who is living there.
Class Address doesn’t know about Class Person.
Class A Class B
+doSomething() +actionB()
-myB
Class A Class B
-myB : Class B
+doSomething() +actionB()
Class A
Class B
+doSomething() +actionB()
-myB
Class A Class B
-myB : Class B
+doSomething() +actionB()
The above representation has the fact that Class A has a attribute of type
Class B written in the attribute’s column.
The above two representations are identical.
Which representation should we use.
It depends on where your emphasis is. If you’re going to emphasize the
relationship of Class A to Class B, the arrow is a great way to
emphasize.
Example :
Person
Address
-name : string -street : string
+doSomething() -city : string
-zip : string
+toString() :
-address string
Class Person has 2 attributes one is name of type string and the other is
address of type Address. Both types of representations are used in the
same diagram.
3 types of Associations :
Association most general
Aggregation Describe whole – part relationship.
Composition Describe whole – part relationship.
Aggregation : Aggregation are associations with a whole – part
relationship.
Example :
Class A Class B
The hollow diamond is next to the Class that represents the whole. Class
B is part of Class A.
Example :
Lake Slide
Car Passengers
This means that the construction and destruction of the ‘part’ depends on
the ‘whole’.
The filled diamond is next to the class that represents the whole.
Example :
Class : Administrator
Attributes : adminName, email
Methods : updateCatalog.
Class : Shopping Cart
Attributes : Cart Id, Product Id, quantity, dateAdded.
Methods : addCartItem, updateQuantity, viewCarddetails, checkout.
Class : Order
Attributes : orderId, datecreated, dateshipped, customerName,
customerId, States, Shipping Id.
Methods : placeOrder
Class : Shipping Info
Attributes : Shipping id, Shipping type, Shipping Cost, Shipping Region
id.
Methods : updateShippinginfo
Class : Order Details
Attributes : order id, product id, product name, quantity, unit cost, sub
total.
Methods : calcPrice