Class Diagrams PPT5
Class Diagrams PPT5
Class Diagrams PPT5
Class diagram is a static type structure diagram that describes the structure of a
system by showing system’s classes, attributes and operations, and relationship
among the objects.
Purpose of the class diagram
➢ This is the only UML that can appropriately depict various aspects of the
OOPs concept.
➢ Proper design and analysis of the applications can be faster and efficient.
Operations
- addInfo(var1,var2) :Void Also called methods or functions.
+ cal_mark() :Void
+ getInfo() :Void Allow us to specify any behavioral feature of class.
Visibility
<<Customer>>
Customer Underlined if it’s Static.
✓ public +
- Id :Int
Optional to indicate allowable null value.
- add :String
✓ private - + name :String
+ dob :Int Ordered to present ‘em in a particular order.
✓ protected # +/ age :Int
In case of Abstract it’s written either in Italic
✓ package ~ # get_Id() :Int {ordered} or inside these << >> symbols.
- product() :bool [1..*]
✓ derived / + show() :Void Multiplicity denoted by [number..*]
Features of a class
▪ Structural Features (attributes): is a typed feature of a class that specifies the structure of
instances of the class.
▪ Behavioral Features (Methods): is a feature of a class that specifies an aspect of the behavior
of its instances.
Types of relationship
1) Association
2) Multiplicity
3) Aggregation
4) Composition
5) Generalization/Inheritance
6) Dependency
7) Constraints
Association
An Association is a line connector with label association name connects multiple classes and
denotes a logical connection. Association can be binary or N-ary, a class may Reflexive.
Students Course
chooses
Attributes Attributes
Methods Methods
Professor Book
1..* wrote 0..*
Attributes Attributes
Methods Methods
Multiplicity
0..1 , n, 0..* , 1..* , m..n
A1 B1 A4 B4
Both ends of association are unspecified navigability A4 is not navigable while B4 is navigable from A4
A2 B2 A5 B5
A2 has unspecified navigability while B2 is navigable from A2 A5 is navigable from B5 and B5 is navigable from A5
A3 B3 A6 B6
A3 is not navigable while B3 as unspecified navigability A6 is not navigable from B6and B6 is not navigable from A6
Arity
Each associations has a specific arity as it could relate two or more classes.
Binary association:
N-ary association: It is drawn as diamond (larger than a terminator on a line) with a solid line
for each association end connecting the diamond to the classifier that is the end’s type.
design
car company Usman Valentina
friend
Rose
Aggregation
Aggregation is a special type of weaker whole – part (has) association relationship between two
classes where the part can exist separately from the whole. It is depicted as an association
decorated with a hollow diamond at the aggregate end of the association line.
College Studenst
1
0..*
Attributes Attributes
Methods Methods
1 1..*
Copy Pages
1
Computer Mouse
1 1..*
Team Player
1 1..*
Hospital Doctor
Composition
Composition is a special type of whole – part (contain) relationship between two classes where
the part cannot exist on its own separately from the whole. It is depicted as a binary association
decorated with a filled black diamond at the aggregate end.
Building Office
1 1..*
Attributes Attributes
Methods Methods
1 1..*
Pound Fish
1 1..*
Forest Tree
1 0..*
Folder Files
1 1..*
Forest Animal
Generalization
A generalization is shown as a line with a hollow triangle as an arrowhead.
Account Account
Animal
Attribute
Method
Temporary Permanent
Employee Employee
Manager
Consultant
Director Permanent
Consultant
Manager Manager
Dependency
Dependency is a directed relationship which is used to show that some UML element or a set
of elements requires, needs or depends on other model elements for specification or
implementation.
Dependency relationship is the weakest relationship that exists between two classes if the
changes to the definition of one may cause a change into the other but not the vice-versa.
Schedule Meeting
- scheduleIn - topic
+ scheduleGrp + time
- date
Schedule(Meeting) setMeeting()
Constraints
Vendor should be
listed in NSE
Purchased from
Stock Vendor
* *
Constraint on Vendor List
Activates Activates
Heater Cooler