Class Diagram
Presented by
M Praneeth Kumar
Ist Year M.Sc., ICT-ARD
On
14.10.2014
Introduction
• A class diagram in the Unified Modelling language (UML) is a type of static
structure diagram that describes the structure of a system by showing
• system's classes,
• their attributes,
• operations (or methods), and
• the relationships among objects.
Class
•A class is a description of a set of objects that share the same
attributes, operations, relationships, and semantics.
•Graphically, a class is rendered as a rectangle, usually
including its name, attributes, and operations in
separate, designated compartments.
Example
Bank Account
Owner : String
Balance : Dollars = 0
Deposit (Amount : Dollars)
Withdrawal (Amount : Dollars)
Class Names
•The name of the class is the only required
tag in the graphical representation of a class.
• It always appears in the top-most
compartment.
Class Name
Attributes
Operations
Class Attributes
•An attribute is a named property of a
class that describes the object being modeled.
•In the class diagram, attributes appear in
the second compartment just below the
name-compartment.
Person
Name: String
Address: Address
Birth date : Date
SSN : ID
Class Attributes (Cont’d)
Attributes can be:
• + public
• # protected
• - private
• / derived
Person
+Name: String
#Address: Address
#Birth date : Date
/ Age : Date
-SSN : ID
Class Operations
•Operations describe the class behavior and appear in the third compartment.
Person
Name: String
Address: Address
Birth date : Date
SSN : ID
Eat
Sleep
Work
Play
Relationships between Classes
• In a class diagram, it is important to see the relationship between classes.
There are following types of relationships amongst classes
• Association
• Aggregation
• Generalization
Association Relationship
• An Association is a connection between classes, showing how one class relates to another.
• The association is shown as a line drawn between the classes.
• An Association Name can be given to the association to clarify the association between two
classes
An association relationship between two classes with role
names
Aggregation Relationship
• Aggregation is a special case of association used to model a “Whole to its Parts”
relationship.
• An Aggregate relationship can be thought of as a "Consists Of" relationship, where
the Whole consists of the Parts
Basic Aggregation relationship between class Car and class Wheel
Generalization Relationship
• The Generalization relationship indicates that one of the two related classes (the
subclass) is considered to be a specialized form of the other (the super type) and
super class is considered as 'Generalization' of subclass.
• In practice, this means that any instance of the subtype is also an instance of the
super class.
Class diagram showing generalization between one super class and two subclasses
Class diagram

Class diagram

  • 1.
    Class Diagram Presented by MPraneeth Kumar Ist Year M.Sc., ICT-ARD On 14.10.2014
  • 2.
    Introduction • A classdiagram in the Unified Modelling language (UML) is a type of static structure diagram that describes the structure of a system by showing • system's classes, • their attributes, • operations (or methods), and • the relationships among objects.
  • 3.
    Class •A class isa description of a set of objects that share the same attributes, operations, relationships, and semantics. •Graphically, a class is rendered as a rectangle, usually including its name, attributes, and operations in separate, designated compartments.
  • 4.
    Example Bank Account Owner :String Balance : Dollars = 0 Deposit (Amount : Dollars) Withdrawal (Amount : Dollars)
  • 5.
    Class Names •The nameof the class is the only required tag in the graphical representation of a class. • It always appears in the top-most compartment. Class Name Attributes Operations
  • 6.
    Class Attributes •An attributeis a named property of a class that describes the object being modeled. •In the class diagram, attributes appear in the second compartment just below the name-compartment. Person Name: String Address: Address Birth date : Date SSN : ID
  • 7.
    Class Attributes (Cont’d) Attributescan be: • + public • # protected • - private • / derived Person +Name: String #Address: Address #Birth date : Date / Age : Date -SSN : ID
  • 8.
    Class Operations •Operations describethe class behavior and appear in the third compartment. Person Name: String Address: Address Birth date : Date SSN : ID Eat Sleep Work Play
  • 9.
    Relationships between Classes •In a class diagram, it is important to see the relationship between classes. There are following types of relationships amongst classes • Association • Aggregation • Generalization
  • 10.
    Association Relationship • AnAssociation is a connection between classes, showing how one class relates to another. • The association is shown as a line drawn between the classes. • An Association Name can be given to the association to clarify the association between two classes An association relationship between two classes with role names
  • 11.
    Aggregation Relationship • Aggregationis a special case of association used to model a “Whole to its Parts” relationship. • An Aggregate relationship can be thought of as a "Consists Of" relationship, where the Whole consists of the Parts Basic Aggregation relationship between class Car and class Wheel
  • 12.
    Generalization Relationship • TheGeneralization relationship indicates that one of the two related classes (the subclass) is considered to be a specialized form of the other (the super type) and super class is considered as 'Generalization' of subclass. • In practice, this means that any instance of the subtype is also an instance of the super class. Class diagram showing generalization between one super class and two subclasses