Class diagram- UML diagram

ramakantsoni 2,210 views 14 slides Apr 26, 2015
Slide 1
Slide 1 of 14
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14

About This Presentation

Descriptive slides for the Class Diagrams in UML


Slide Content

Duration : 3 hrs
1
RamakantSoni
Assistant Professor
Dept. of Computer Science
B K Birla Institute of Engineering & Technology, Pilani, India
Ramakant Soni @ BKBIET PIlani

Class Diagram Overview
ClassdiagramisonetypeofUMLstructurediagram
whichshowsstructureofthedesignedsystematthe
levelofclassesandinterfaces,showstheirfeatures,
constraintsandtheirrelationships-associations,
generalizations,dependencies,etc.
Ramakant Soni @ BKBIET PIlani 2

ClassName
attributes
Aclassisadescriptionofasetofobjects
thatsharethesameattributes,operations,
relationships,andsemantics.
Graphically,aclassisrenderedasa
rectangle,usuallyincludingitsname,
attributes,andoperationsinseparate,
operations
attributes,andoperationsinseparate,
designatedcompartments.
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
Anattributeisanamedpropertyofaclass
thatdescribestheobjectbeingmodeled.
Intheclassdiagram,attributesappearinthebirthdate : Date
ssn : Id
Intheclassdiagram,attributesappearinthe
secondcompartmentjustbelowthename-
compartment.
Ramakant Soni @ BKBIET PIlani

Person
name : String
address : Address
Attributesareusuallylistedintheform:
attributeName:Type
Aderivedattributeisonethatcanbe
computedfromotherattributes,butdoesn’t
actuallyexist.
address : Address
birthdate: Date
/ age : Date
ssn : Id
Forexample,aPerson’sagecanbe
computedfromhisbirthdate.Aderived
attributeisdesignatedbyapreceding‘/’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 dependencyindicates a semantic relationship between two or
more elements. The dependency from CourseScheduleto Course
exists because Courseis used in both the addand removeoperations
of CourseSchedule.
CourseSchedule
add(c : Course)
remove(c : Course)
Course
Ramakant Soni @ BKBIET PIlani

Person
Ageneralizationconnectsasubclasstoits
superclass.
Itdenotesaninheritanceofattributesand
behaviorfromthesuperclasstothebehaviorfromthesuperclasstothe
subclassandindicatesaspecializationin
thesubclassofthemoregeneralsuper
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 associationdenotes that link.
InstructorStudent
Ramakant Soni @ BKBIET PIlani