Duration : 3 hrs
1
Ramakant Soni
Assistant Professor
Dept. of Computer Science
B K Birla Institute of Engineering & Technology, Pilani, India
Ramakant Soni @ BKBIET PIlani
Class Diagram Overview
Class diagram is one type of UML structure diagram
which shows structure of the designed system at the
level of classes and interfaces, shows their features,
constraints and their relationships - associations,
generalizations, dependencies, etc.
Ramakant Soni @ BKBIET PIlani 2
ClassName
attributes
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,
operations
attributes, and operations in separate,
designated compartments.
Ramakant Soni @ BKBIET PIlani
ClassName
attributes
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.
operations
Ramakant Soni @ BKBIET PIlani
Person
name : String
address : Address
birthdate : Date
An attribute is a named property of a class
that describes the object being modeled.
In the class diagram, attributes appear in thebirthdate : Date
ssn : Id
In the class diagram, attributes appear in the
second compartment just below the name-
compartment.
Ramakant Soni @ BKBIET PIlani
Person
name : String
address : Address
Attributes are usually listed in the form:
attributeName : Type
A derived attribute is one that can be
computed from other attributes, but doesn’t
actually exist.
address : Address
birthdate : Date
/ age : Date
ssn : Id
For example, a Person’s age can be
computed from his birth date. A derived
attribute is designated by a preceding ‘/’ as
in:
/ age : Date
Ramakant Soni @ BKBIET PIlani
Person
+ name : String
# address : Address
Attributes can be:
+ public
# protected
- private
# address : Address
# birthdate : Date
/ age : Date
- ssn : Id
- private
/ derived
Ramakant Soni @ BKBIET PIlani
Person
name : String
address : Address
birthdate : Datebirthdate : Date
ssn : Id
Eat()
Sleep()
Work()
Play()
Operations describe the class behavior
and appear in the third compartment.
Ramakant Soni @ BKBIET PIlani
A class may also include its responsibilities in a class diagram.
A responsibility is a contract or obligation of a class to perform a
particular service.
SmokeAlarm
Responsibilities
-- sound alert and notify guard station
when smoke is detected.
-- indicate battery state
Ramakant Soni @ BKBIET PIlani
In UML, object interconnections (logical or physical), are modeled as
relationships.
There are five kinds of relationships in UML:
• dependencies
• generalizations
• associations
•Inheritence
•realization
Ramakant Soni @ BKBIET PIlani
A dependency indicates a semantic relationship between two or
more elements. The dependency from CourseSchedule to Course
exists because Course is used in both the add and remove operations
of CourseSchedule.
CourseSchedule
add(c : Course)
remove(c : Course)
Course
Ramakant Soni @ BKBIET PIlani
Person
A generalization connects a subclass to its
super class.
It denotes an inheritance of attributes and
behavior from the super class to thebehavior from the super class to the
subclass and indicates a specialization in
the subclass of the more general super
class.
Student
Ramakant Soni @ BKBIET PIlani
Student
UML permits a class to inherit from multiple superclasses, although some
programming languages (e.g., Java) do not permit multiple
inheritance.
Employee
TeachingAssistant
Ramakant Soni @ BKBIET PIlani
If two classes in a model need to communicate with each other, there
must be link between them.
An association denotes that link.
InstructorStudent
Ramakant Soni @ BKBIET PIlani

Class diagram- UML diagram

  • 1.
    Duration : 3hrs 1 Ramakant Soni Assistant Professor Dept. of Computer Science B K Birla Institute of Engineering & Technology, Pilani, India Ramakant Soni @ BKBIET PIlani
  • 2.
    Class Diagram Overview Classdiagram is one type of UML structure diagram which shows structure of the designed system at the level of classes and interfaces, shows their features, constraints and their relationships - associations, generalizations, dependencies, etc. Ramakant Soni @ BKBIET PIlani 2
  • 3.
    ClassName attributes 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, operations attributes, and operations in separate, designated compartments. Ramakant Soni @ BKBIET PIlani
  • 4.
    ClassName attributes The name ofthe class is the only required tag in the graphical representation of a class. It always appears in the top-most compartment. operations Ramakant Soni @ BKBIET PIlani
  • 5.
    Person name : String address: Address birthdate : Date An attribute is a named property of a class that describes the object being modeled. In the class diagram, attributes appear in thebirthdate : Date ssn : Id In the class diagram, attributes appear in the second compartment just below the name- compartment. Ramakant Soni @ BKBIET PIlani
  • 6.
    Person name : String address: Address Attributes are usually listed in the form: attributeName : Type A derived attribute is one that can be computed from other attributes, but doesn’t actually exist. address : Address birthdate : Date / age : Date ssn : Id For example, a Person’s age can be computed from his birth date. A derived attribute is designated by a preceding ‘/’ as in: / age : Date Ramakant Soni @ BKBIET PIlani
  • 7.
    Person + name :String # address : Address Attributes can be: + public # protected - private # address : Address # birthdate : Date / age : Date - ssn : Id - private / derived Ramakant Soni @ BKBIET PIlani
  • 8.
    Person name : String address: Address birthdate : Datebirthdate : Date ssn : Id Eat() Sleep() Work() Play() Operations describe the class behavior and appear in the third compartment. Ramakant Soni @ BKBIET PIlani
  • 9.
    A class mayalso include its responsibilities in a class diagram. A responsibility is a contract or obligation of a class to perform a particular service. SmokeAlarm Responsibilities -- sound alert and notify guard station when smoke is detected. -- indicate battery state Ramakant Soni @ BKBIET PIlani
  • 10.
    In UML, objectinterconnections (logical or physical), are modeled as relationships. There are five kinds of relationships in UML: • dependencies • generalizations • associations •Inheritence •realization Ramakant Soni @ BKBIET PIlani
  • 11.
    A dependency indicatesa semantic relationship between two or more elements. The dependency from CourseSchedule to Course exists because Course is used in both the add and remove operations of CourseSchedule. CourseSchedule add(c : Course) remove(c : Course) Course Ramakant Soni @ BKBIET PIlani
  • 12.
    Person A generalization connectsa subclass to its super class. It denotes an inheritance of attributes and behavior from the super class to thebehavior from the super class to the subclass and indicates a specialization in the subclass of the more general super class. Student Ramakant Soni @ BKBIET PIlani
  • 13.
    Student UML permits aclass to inherit from multiple superclasses, although some programming languages (e.g., Java) do not permit multiple inheritance. Employee TeachingAssistant Ramakant Soni @ BKBIET PIlani
  • 14.
    If two classesin a model need to communicate with each other, there must be link between them. An association denotes that link. InstructorStudent Ramakant Soni @ BKBIET PIlani