You are on page 1of 10

UNIFIED MODELING LANGUAGE

(UML)
Class and Objects Diagrams

Dr. Myat Mon Kyaw


Faculty of Information Science
University of Computer Studies (Yangon)

1
Outlines

 Data Types  Aggregation


 Classes  Composition
 Describing Objects With Classes  Association Classes
 Associations  N-ary Associations
 Generalization And Specialization  Qualified Associations
 Inheritance Of Attributes And  Interfaces
Operations  Templates

2
Describing Objects With Classes
 Every object contains certain pieces of data and a number of operations
 All the objects of a given class contain
the same data items, though with differing actual values, and

the same operations


 This common structure is defined by a number of features in the class
including
attributes, which describe the data items found in its instances

operations
3
Attributes
 Attributes describe data fields in a class and can have a type which defines the
values that an object can hold.
 By default attribute have instance scope , each instance can have a distinct value.
 An attribute with class scope has one value shared by all instances of the class
(‘static’)
 Attributes with class scope are underlined.

Figure 8.6 Attribute and attribute values


 Classes are not normally used as attribute types.
 A better way to model this situation would be to use an association between
classes.
4
Attribute Multiplicity
 Attributes can also have an explicitly defined multiplicity.
 Defines how many values an object stores for a attribute.
 default is ‘exactly 1’
 implying that each instance of the class stores exactly one value for each
attribute
 ‘optional’ multiplicity shows possible not store a data value for it
 Arrays modelled by ‘many’ multiplicity

Figure 8.8 Attribute multiplicity


5
Operations and operation scope
 Operations define behaviour provided by every instance of the class.
 Defined in optional lower section of class icon and can be omitted.
 Parameters and return types optional
 Operations can have instance or class scope
 Instance scope
 Apply to individual instances of the class and can only be called once an
instance has been created
 Class Scope
 Operations can be called independently of any instance of the class, but as a
result they only have access to attributes that also have class scope
 static functions and constructors shown with class scope
6
Constructors

 Operations that create new instances of a class


 Class scope in UML
 Slightly different properties from other operations
 Constructor has the same name as the class

Figure 8.9 A module class with attributes and operations


7
Identifying Objects
 Object identities are implicit
 Not the same as an attribute
 Objects can share all attribute values and still be distinct
 Many classes will have attributes with unique values
 Corresponding to real-world identifiers
 UML notation does not specify uniqueness

Figure 8.11Distinct object with equal state


8
Visibility of Class Features
 Attributes and operations can have a visibility
parallel to Java/C++ access levels
 Specifies the extent to which the feature is available to other classes
 UML defines four levels of visibility:
public (+): visible to all objects

package (~): visible to objects in same package

protected (#): visible to instances of subclasses

private (-): visible only in same object

9
Next Lecture
Thank You.

Associations

10

You might also like