2. What is a Class Diagram?
A Class Diagram is a diagram describing the structure
of a system.
It consists the :
Classes.
Attributes.
Operations.
Relationships among the classes.
3. Classes
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.
ClassName
attributes
operations
4. 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.
ClassName
attributes
operations
5. Class Attributes
should include all fields of the object.
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.
Example;
a Person’s age can be computed from his birth date.
/ age : Date
Person
name : String
address : Address
birthdate : Date
/ age : Date
ssn : Id
6. Class Attributes (Cont..)
Attributes can be:
+ public.
# protected.
- private.
/ derived.
Person
+ name : String
# address : Address
# birthdate : Date
/ age : Date
- ssn : Id
7. Class Operations
Operations describe the class behavior and appear in
the third compartment.
Person
name : String
address : Address
birthdate : Date
ssn : Id
eat
sleep
work
play
8. Relationships
There are three types of relationships you can
set up between classes.
Dependencies
Generalizations
Associations
9. Dependency Relationships
A dependency indicates a semantic relationship
between two or more elements.
Symbolized by dotted line.
10. Generalization Relationships
A generalization connects a subclass to its superclass.
Generalization provides the capability to create
supper classes that encapsulate structure and behavior
common to several classes.
specialization provides the ability to create subclasses
that represent refinement to the supper-class.t.
12. Association Relationships
If two classes in a model need to communicate with each
other, there must be link between them.
Here , an association is instructs
Instructor Student
instructs
13. Association Relationships(Cont..)
We can indicate the multiplicity of an association by
adding multiplicity adornments to the line denoting the
association.
The example indicates that a Student has one or more
Instructors:
Student Instructor
1..*