Académique Documents
Professionnel Documents
Culture Documents
by
N.Prathyush
a
e s
s s
c l a
Classes
contents:-
Ø Definition of the class
ØNames
ØAttributes
ØOperations
ØResponsibilities
Definition:-
A class is a description of a set of objects that share the same attributes, operations,
relationships, and semantics. A class is implemented one or more interfaces.
Graphically, a class is rendered as a rectangle. name
attributes
operations
Names:-
Every class must have a name that distinguishes it from other classes. A name is a
textual string with a simple path or path name which consists of the details of the packages of
class.
Customer Java::awt::Rectangle
Attributes:-
An attribute is a named property of a class that describes a range of values that
instances hold. An attribute represents some property of the thing you are modeling that is shared
by all objects of that class. Graphically, attributes are
walisted in a compartment just below the class
name.
Height: llfloat
Width: float
Thickness: float
IsLoadBearing : Boolean
= false
Operations:-
An operation is the implementation of a service that can be requested from any
object of a particular class. A may have any number of operations based on the responsibilities
mentioned the class. Graphically, the operations are listed in a compartment just below the
attributes.
Rectangl
e
add()
grow()
move()
Is Empty()
Operation by stating its signature, covering the name, type, and default value of all
parameters and a return type.
TemperatureSen
sor
Reset()
setAlarm(t :
Temperature)
Value() : Temperature
Responsibilities:-
A responsibility is a contract or an obligation of a class. When we create a
class, we make a statement that all the objects of that class should have the same kind of state
and the same kind of behavior. Graphically, responsibilities can be drawn in a separate
compartment at the bottom of the class.
FraudAgent
Responsibilities
--Determine the risk of
a customer order
--handle customer-
specific criteria for
fraud
Com mon Model ing Tec hni ques :-
A class is a structural thing which provides the abstraction of various properties
and operations shared by different objects, by using classes we can model the following.
Model
Responsibilities
--manage the
state of the model
Modeling non-software things:-
Model the non-software thing as a class
If we want to distinguish the modeled class from the existing UML classes use a
stereo type.
If the non-software thing which we want to model is in hardware, try to model a
using a “ node “.
Accounts Receivable
Agent
Modeling 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.
<<enumeration>
>
Boolean
False
true
h i p
n s
t i o
el a s
R
Definition:-
A relationship is a connection among things. In UML a relationship is rendered as a path, with
different kinds of lines use to distinguish the kinds of relationships. In object-oriented modeling, the three
most important relationships.
Contents:-
Dependency
Generalization
Association
Dependency:-
A dependency is a “ using “ relationship that states that a change in specification of one thing
may effect another thing that uses it. Graphically, a dependency is rendered to the thing being depended on.
FilmClip
name
playOn(c :
-------------------> Channel
Channel)
Start()
Stop() --------
Reset()
dependenc
y
Generalization:-
A Generalization is a relationship between a general thing(super class) and a
more specific kind of that thing(sub class). Generalization is sometimes also known as IS-A-
KIND of relationship. Graphically, generalization is rendered as a solid directed line with a
large open arrow head, pointing to the parent.
Shape
origin base class
Move()
generalizatio Resize()
n Display()
Name:-
This is the name given for the relationship between two or more classes.
Name
name direction
Works for
Person Company
associatio
n
Role Names:-
These are the names given for the participating classes in a relationships. A
person playing the role of employee is associated with a company playing the role of
employer.
Person Company
employe employer
e association
Multiplicity:-
Multiplicity represent how many objects are involved across an instance of
association from the different classes. The stating of “ how many “ is known as Multiplicity.
1...
Person Company
associatio
n
Aggregation:-
If we want to model a” whole/part “ relationship in which one class to
represents a larger thing consisting of these smaller things, this kind of relationship is
often known as aggregation and implements strictly the relationship “ Has-A “.
An aggregation is a special kind of association rendered with an open or
hallow diamond at the end of “ whole “ class.
Company
aggregati
whole on
part Department
Common Modeling Techniques:-
using UML’s relationships we can model the following.
Modeling Simple Dependency
Modeling Single Inheritance
Modeling Structural relationships
<<friend
>>
Iterator
Modeling Simple Inheritance:-
To model inheritance between a set of classes,
Identify the responsibilities, attributes and operations that are common to two or more
classes.
Create a class with the above mentioned common responsibilities, attributes and
operations.
Lastly show the relationships from the specialized classes to generalized class.
Security
presentValu
e()
History()
interestRat assessments
e
presentValu presentValu presentValue presentValu
e() e() () e()
SmallCapSto LargeCapSto
ck ck
Common Structural Relationships:-
A relationships are classified into two types, they are one-side, two-sided
dependency and generalization/specification.
For a given set of two classes identify whether objects of one class can navigate to the
other class and vice-versa.
Identify a set of two classes with the relationship dependency and find out whether there
exist a two-sided relationship other than dependency.
For each of the associations specify the adornments such as role names, multiplicity,
aggregation etc.
0…
ha Departme 1
School s
1 1. nt
1. . 1. 1.
. . .
member Assigned
To 0
1. 1. ..1
chairpers
attends . teach . on
Instruct
Student Course es 1. or
.
o n
m
m ism s
C o n
c h a
m e
Common mechanisms
Uml is made similar by the presence of four
common mechanisms that apply consistently throughout the
language. After constructing or developing the architecture and
different views of a software intensive system, the developer
should go for common mechanisms. We have four types of
common mechanisms. They are….
q Specifications
q Adornments
q Common divisions
q Extensibility
Adornments
Adornments are generally added to an element’s basic
notation and are used to visualize details from the element’s
specification .They are used to decorate a particular thing to
specify some artifacts.
Adornments are classified into two types. They are…..
1. Textual adornments
2. Graphical or symbolic adornments.
Textual adornments
most adornments are rendered by placing text near the
element. Textual adornments are the strings which delineate the
artifacts of a particular thing or relationship or a diagram. Some of
the common textual adornments are name, role names,
multiplicity, isaggregation or not.
Graphical adornments
most adornments are rendered by adding a graphic
symbol to the basic elements. These are the adornments used to
specify the artifacts such as relationships, access specifiers etc. some
of the symbolic adornments are..
publi
c
private
# protected
note
A note is a special kind of adornment, which is a graphical
symbol for rendering comments or constraints attached to an
element or collection of elements. These are used to specify things
like requirements, observations, reviews and explanations, in
addition to rendering constraints.
A note is rendered in uml using a rectangle with a dog-
eared corner. In uml a note can be rendered in three ways. They
are…..
Link to
document
Extensibility mechanisms
uml has the capability of extending its vocabulary,
properties, and semantics using one of the mechanisms known as
extensibility mechanisms. This mechanisms permit us to extend the
language in controlled ways.
these mechanisms include…
1. stereo types
2. tagged values
3. constraints
Stereo types
a stereo type extends the vocabulary of the uml,
allowing you to create new kinds of building blocks that are derived
from existing ones but with its own properties, semantics and
notation.
Stereotyped
element as icon
Tagged values
A tagged value extends the properties of a uml building
block, allowing to create new information in that element’s specific
function.
A tagged value is rendered as a string enclosed by
brackets and placed below the name of another element. That
string includes a name(tag), a separator(=) and a value( of the
tag).
Server
{processor
s=3}
Constraints
A constraint is a condition which is used to add or
modify the existing rules or semantics for a well-formed model we
need to have certain constraints established.
a constraint is generally rendered as a simple statement
or a mathematical equation in a pair of curly braces, and is placed
by side of the thing to which it belongs.
simple constraint
portfolio corporation
Constraint
{secur across
e} multiple
Bank { constraints
Account or}
person
Gender :{f,m} Formal
constraint
Using ocl
{self.wife.gender=fem
ale and
based on the common mechanisms we can model the
following
modeling comments
modeling new building blocks
modeling new properties
modeling new semantics
Modeling comments
write the comment in the symbol provided and place the note
by side of the element to which it refers.
the note can be elided or it can be made visible
if the note is lengthy, then write down the complete description
in a document and place a link in the note referring the document
as the model evolves keep those comments that are significant ,
otherwise remove
Modeling new building blocks
ü Make sure that the thing which we want to model doesn’t have a
graphical representation in uml
ü After conforming the above select any one of the eleven things
and stereotype it. Stereo typing can be done in two ways
1. Selecting a stereo type which already exists.
2. Creating our own stereo type.
üSpecify new properties and semantics for the new thing.
ü If necessary place a icon for the above stereo type
Modeling new properties
ü make sure that there is no way to express a value using the
attributes of a class
ü in the above situation create a new tag and assign it a value
which we want to model
<<subsystem>>
---
FieldAccess
- {version=2.5
-
Status=checkdin}
---
<<subsystem>> <<subsystem>>
--
Billing AccountsPayable
---
-
{version=3.2 {version=3.2.1
-- -
---
Status=checkout - Status=checkedin
By=edg} }
-
--
<<subsystem>>
WorldCurrency
{version=7.5
Status=checedin}
Modeling new semantics
ümake sure there is no way to model the rules of constraints.
ü write down the constraints and new semantics for the element
which we want to model and place adjacent to it
ü if we want to express the constraints in a more precise way use
ocl as apart of mentioning the constraints
department
member
{subset 1..* 1 manager
}
person
A diagram is one of the basic building blocks of uml which
group together elements with internal relationships.
According to version 2.0 there are a set of thirteen diagrams
which are used to model a software intensive system in different
views. The diagrams are classified into two types, they are….
1. Static diagrams
2. Dynamic diagrams
The static diagrams model the static behavior of system
where as the dynamic diagrams model the dynamic aspects of a
system.
The static parts of a system uses one of the following
diagrams
1. Class diagrams
2. Object diagram
3. Component diagram
4. Deployment diagram
The following diagrams are used to view the dynamic parts of a
system
Collaboration diagram
A behavioral diagram that shows an
interaction, emphazing the structural
organizations of the objects that send
an d receive messages
orderfullfillme
Order taker
nt
submitord
er placeorder
acknowledgeOrde
Low level of abstraction
orderfullfillme Billing
Order taker
nt agent
process
card
submitord
er placeorder triggerBill
acknowledgeOrder
Modeling complex views
To model a system with a high level of abstraction by eliding some
details, you’d lose the information necessary to make these insights.
To model complex views….
Ø If there is no meaningful information present in a high-level abstraction ,elide
some parts of the diagram and retaining the details in other part.
Ø After eliding if still the diagram is complex , group some of the elements in
packages or in high-level of abstractions, then render those packages or
collaborations in your diagram.
Ø If still diagram is complex, use notes and color as visual cues to draw the
readers attention to the points you want to make.
Ø If it is still complex , print it in its entirely and hang it on a convenient large
wall. You lose the interactivity an online version of the diagram brings, but you
can step back from the diagram and study it for common patterns
c e d
v a n a l
d
A uctu g r
t r
S del i n
M o
c e d
v a n
Ad s es
l a s
C
classifier:-
A classifier is a mechanism that describes structural and behavioral
features. The UML provides a number of other kinds of classifiers.
Classes:-
Classes are the most important building block of any object-oriented system. A class is a
description of set of objects that share the same attributes, operations, relationships, and
semantics.
Shape
origin
move()
Resize()
Display()
Interface:-
A collection of operations that are used to specify a service of a class or a
component.
IUnknown
Datatype:-
A type whose values have no identify, including primitive built-in types, as well as
enumeration types.
<<type>>
Int
{values range
from
-2**31-1 to
Signal:- +2**31}
The specification of an asynchronous stimulus communicated between instances.
<<signal
>>
Component:- OffHook
A physical and replaceable part of a system that conforms to and provides the
realization of a interfaces.
Kernel32.
dll
Node:-
A physical element that exists at time and that represents a computational resource.
Generally having at least some memory and often processing capability.
egb_serv
er
Use case:-
A description of a set of a sequence of actions, including variants, that a system
performs that yields an observable result of value to a particular actor.
Process
Subsystem:- loan
A grouping of elements of which some constitute a specification of the behavior
offered by the other contained elements.
<<subsystem
>>
Customer
Service
subsystem
Visibility:-
Visibility is one of the most important details that we can specify using some
symbolic notation the visibility of a feature specifies whether it can be used by other classifies
UML specifies three levels of visible.
Public Any outside classifier with visibility to the given classifier can
use the feature, specified by prepending the
symbol ( + )
Protected Any descendent of the classifier can use the feature, specified by
Prepending the symbol ( # )
Private Only the classifier itself can use the feature, specified by prepending
the symbol ( - ) Toolbar
# currentSelection :
Tool
# toolCount :
+ pickItem(I :
Integer)
+ addTool(t : Tool)
+ removeTool(I :
integer)
+ getTool() : Tool
# checkOrphans()
Scope:-
Scope is an another detail which can be specified for a classifiers ownership. UML
has two keywords which specify the “ scope “ , they are
instance Each instance of the classifier holds its own value for the feature
classifier There is just one value of the feature for all instance of the classifier
Frame
Instance
header : scope
FrameHeader
uniqueID : Long
Class scope
Abstract, Root, leaf, and Polymorphic Elements:-
UML uses the notation of writing the names of classes and operations in
Italics to show that they are abstraction.
RectangularIc
on
height : ArbitraryIcon
Integer
width : edge :
LineCollection
isInside(p : Point) :
Button Boolean
display()
Multiplicity:-
The number of instances a class may have is called its multiplicity. In UML we
can specify the multiplicity of a class is specify by writing a multiplicity expression in the upper
right corner of the class. For example, NetworkController is a singleton class. There are exactly
three instances of the class ControlRod in the system.
NetworkController
consolePort [2..*] :
Port
Attribute:-
It can specify the visibility, scope, and multiplicity of each attribute and also the
type, initial value, and changeability of each attribute.
The syntax of an attribute in the UML is
[= initial-value] [{property-string}]
There are three defined properties that you can use with attributes.
vin
vout
vinout
Template Classes:-
A template is a parameterized element. We can write template classes, each of which
defines a family of classes. A template includes slots for classes, objects, and values. The result
is a concrete class that can be used just like any ordinary class.
Template
parameters
Template class Item
Value
Map Buckets :
int
+ bind(in I : Item; in v : value) :
Boolean
+ isBound(in I :item) : Boolean
<<bind>> (Customer,
Implicit binding Order, 3)
Map<Customer, explicit binding
Order, 3> OrderMa
p
Standard Elements:-
In UML’s extensibility mechanisms apply to classes. Most often, we will use
tagged values to extend class properties and stereotypes to specify new kinds of components.
There are four standard stereotypes that are used, they are
ØMetaclass
ØPowertype
ØStereotype
ØUtility
stereotype Specifies
parentthat the classifier is a stereotype that maybe applied to
utility Specifies a class whose attributes and operations are all class
other elements.
scoped.
Common Modeling Techniques:-
Modeling the semantics of class:-
In the advanced structural modeling for a class the following are the set
of common modeling techniques available.
Dependency:-
A dependency is a using relationship, specifying that a change in the
specification of one thing may effect another thing, but not necessarily the reverse.
Graphically, a dependency is rendered as a dashed line, directed to the thing.
UML defines a number of stereotypes that may be applied to dependency
relationships. There are 17 such stereotypes, all of which can be organized into six
groups.
There are 8 stereotypes that apply to dependency relationships among classes and
objects in class diagram.
bind Specifies that the source instantiates the target
template using the
given actual parameters.
import Specifies that the public contents of the target package enter the flag
namespace of the source.
Stereotypes for use cases:-
extend Specifies that the target use case extends the behavior of the source.
include Specifies that the source use case explicitly incorporates the
behavior of another use case.
Stereotypes for Interaction:-
become Specifies that the target is the same object as the source but at a later
point in time wit different values states & roles.
call Specifies that the source operation invokes the target operation.
copy Specifies that the target object design exact, but independent, copy of
the source.
Stereotypes for state machine:-
send Specifies that the source operation sends the target event.
Generalization:-
A Generalization is a relationship between a general thing and a more specific kind of
that thing. The relationship generalization is having only one stereotype
i.e., implementation which models the “ private inheritance “.
The generalization relationship is having 4 standard constraints, they are
qcomplete
qincomplete
qdisjoint
qoverlapping
complete Specifies that all children in the generalization have been specified
in the model and that no additional children are permitted.
incomplete Specifies that not all children in the generalization have been
specified and that additional children are permitted.
disjoint Specifies that objects of the parent may have no more than one of
the children as a type.
overlapping Specifies that objects of the parent may have more than one of the
children as a type.
Association:-
An association is a structural relationship, specifying that objects of one thing are
connected to objects of another. Graphically, an association is rendered as a solid line connecting
the same or different classes.
Association is bi-directional relationship. In UML which is having the following
stereotypes.
vNavigation
vVisibility
vQualification
vInterface Specifies
vComposition
vAssociation Class
Navigation:-
At times the navigation between the two entities participating than association is
unidirectional in order to implement this UML provides a concept known as navigation using a
directed arrow or a filled triangle.
1 *
user password
Visibility:-
In UML, we can specify three levels of visibility for the association ends, Generally
applied to the role names, public(+),private(-),protected(#).
1 * 1 *
UserGroup user Password
Qualification:-
The stereotype qualification implements the concept of
“ relationship attributes “. UML uses at different concept known as qualification by which a
qualifier is mentioned at any of the ends of the relation. Using a small rectangle.
jobID : * 0… ReturnedIte
WorkDesk 1
Int m
Interface Specifier:-
Using interface specifies we mentioned the names of the interfaces implements
by each role names of an association relationships.
Worker :
IEmployee
Person
Supervisor :
IManager
Composition:-
A composition is one of the forms of association which implements the relationship
whole / part, such relationship are often known as aggregation but an aggregation with a
multiplicity of exactly one at any of the ends is known as composition.
window
1
*
Association Classes:- Frame
In an association between two classes, the association if self may have some
properties, UML provides 4 standard properties or adornments they are name, role names,
multiplicity & aggregation.
Compan * 1
..* Person
y
Job
descriptio
n
dateHired
salary
Constraints:-
These simple and advanced properties of associations are sufficient for most of the
structural relationships.UML defines five constraints they are
implicit Specifies that the relationship is not manifest but, rather, is only
conceptual.
ordered Specifies that the set of objects at one end of an association are
in an explicit order.
changeable Links between may be added, removed, and changed freely.
addOnly New links may be added from an object on the opposite end of the
association.
frozen A link, once added from an object an the opposite end of the
association, may not be modified or deleted.
Realization:-
A realization is a semantic relationship between classifies in which one classifier
guarantees to carry out. Graphically, a realization is rendered as a dashed directed line with a
open hallow head.
<<interface> Realizatio
> n
IRuleAgent ----------------- AccountBusinessR
addRule() ules
changeRule(
) Realization of an interface
explainActio
Common Modeling Technique:-
Modeling Webs of Relationships:-
v Identify the use cases & synonyms.
v Start by modeling the structural relationships.
v Identify for any generalization or specialization relationships.
v After the above steps completion only proceed for looking dependencies.
v Identify each kind of relationship and if necessary apply the advanced features.
v Don’t try for modeling all kinds of relationships in a single diagram or view.
e s
ka g
ac
p
A package is a general –purpose mechanism for organizing elements into rules.
Graphically, a package rendered as a tabbed folder.
Concepts:-
ØNames
ØOwned Elements
ØVisibility
ØImporting and Exporting
Names:-
A name is a textual string. That name alone is known as a simple name. A package is
typically drawn showing only its name.
client
+OrderForm Sensors::visi
+ on
TrackingFor
Simple names Path names
m
Owned Elements:-
üA package may contain classes, interfaces, components, nodes, collaborations.
ü A package forms a namespace in which duplication of the names of same elements
is
not possible.
üElements of different kinds may have same name with in a package.
üPackages may own other packages.
Clien
Clien t
t
+ +
Orderform OrderForm
+ -
TrackingFor Order
m
+
- Order
TrackingFor
m
Visibility:-
visibility of an element owned by a package by prefixing the elements name with an
appropriate visibility symbol. Public elements are rendered by prefixing their name with a +
symbol, as for OrderForm. Collectively, the public parts of a package constitute the package’s
interface. It is rendered by prefix in the elements name with a# symbol and a – symbol
respectively.
GUI <<import>
+ Window >
+ Form
#
EventHandle
r
Importing and exporting
Generalization:-
Generalization among packages is very much like generalization among classes. The package GUI is
shown to export two classes. Packages involved in generalization relationships follow te same principle of
substitutability as do classes
GUI
+ Window
+ Form
#
eventHandler
WindowsG
UI
+ GUI::Window
+ Form
#
GUI:EventHandl MacGUI
er
+ VBForm
Standard Elements:-
All the UML’s extensibility mechanisms for also applicable to package.UML defines a
set of 5 standard stereo types which are applicable only two packages, they are
ØFacade
ØFramework
ØStub
ØSubsystem
ØSystem
v Identify the architectural views that are significant for the problem.
v Place the elements(diagrams) that are necessary and sufficient to visualize, specify,
construct & document the semantics of the package.
v If necessary group the elements further into way own package.
Interfaces
Iunknown
Networking::IRouter
Ispell Isensor
Sensors::ITarget
Operations
an interface is a named collection of operations used to
specify a service of a class or of a component. Like a class, an interface
may have any number of operations. These operations may be adorned
with visibility properties , concurrency properties, stereotypes, tagged
values, and constraints.
when we visualize an interface in its normal form as a circle, w
suppress the display of these operations. We can render an interface as a
stereotyped class, listing its operations in the appropriate compartment.
Operations may be drawn showing only their name, or they may be
augmented to show their full signature and other properties.
<<interface>>
url
stereotype StreamHandler
openConnectio
n()parse URL()
setURL()
operations toExternalForm
()
operations
Relationships
Ø simple form in which the interface and its realization relationship are rendered as a lollipop
sticking off to one side of a class or component. This is useful when you simply want to expose
the seams in your system.
Ø second, you can use the expanded form in which you render an interface as a stereotyped
class, which allows you to visualize its operations and their properties, and then draw a
realization relationship from the classifier or component to the interface.
in UML a realization is rendered as a dashed directed line with a large open arrow head
pointing to the interface. This notation is cross between generalization and dependency.
in both cases, you attach the class or component that builds on an interface with a
dependency relationship from the element to the interface.
dependency
TargetTracker
Tracker ---------
observ
er Realization(simple
Java::Util::Observa form)
ble
interfa
ce
Target dependency
Id <<interface
currentPosition >>
-------- Observer
TargetTracker
setPosition()
setVelocity() Update()
expectedPositi
on()
Realization(exapanded
form)
Types and roles
Types and roles provide a mechanism for you to model the static and
dynamic conformance of an abstraction to an interface in a specific
context.
A type is a stereotype of a class used to specify a domain of objects,
together with operations applicable to the object.
A role is the behavior of an entity participating in a particular context.
interface
<<interface>>
association
Employee
person Company
getEmploymtHisto
ry()
e:Employee
getCompensation(
)
getBenefits()
class
class
role
Common modeling techniques
There are two common modeling techniques
QueryInterface():HRE
SULT
AddRef():ULONG
Release():ULONG
<<interface>>
ITransaction
ILedger Start()
Ledger.dll PerformAction()
Commit()
Rollback()
Exceptions
IReports failure
person
Modeling static
types
<<become>
> P:person
P:person [employee
[Canditate] ]
Hire( HRDepartme
) nt
Modeling dynamic