UML - Basic Notations: Class Notation

You might also like

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 7

UML - Basic Notations

The Unified Modelling Language (UML) is a general-purpose, developmental, modeling


language in the field of software engineering, that is intended to provide a standard way to
visualize the design of a system.

UML is popular for its diagrammatic notations. We all know that UML is for visualizing,
specifying, constructing and documenting the components of software and non software
systems. The list is;
 Classes
 object
 Interface
 Collaboration
 Use case
 Active classes
 Components
 Nodes
Class notation:

Object notations:

eDAC-AUG2020 Batch
Interface Notation:

Collaboration Notation:

Relationships

A model is not complete unless the relationships between elements are described
properly. The Relationship gives a proper meaning to an UML model. Following are the
different types of relationships available in UML.
1. Dependency
2. Association
3. Generalization
4. Extensibility

Dependency Notation:

eDAC-AUG2020 Batch
Association Notation:
Association is a relationship between two objects. In other words, association defines the
multiplicity between objects. You may be aware of one-to-one, one-to-many, many-to-one,
many-to-many all these words define an association between objects. Aggregation is a special
form of association. Composition is a special form of aggregation.

Association - Association is a relationship between two objects.

Aggregation - A directional association between objects (shared


association). When an object ‘has-a’ another object, then you have got an aggregation
between them.

Composition- A restricted aggregation is called composition (Not


shared association). When an object contains the other object, if the contained object cannot
exist without the existence of container object, then it is called composition.

Generalization- Generalization uses a “is-a” relationship from a


specialization to the generalization class (Inheritance)

Realization- Realization is a relationship between the blueprint


class and the object containing its respective implementation level details. This as the
relationship between the interface and the implementing class.

Dependency- Change in structure or behaviour of a class affects


the other related class, then there is a dependency between those two classes. When one class
contains the other class it this happens.

eDAC-AUG2020 Batch
Generalization Notation:

Extensibility Notation:
Stereotypes (Represents new elements)
Tagged values (Represents new attributes)
Constraints (Represents the boundaries)

eDAC-AUG2020 Batch
Generalization, Specialization, and Inheritance:

Constraints:
A constraint is a packageable element which represents some condition, restriction or
assertion related to some element (that owns the constraint) or several elements. Constraints
are commonly used for various elements on class diagrams.

Bank account constraints - non empty owner and positive balance

Comments:

eDAC-AUG2020 Batch
Compare Aggregation Association & Composition:
Association is a relationship where all objects have their own lifecycle and there is no owner.
Let's take an example of Teacher and Student. Multiple students can associate with
single teacher and single student can associate with multiple teachers, but there is no
ownership between the objects and both have their own lifecycle. Both can be created
and deleted independently.

Aggregation is a specialised form of Association where all objects have their own lifecycle,
but there is ownership and child objects can not belong to another parent object.
Let's take an example of Department and teacher. A single teacher can not belong to
multiple departments, but if we delete the department, the teacher object will not be
destroyed. We can think about it as a “has-a” relationship.

Composition is again specialised form of Aggregation and we can call this as a “death”
relationship. It is a strong type of Aggregation. Child object does not have its lifecycle and if
parent object is deleted, all child objects will also be deleted.
Let's take again an example of relationship between House and Rooms. House can
contain multiple rooms - there is no independent life of room and any room can not
belong to two different houses. If we delete the house - room will automatically be
deleted.

eDAC-AUG2020 Batch
Relationship Reading:

The above relationships are read as follows:

 Dependency : class A uses class B


 Aggregation : class A has a class B
 Composition : class A owns a class B
 Inheritance : class B is a Class A (or class A is extended by class B)
 Realization : class B realizes Class A (or class A is realized by class B)

A Class can be instantiated but an Interface cannot be instantiated You can create an instance
of an Object that implements the Interface. A Class is a full body entity with members,
methods along with their definition and implementation.

eDAC-AUG2020 Batch

You might also like