You are on page 1of 7

Experiment No.

: 3a
1. Aim: Develop a Classes, Relationships, Class Diagrams, Advanced Classes and
Relationship

2. What will you learn by performing this experiment?


We will learn how to identify classes and advanced classes from the Problem statement,
understanding relationships between the classes and how to represent the objects in the
class using an object diagram.

3. Hardware & Software Required: PC Desktop, Rational Rose

4. Theory:
The class identification is done from project specifications or SRS. Nouns are potential
classes, objects, fields .Verbs are potential methods or responsibilities of a class.

An UML class diagram is a:

1. picture of the classes in an OO system.

2. their fields and methods

3. how various classes and related and how they interact or inherit from each other

UML representation of a Class:

Class name is written on the top of box. Write < > on top of interfaces' names. Use
italics for an abstract class name.

The attributes should include all fields of the object.

Operations / methods should mention all the functions/ actions taken by the class.
Example of a Class is as given below:
Fig. 1 UML Representation of a Class.

Class attributes (= fields)

1. attributes are fields, instance variables.

2. Visibility(access specifier) name is given as: type [count] = default_value.

3. visibility types and symbols:

+ public

# protected

- private

~ package (default)

/ derived

Always underline static attributes.

Class operations / methods:

Representation: visibility name (parameters) : return_type

Visibility for methods is as shown:

+ public
# protected

- private

~ package (default)

Always underline static methods. Omit return_type on constructors and when return type
is void.

Relationships in Class Diagrams:

1. Generalization: It represents an inheritance relationship. It helps to represent


inheritance between classes and interface implementation.

2. Association: a usage relationship. It’s types are: dependency, aggregation and


composition.

1. Generalization (inheritance) relationships:

The hierarchies in class diagram are drawn top-down with arrows pointing upward to
parent. The line/arrow styles indicate whether parent is a(n) class(solid line, black
arrow), abstract class(solid line, white arrow) or interface(dashed line, white arrow).

Fig 2 Generalization

2. Associational Relationships:
It shows three important things:

1. Multiplicity (how many are used). It is either one to many, Many to One, or Many to
many.

2. Name

3. Navigability ( direction)

Fig. 3 Associational Relationship

3. Multiplicity of Associations:

4. Association Types:
1. Aggregation: It is also known as : “is part of” relationship. Its symbols is a clear white
diamond.

Fig. 4 Aggreagtion

2. Composition: It is also known as “is entirely made of” – stronger version of


aggregation – the parts live and die with the whole. It is symbolized by a black
diamond.

Fig. 5 Composition

3. Dependency: It is also called “uses temporarily”. Its symbol is a dotted line. It is used
as an implementation detail, not an intrinsic part of that object's state.
Fig 6 Dependency

Fig. 7 Class diagram example

So the following class diagram has been drawn considering all the points mentioned above:

Where to use Class Diagrams?


Class diagram is a static diagram and it is used to model static view of a system. The static view
describes the vocabulary of the system.

Class diagram is also considered as the foundation for component and deployment diagrams.
Class diagrams are not only used to visualize the static view of the system but they are also used
to construct the executable code for forward and reverse engineering of any system.
Generally UML diagrams are not directly mapped with any object oriented programming
languages but the class diagram is an exception.

Class diagram clearly shows the mapping with object oriented languages like Java, C++ etc. So
from practical experience class diagram is generally used for construction purpose.

So in a brief, class diagrams are used for:

 Describing the static view of the system.

 Showing the collaboration among the elements of the static view.

 Describing the functionalities performed by the system.

 Construction of software applications using object oriented languages.

5. Procedure/ Program:

6. Results:

7. Conclusion and Discussion:

Thus class diagrams have been understood.

8. QUIZ / Viva Questions:

 What is UML?
 What are the advantages of UML diagrams?
 How these modeling diagrams would help in software application development?
 How do we represent private, public and protected in class diagrams?

9. References:

1. “Software Engineering : A Practitioner‟s Approach” by Roger Pressman Sixth Edition


2. “Software Engineering” by Ian Sommerville, Pearson
3. “Software Engineering : A Precise Approach” Pankaj Jalote , Wiley India
4. “System Analysis and Design” Alan Dennis, Wixom, R M Roth – Wiley India
5. “Software Engineering : Principles and Practice” by Waman S Jawadekar

You might also like