UNIT 2
1. Class
A class is a template or description for similar objects. Similar means objects have same
attributes, operations, responsibilities and semantics. These classes may belong to problem
domain or may belong to the solution or implementation for the problem. The graphical
representation of a class in UML is a rectangle.
Example:
2. Relationships in UML
It depict a connection between several things, such as structural, behavioural, or grouping
things in the unified modelling language. Since it is termed as a link, it demonstrates how
things are interrelated to each other at the time of system execution
2.1 Dependency- Whenever there is a change in either the structure or the behavior of the
class that affects the other class, such a relationship is termed as a dependency. Or, simply,
we can say a class contained in other class is known as dependency. It is a unidirectional
relationship.
2.2 Association- Association is a structural relationship that represents how two entities are
linked or connected to each other within a system. It can form several types of associations,
such as one-to-one, one-to-many, many-to-one, and many-to-many. A ternary association is
one that constitutes three links. It portrays the static relationship between the entities of two
classes.
An association can be categorized into four types of associations, i.e., bi-directional,
unidirectional, aggregation (composition aggregation), and reflexive, such that an aggregation
is a special form of association and composition is a special form of aggregation. The mostly
used associations are unidirectional and bi-directional.
,2.3 Aggregation- An aggregation is a special form of association. It portrays a part-of
relationship. It forms a binary relationship, which means it cannot include more than two
classes. It is also known as Has-a relationship. It specifies the direction of an object
contained in another object. In aggregation, a child can exist independent of the parent.
2.4 Composition- In a composition relationship, the child depends on the parent. It forms a
two-way relationship. It is a special case of aggregation. It is known as Part-of relationship.
2.5 Generalization- The generalization relationship implements the object-oriented concept
called inheritance or is-a relationship. It exists between two objects (things or entities), such
that one entity is a parent (superclass or base class), and the other one is a child (subclass or
derived class). These are represented in terms of inheritance. Any child can access, update, or
inherit the functionality, structure, and behavior of the parent.
3. Common mechanism in UML
3.1. Specification- Provides a textual statement describing interesting aspects of a system.
3.2. Adornments- Textual/graphical items added to the basic notation of an element.
They are used for explicit visual representation of those aspects of an element that are beyond
the most important.
Examples: The basic notation of association is line, but this could be adorned with additional
details, such as the role names and multiplicity of each end.
,3.3. Common Divisions- In modeling, object-oriented systems get divided in multiple ways.
For example, class vs. object, interface vs. implementation. An object uses the same symbol
as its class with its name underlined.
3.4. Extensibility Mechanisms- Extensibility mechanisms allow extending the language in
controlled ways. They include Stereotypes, Tagged Values and Constraints.
3.4.1Stereotypes- Stereotypes are used to create new building blocks from existing blocks.
New building blocks are domain-specific. Stereotypes are used to extend the vocabulary of a
system. Graphically represented as a name enclosed by guillemots (« »)
3.4.2 Tagged Values- Tagged values are used to add to the information of the element (not of
its instances). Stereotypes help to create new building blocks, whereas tagged values help to
create new attributes. These are commonly used to specify information relevant to code
generation, configuration management and so on.
3.4.3 Constraints- Constraints are used to create rules for the model. Rules that impact the
behavior of the model, and specify conditions that must be met. Can apply to any element in
the model, i.e., attributes of a class, relationship. Graphically represented as a string enclosed
, by braces {....} and placed near the associated elements or connected to that elements by
dependency relationships.
4. Class diagram
The class diagram depicts a static view of an application. It represents the types of objects
residing in the system and the relationships between them. A class consists of its objects, and
also it may inherit from other classes. A class diagram is used to visualize, describe,
document various different aspects of the system, and also construct executable software
code. It shows the attributes, classes, functions, and relationships to give an overview of the
software system. It constitutes class names, attributes, and functions in a separate
compartment that helps in software development. Since it is a collection of classes, interfaces,
associations, collaborations, and constraints, it is termed as a structural diagram.
4.1 Purpose
The main purpose of class diagrams is to build a static view of an application. It is the only
diagram that is widely used for construction, and it can be mapped with object-oriented
languages. It is one of the most popular UML diagrams. Following are the purpose of class
diagrams given below:
It analyses and designs a static view of an application.
It describes the major responsibilities of a system.
It is a base for component and deployment diagrams.
It incorporates forward and reverse engineering.
4.2 Benefits
It can represent the object model for complex systems.
It reduces the maintenance time by providing an overview of how an application is
structured before coding.
It provides a general schematic of an application for better understanding.
It represents a detailed chart by highlighting the desired code, which is to be
programmed.
It is helpful for the stakeholders and the developers.
4.3 Vital components
The class diagram is made up of three sections:
1. Class
A class is a template or description for similar objects. Similar means objects have same
attributes, operations, responsibilities and semantics. These classes may belong to problem
domain or may belong to the solution or implementation for the problem. The graphical
representation of a class in UML is a rectangle.
Example:
2. Relationships in UML
It depict a connection between several things, such as structural, behavioural, or grouping
things in the unified modelling language. Since it is termed as a link, it demonstrates how
things are interrelated to each other at the time of system execution
2.1 Dependency- Whenever there is a change in either the structure or the behavior of the
class that affects the other class, such a relationship is termed as a dependency. Or, simply,
we can say a class contained in other class is known as dependency. It is a unidirectional
relationship.
2.2 Association- Association is a structural relationship that represents how two entities are
linked or connected to each other within a system. It can form several types of associations,
such as one-to-one, one-to-many, many-to-one, and many-to-many. A ternary association is
one that constitutes three links. It portrays the static relationship between the entities of two
classes.
An association can be categorized into four types of associations, i.e., bi-directional,
unidirectional, aggregation (composition aggregation), and reflexive, such that an aggregation
is a special form of association and composition is a special form of aggregation. The mostly
used associations are unidirectional and bi-directional.
,2.3 Aggregation- An aggregation is a special form of association. It portrays a part-of
relationship. It forms a binary relationship, which means it cannot include more than two
classes. It is also known as Has-a relationship. It specifies the direction of an object
contained in another object. In aggregation, a child can exist independent of the parent.
2.4 Composition- In a composition relationship, the child depends on the parent. It forms a
two-way relationship. It is a special case of aggregation. It is known as Part-of relationship.
2.5 Generalization- The generalization relationship implements the object-oriented concept
called inheritance or is-a relationship. It exists between two objects (things or entities), such
that one entity is a parent (superclass or base class), and the other one is a child (subclass or
derived class). These are represented in terms of inheritance. Any child can access, update, or
inherit the functionality, structure, and behavior of the parent.
3. Common mechanism in UML
3.1. Specification- Provides a textual statement describing interesting aspects of a system.
3.2. Adornments- Textual/graphical items added to the basic notation of an element.
They are used for explicit visual representation of those aspects of an element that are beyond
the most important.
Examples: The basic notation of association is line, but this could be adorned with additional
details, such as the role names and multiplicity of each end.
,3.3. Common Divisions- In modeling, object-oriented systems get divided in multiple ways.
For example, class vs. object, interface vs. implementation. An object uses the same symbol
as its class with its name underlined.
3.4. Extensibility Mechanisms- Extensibility mechanisms allow extending the language in
controlled ways. They include Stereotypes, Tagged Values and Constraints.
3.4.1Stereotypes- Stereotypes are used to create new building blocks from existing blocks.
New building blocks are domain-specific. Stereotypes are used to extend the vocabulary of a
system. Graphically represented as a name enclosed by guillemots (« »)
3.4.2 Tagged Values- Tagged values are used to add to the information of the element (not of
its instances). Stereotypes help to create new building blocks, whereas tagged values help to
create new attributes. These are commonly used to specify information relevant to code
generation, configuration management and so on.
3.4.3 Constraints- Constraints are used to create rules for the model. Rules that impact the
behavior of the model, and specify conditions that must be met. Can apply to any element in
the model, i.e., attributes of a class, relationship. Graphically represented as a string enclosed
, by braces {....} and placed near the associated elements or connected to that elements by
dependency relationships.
4. Class diagram
The class diagram depicts a static view of an application. It represents the types of objects
residing in the system and the relationships between them. A class consists of its objects, and
also it may inherit from other classes. A class diagram is used to visualize, describe,
document various different aspects of the system, and also construct executable software
code. It shows the attributes, classes, functions, and relationships to give an overview of the
software system. It constitutes class names, attributes, and functions in a separate
compartment that helps in software development. Since it is a collection of classes, interfaces,
associations, collaborations, and constraints, it is termed as a structural diagram.
4.1 Purpose
The main purpose of class diagrams is to build a static view of an application. It is the only
diagram that is widely used for construction, and it can be mapped with object-oriented
languages. It is one of the most popular UML diagrams. Following are the purpose of class
diagrams given below:
It analyses and designs a static view of an application.
It describes the major responsibilities of a system.
It is a base for component and deployment diagrams.
It incorporates forward and reverse engineering.
4.2 Benefits
It can represent the object model for complex systems.
It reduces the maintenance time by providing an overview of how an application is
structured before coding.
It provides a general schematic of an application for better understanding.
It represents a detailed chart by highlighting the desired code, which is to be
programmed.
It is helpful for the stakeholders and the developers.
4.3 Vital components
The class diagram is made up of three sections: