Sie sind auf Seite 1von 10

Lab 2

Class Diagram
Theory:
A class diagram in the Unified Modeling Language (UML) is a type of static structure
diagram that describes the structure of a system by showing the system's classes, their
attributes, operations (or methods), and the relationships among objects.
Class diagram is not only used for visualizing, describing and documenting different
aspects of a system but also for constructing executable code of the software application.
The class diagram describes the attributes and operations of a class and also the
constraints imposed on the system. The class diagrams are widely used in the modelling
of object oriented systems because they are the only UML diagrams which can be
mapped directly with object oriented languages.
Purpose:
The purpose of the class diagram is to model the static view of an application. The class
diagrams are the only diagrams which can be directly mapped with object oriented
languages and thus widely used at the time of construction.
The UML diagrams like activity diagram, sequence diagram can only give the sequence
flow of the application but class diagram is a bit different. So it is the most popular
UML diagram in the coder community.
So the purpose of the class diagram can be summarized as:

Analysis and design of the static view of an application.

Describe responsibilities of a system.

Base for component and deployment diagrams.

Forward and reverse engineering.

Relationship:
A relationship is a general term covering the specific types of logical connections found
on class and object diagrams. UML defines the following relationships:
Instance-level relationships:
Dependency
A dependency is a semantic connection between dependent and independent model
elements. It exists between two elements if changes to the definition of one element (the
server or target) may cause changes to the other (the client or source). This association is
uni-directional.

Association

Class diagram example of association between two classes


An association represents a family of links. A binary association (with two ends) is
normally represented as a line. An association can link any number of classes. An
association with three links is called a ternary association. An association can be named,
and the ends of an association can be adorned with role names, ownership indicators,
multiplicity, visibility, and other properties.

Aggregation

Class diagram showing Aggregation between two classes

Aggregation is a variant of the "has a" association relationship; aggregation is more


specific than association. It is an association that represents a part-whole or part-of
relationship. As shown in the image, a Professor 'has a' class to teach
In UML, it is graphically represented as a hollow diamond shape on the containing class
with a single line that connects it to the contained class. Example: Library has Students
and books. Here the student can exist without library, the relation between student and
library is aggregation.

Composition

Class diagram showing Composition between two classes at top and Aggregation
between two classes at bottom
Composition is a stronger variant of the "has a" association relationship; composition is
more specific than aggregation.
The UML graphical representation of a composition relationship is a filled diamond
shape on the containing class end of the lines that connect contained class(es) to the
containing class.

Class-level relationships:
Generalization:
It indicates that one of the two related classes (the subclass) is considered to be a
specialized form of the other (the super type) and the superclass is considered a
Generalization of the subclass. In practice, this means that any instance of the subtype is
also an instance of the superclass.

Realization:
In UML modelling, a realization relationship is a relationship between two model
elements, in which one model element (the client) realizes (implements or executes) the
behavior that the other model element (the supplier) specifies.
The UML graphical representation of a Realization is a hollow triangle shape on the
interface end of the dashed line (or tree of lines) that connects it to one or more
implementers.
Multiplicity:
This association relationship indicates that (at least) one of the two related classes make
reference to the other. This relationship is usually described as "A has a B" (a mother cat
has kittens, kittens have a mother cat).

0..1

No instances (rare)

No instances, or one instance

Exactly one instance

0..*

Zero or more instances

Zero or more instances

1..*

One or more instances

Class diagrams
1. College Management System

2. Library Management System

3. Order Processing System

4. Android Bluetooth Chat (Minor project)

Discussion:

In this way, class diagram was drawn for College Management System, Library
Management System, Order Processing System and Android Bluetooth Chat using Argo
UML. Class diagram is a type of static structure diagram that simply describes the
structure of the system, divided in classes with different connections and relationships. It
forces the programmer to think out the structure of his/her classes and how they will
interact with each other before actually writing any code. It provides a blueprint for
maintenance programmers to get an overview of how the application is structured before
examining the actual code. It describes the functionalities performed by the system.

Conclusion:
Hence, from this laboratory we got familiarized with class diagrams and we have learned
to design class diagram in Argo UML.