Chapter II Structural Modeling
Chapter II Structural Modeling
The elements are like components which can be associated in different ways to make a complete UML
picture, which is known as diagram. Thus, it is very important to understand the different diagrams to
implement the knowledge in real-life systems.
Any complex system is best understood by making some kind of diagrams or pictures. These diagrams
have a better impact on our understanding. If we look around, we will realize that the diagrams are not a
new concept but it is used widely in different forms in different industries.
We prepare UML diagrams to understand the system in a better and simple way. A single diagram is not
enough to cover all the aspects of the system. UML defines various kinds of diagrams to cover most of
the aspects of a system.
You can also create your own set of diagrams to meet your requirements. Diagrams are generally made in
an incremental and iterative way.
There are two broad categories of diagrams and they are again divided into subcategories −
• Structural Diagrams
• Behavioral Diagrams
• Class diagram
• Object diagram
• Component diagram
• Deployment diagram
Class diagrams are the most common diagrams used in UML. Class diagram consists of classes, interfaces,
associations, and collaboration. Class diagrams basically represent the object-oriented view of a system,
which is static in nature.
Active class is used in a class diagram to represent the concurrency of the system.
Class diagram represents the object orientation of a system. Hence, it is generally used for development
purpose. This is the most widely used diagram at the time of system construction.
Object Diagram
Object diagrams can be described as an instance of class diagram. Thus, these diagrams are more close to
real-life scenarios where we implement a system.
Object diagrams are a set of objects and their relationship is just like class diagrams. They also represent
the static view of the system.
The usage of object diagrams is similar to class diagrams but they are used to build prototype of a system
from a practical perspective.
Component Diagram
Component diagrams represent a set of components and their relationships. These components consist of
classes, interfaces, or collaborations. Component diagrams represent the implementation view of a system.
During the design phase, software artifacts (classes, interfaces, etc.) of a system are arranged in different
groups depending upon their relationship. Now, these groups are known as components.
Finally, it can be said component diagrams are used to visualize the implementation.
Deployment Diagram
Deployment diagrams are a set of nodes and their relationships. These nodes are physical entities where
the components are deployed.
Deployment diagrams are used for visualizing the deployment view of a system. This is generally used by
the deployment team.
Note − If the above descriptions and usages are observed carefully then it is very clear that all the diagrams
have some relationship with one another. Component diagrams are dependent upon the classes, interfaces,
etc. which are part of class/object diagram. Again, the deployment diagram is dependent upon the
components, which are used to make component diagrams.
Behavioral diagrams basically capture the dynamic aspect of a system. Dynamic aspect can be further
described as the changing/moving parts of a system.
• Use case diagram(to know how the users are going to interact with the system)
• Sequence diagram (interaction diagrams)
• Collaboration diagram
• Statechart diagram
• Activity diagram
Use case diagrams are a set of use cases, actors, and their relationships. They represent the use case view
of a system. ‘
A use case represents a particular functionality of a system. Hence, use case diagram is used to describe
the relationships among the functionalities and their internal/external controllers. These controllers are
known as actors.
Sequence Diagram
A sequence diagram is an interaction diagram. From the name, it is clear that the diagram deals with some
sequences, which are the sequence of messages flowing from one object to another.
Interaction among the components of a system is very important from implementation and execution
perspective. Sequence diagram is used to visualize the sequence of calls in a system to perform a specific
functionality.
Collaboration Diagram
Collaboration diagram is another form of interaction diagram. It represents the structural organization of
a system and the messages sent/received. Structural organization consists of objects and links.
Statechart Diagram
Any real-time system is expected to be reacted by some kind of internal/external events. These events are
responsible for state change of the system.
Statechart diagram is used to represent the event driven state change of a system. It basically describes the
state change of a class, interface, etc.
State chart diagram is used to visualize the reaction of a system by internal/external factors.
Activity Diagram
Activity diagram describes the flow of control in a system. It consists of activities and links. The flow can
be sequential, concurrent, or branched.
Activities are nothing but the functions of a system. Numbers of activity diagrams are prepared to capture
the entire flow in a system.
Activity diagrams are used to visualize the flow of controls in a system. This is prepared to have an idea
of how the system will work when executed.
Note: Dynamic nature of a system is very difficult to capture. UML has provided features to capture the
dynamics of a system from different angles. Sequence diagrams and collaboration diagrams are
isomorphic, hence they can be converted from one another without losing any information. This is also
true for Statechart and activity diagram.
Page 5
[email protected] www.cameroonhnd.com 678866022 | 671633180
CMR HND PLATFORM LEARN TODAY, LEAD TOMORROW HND E-LEARNING PLATFORM
Visibility:
One of the important features that can be applied to the classifier’s attributes and operations is the
visibility. The visibility feature specifies whether a classifier can be used or accessed by the other
classifiers. The four access specifiers in UML are as shown below:
Attributes:
While modeling classes, it is reasonable to write only the attribute name. Along with the name,
you can also specify multiplicity, visibility and scope. Apart from these features, we can also specify the
type, initial value and changeability of each attribute. The syntax of an attribute in UML is:
Examples:
The three predefined properties that can be used with attributes in UML are :
Page 6
[email protected] www.cameroonhnd.com 678866022 | 671633180
CMR HND PLATFORM LEARN TODAY, LEAD TOMORROW HND E-LEARNING PLATFORM
Operations:
While modeling classes, it is simple to write only the operation name. Along with the name we can
also mention the visibility and scope. Apart from these basic details, we can also specify the return type,
parameters, concurrency semantics and other features. The syntax of an operation in UML is:
[visibility] name [(parameters-list)] [: return-type] [{property-string}]
Examples:
display Name only
+ display Name and visibility
set(n : Name, s : String) Name and parameters
getID() : Integer Name and return type
restart() {guarded} Name and property
The operation name, parameters list and its return type is collectively known as the signature of the
operation.
There are four predefined properties (stereotypes) that can be applied to operations, in UML. They are:
Page 7
[email protected] www.cameroonhnd.com 678866022 | 671633180
CMR HND PLATFORM LEARN TODAY, LEAD TOMORROW HND E-LEARNING PLATFORM
isQuery Execution of the operation does not change the state of the system.
sequential Denotes that the operation is suitable for sequential access only.
guarded Indicates that the operation guarantees integrity in case of concurrent access.
Concurrent calls will be performed in a sequential manner.
concurrent Denotes that the operation can be called concurrently and the integrity of the
object will be preserved. Operation executes on the object concurrently.
Relationships :
When we are modeling the system first of all we start is identifying things. These things will not
stay alone. They collaborate with each other means they are connected with others in some way. These
connections between the things are known as relationships.
In object-oriented modeling, there are three main relationships between the things:
1) Dependency,
2) Associations
3) Generalization.
Dependency:
A semantic relationship, in which a change in one thing (the independent thing) may cause changes in the
other thing (the dependent thing). A dependency is a using relationship. In this relationship one thing
depends on the other thing. The change in independent thing will affect the dependent thing. Dependency
is graphically represented as a dashed directed line. The arrow head points towards the independent thing.
Generalization:
The generalization relationship also known as the is-a relationship is between two things where one thing
is general (superclass) and the other is specific thing (subclass) of the general thing. Graphically,
generalization is represented as a solid line with a hollow arrow head pointing towards the general thing
Page 8
[email protected] www.cameroonhnd.com 678866022 | 671633180
CMR HND PLATFORM LEARN TODAY, LEAD TOMORROW HND E-LEARNING PLATFORM
Association:
An association is a structural relationship which connects one thing with another. Given an
association between two things, we can navigate from one thing to the other thing and vice versa. It is also
common for a thing to have a self association.
An association which connects exactly two classes is known as binary association. An association
which connects n number of classes is known as n-nary association. Graphically association is represented
as a solid line. Apart from this basic representation, an association has four adornments:
Name: An association can have a name which let’s you represent the meaning of the association. The
name is written on top of the association. We can also represent the direction in which the name is read.
Role: A thing participating in an association will have a specific role. This role can be represented by
writing it outside, near to the thing and below or above the association.
Multiplicity: The multiplicity is an indication of how many objects may participate in the given
relationship, or the allowable number of instances of the element.When connecting things with
association, we are concerned about how many objects of one class can connect across an instance of the
association. This “how many” is known as multiplicity of an association’s role and is written as an
expression.
Aggregation: In some cases we might come across “whole-part” relationships between two things, in
which one thing is a part of another thing. Such relationship is known as an aggregation or also known as
“has-a” relationship. Aggregation is a special case of the association relationship. Aggregation is
represented as a solid line with a hollow diamond head towards the whole thing.
Composition:
The composition is a flavor of association relationship. Composition as well as aggregation
relationships represent whole-part relationships, in which one thing is a part of the other thing. There is a
simple difference between the association and composition relationships. In composition, the lifetime of
the part is dependent of the lifetime of the whole thing. Where as in aggregation, the lifetime of the part is
independent of the whole thing.
Composition is graphically represented by adorning the association relationship with a filled
diamond head near the whole end. (There are dependent to each other in composition on while in
agregation it doesn’t depends on the whole things.Another name for composition is called containement)
Association Class :
Sometimes in an association relationship, the association might have attributes or properties like a
class does. In such cases, it is modeled as an association class. An association class in UML is represented
with a class icon attached to the association with a dashed line.
• The name of the class diagram should be meaningful to describe the aspect of the system.
• Each element and their relationships should be identified in advance.
• Responsibility (attributes and methods) of each class should be clearly identified
• For each class, minimum number of properties should be specified, as unnecessary properties
will make the diagram complicated.
• Use notes whenever required to describe some aspect of the diagram. At the end of the
drawing it should be understandable to the developer/coder.
• Finally, before making the final version, the diagram should be drawn on plain paper and
reworked as many times as possible to make it correct.
The following diagram is an example of an Order System of an application. It describes a particular aspect
of the entire application.
• First of all, Order and Customer are identified as the two elements of the system. They have a one-
to-many relationship because a customer can have multiple orders.
• Order class is an abstract class and it has two concrete classes (inheritance relationship)
SpecialOrder and NormalOrder.
• The two inherited classes have all the properties as the Order class. In addition, they have additional
functions like dispatch () and receive ().
The following class diagram has been drawn considering all the points mentioned above.
Page 12
[email protected] www.cameroonhnd.com 678866022 | 671633180
CMR HND PLATFORM LEARN TODAY, LEAD TOMORROW HND E-LEARNING PLATFORM
Page 13
[email protected] www.cameroonhnd.com 678866022 | 671633180
CMR HND PLATFORM LEARN TODAY, LEAD TOMORROW HND E-LEARNING PLATFORM
Page 14
[email protected] www.cameroonhnd.com 678866022 | 671633180
CMR HND PLATFORM LEARN TODAY, LEAD TOMORROW HND E-LEARNING PLATFORM
Page 15
[email protected] www.cameroonhnd.com 678866022 | 671633180
CMR HND PLATFORM LEARN TODAY, LEAD TOMORROW HND E-LEARNING PLATFORM
Reverse engineering is the process of transforming code into a model through a mapping from a specific
implementation language.
Page 16
[email protected] www.cameroonhnd.com 678866022 | 671633180
CMR HND PLATFORM LEARN TODAY, LEAD TOMORROW HND E-LEARNING PLATFORM
Page 17
[email protected] www.cameroonhnd.com 678866022 | 671633180
CMR HND PLATFORM LEARN TODAY, LEAD TOMORROW HND E-LEARNING PLATFORM
Object Names :
Every object is actually symbolized like a rectangle, that offers the name from the object and its class
underlined as well as divided with a colon
Object Attributes :
Similar to classes, you are able to list object attributes inside a separate compartment. However, unlike
classes, object attributes should have values assigned for them
Links :
Links tend to be instances associated with associations. You can draw a link while using the lines
utilized in class diagrams
Example :
The following diagram is an example of an object diagram. It represents the Order management system
which we have discussed in the chapter Class Diagram. The following diagram is an instance of the system
at a particular time of purchase. It has the following objects.
• Customer
• Order
• SpecialOrder
• NormalOrder
Page 18
[email protected] www.cameroonhnd.com 678866022 | 671633180
CMR HND PLATFORM LEARN TODAY, LEAD TOMORROW HND E-LEARNING PLATFORM
Page 19
[email protected] www.cameroonhnd.com 678866022 | 671633180
CMR HND PLATFORM LEARN TODAY, LEAD TOMORROW HND E-LEARNING PLATFORM
• Model the static design (similar to class diagrams) or structure of a system using prototypical
instances and real data.
• Helps us to understand the functionalities that the system should deliver to the users.
• Understand relationships between objects.
• Visualise, document, construct and design a static frame showing instances of objects and
their relationships in the dynamic story of life of a system.
• Verify the class diagrams for completeness and accuracy by using Object Diagrams as
specific test cases.
• Discover facts and dependencies between specific instances and depicting specific examples of
classifiers.
Page 20
[email protected] www.cameroonhnd.com 678866022 | 671633180