Advanced Classes
1
Outline
• What is “Classifier”
• Special properties of attributes and
operations and different kinds of classes
• What is “Relationship”
• Important relationships in UML
2
What is Classifier
• A classifier is a mechanism that describes
structural and behavioral features.
• In general, the modeling elements that can
have instances are called classifiers.
• Class, Instance, Datatype, Signal,
Component, Node, Use case, Subsystem
are classifiers. (packages are not.)
3
What is Classifier cont.
class use case datatype interface
Shape <<datatype>> IUnknow
Process loan Int
-origin
+move() signal
+resize() <<signal>>
+display() OffHook
egb_server <<subsystem>>
[Link] Customer Service subsystem
component node subsystem 4
Special properties of attributes and
operations
• Visibility
– Public[+]: any outside classifier with visibility to the given
classifier can use this feature.
– Protected[#]: any descendant of the classifier can use the
feature.
– Private[-]: only the classifier itself can use the feature.
Toolbar
public #currentSelection
protected
#toolCurrent
+pickItem()
+addTool()
+removeTool()
protected +getTool()
#checkOrphans()
private -compact() 5
Special properties of attributes and
operations
• Scope
– The owner scope of a feature specifies whether
the feature appears in each instance of the
classifier or whether there is just a single
instance of feature for all instances of the
classifier.
• instance : each instance holds its own value.
• classifier : just one value for all instances. [static]
Frame
instance scope
header : FrameHeader
class scope uniqueID : Long
6
Abstract, Root, Leaf and Polymorphic
Elements
Icon
{root} base class
Origin : Point
diaplay() abstract operation
getID() : Integer {leaf}
abstract class concrete operation
RectangularIcon ArbitraryIcon
height : Integer edge : LineCollection
width : Integer
isInside(p : Point) : Boolean abstract class
Button concrete class
display() polymorphic operation
OKButton
{leaf}
7
display() leaf class
Multiplicity
• It’s reasonable to assume that there may
be any number of instances of classes.
• The number of instances a class may
have is called multiplicity.
singleton class multiplicity
NetworkController 1 ControlRod 3
consolePort [2..*] : Port
8
Attributes
• The syntax of an attribute in the UML is
[ visibility ] name [ multiplicity ] [ : type ] [ = initial-value ] [ { property-string } ]
+ origin [0..1] : string = (0,0) {frozen}
• There are three defined properties
1. changeable : no restrictions on modifying the
attribute’s value
2. addOnly : additional value may be added for attributes
with a multiplicity > 1, but once created, a value may
not be removed or altered.
3. frozen : the attribute’s value may not be changed after9
object is initialized.
Operations
• The syntax of an operation in UML is
[ visibility ] name [ ( parameter-list ) ] [ : return-type ] [ { property-string } ]
[ direction ] name : type [ = default-value ]
in, out, inout : means parameter may be modified or not.
• There are five defined properties
1. leaf : may not be overridden <page 7>
2. isQuery : leave the state of subsystem unchanged.
3. sequential : only one flow is in the object at a time.
4. guarded : sequentializing all calls.
5. concurrent : treating the operation as atomic.
– 3. 4. 5. are for concurrence.
In Rational Rose
10
is Synchronize
• In: An input parameter; may not be
modified
• Out: An output parameter; may be
modified to communicate information to
the caller
• inout: An input parameter; may be
modified.
11
Template Classes
• Like template classes in C++ and Ada.
• Cannot use a template directly; you have to
instantiate it first. template parameters
template class
Item, Value, Buckets:int
Map
+bind(in i : Item, in v : Value) : Boolean
+isBound(in i : Item) : Boolean explicit binding
<<bind>> (Customer, Order, 3)
implicit binding
Map<Customer, Order, 3> OrderMap
12