Unit 2 Notes
Unit 2 Notes
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.
Relationships
In UML, relationships are of three types:
The company encompasses a number of employees, and even if one employee resigns,
the company still exists.
A contact book consists of multiple contacts, and if you delete the contact book, all
the contacts will be lost.
Abstract Classes
In the abstract class, no objects can be a direct entity of the abstract class. The abstract
class can neither be declared nor be instantiated. It is used to find the functionalities
across the classes. The notation of the abstract class is similar to that of class; the only
difference is that the name of the class is written in italics. Since it does not involve any
implementation for a given function, it is best to use the abstract class with multiple
objects.
Let us assume that we have an abstract class named displacement with a method
declared inside it, and that method will be called as a drive (). Now, this abstract class
method can be implemented by any object, for example, car, bike, scooter, cycle, etc.
Some key points that are needed to keep in mind while drawing a class diagram are
given below:
Both the object and class diagram are similar to some extent; the only difference is
that the class diagram provides an abstract view of a system. It helps in visualizing a
particular functionality of a system.
The object diagram is actually similar to the concrete (actual) system behavior. The
main purpose is to depict a static view of a system.
2. Dynamic changes are not included in the class Dynamic changes are captured in the
diagram. object diagram.
3. The data values and attributes of an instance are It incorporates data values and
not involved here. attributes of an entity.
4. The object behavior is manipulated in the class Objects are the instances of a class.
diagram.
Following are some of the use cases enlisted below for which the collaboration
diagram is implemented:
1. To model collaboration among the objects or roles that carry the functionalities
of use cases and operations.
2. To model the mechanism inside the architectural design of the system.
3. To capture the interactions that represent the flow of messages between the
objects and the roles inside the collaboration.
4. To model different scenarios within the use case or operation, involving a
collaboration of several objects and interactions.
5. To support the identification of objects participating in the use case.
6. In the collaboration diagram, each message constitutes a sequence number,
such that the top-level message is marked as one and so on. The messages sent
during the same call are denoted with the same decimal prefix, but with
different suffixes of 1, 2, etc. as per their occurrence.
Sequence Diagram
The sequence diagram represents the flow of messages in the system and is also
termed as an event diagram. It helps in envisioning several dynamic scenarios. It
portrays the communication between any two lifelines as a time-ordered sequence of
events, such that these lifelines took part at the run time. In UML, the lifeline is
represented by a vertical bar, whereas the message flow is represented by a vertical
dotted line that extends across the bottom of the page. It incorporates the iterations
as well as branching.
Keep Watching
Messages
The messages depict the interaction between the objects and are represented by
arrows. They are in the sequential order on the lifeline. The core of the sequence
diagram is formed by messages and lifelines.
o Recursive Message: A self message sent for recursive purpose is called a recursive
message. In other words, it can be said that the recursive message is a special case of
the self message as it represents the recursive calls.
o Create Message: It describes a communication, particularly between the lifelines of an
interaction describing that the target (lifeline) has been instantiated.
Sequence Fragments
1. Sequence fragments have been introduced by UML 2.0, which makes it quite easy for
the creation and maintenance of an accurate sequence diagram.
2. It is represented by a box called a combined fragment, encloses a part of interaction
inside a sequence diagram.
3. The type of fragment is shown by a fragment operator.
Types of fragments
Following are the types of fragments enlisted below;
alt Alternative multiple fragments: The only fragment for which the condition is true, will execute
opt Optional: If the supplied condition is true, only then the fragments will execute. It is similar
with only one trace.
loop Loop: Fragments are run multiple times, and the basis of interaction is shown by the guard.
region Critical region: Only one thread can execute a fragment at once.
ref Reference: An interaction portrayed in another diagram. In this, a frame is drawn so as to cove
lifelines involved in the communication. The parameter and return value can be explained.
Any online customer can search for a book catalog, view a description of a particular
book, add a book to its shopping cart, and do checkout.
Benefits of a Sequence Diagram
1. It explores the real-time application.
2. It depicts the message flow between the different objects.
3. It has easy maintenance.
4. It is easy to generate.
5. Implement both forward and reverse engineering.
6. It can easily update as per the new change in the system.
After that, we will enlist the actors that will interact with the system. The actors are the
person or a thing that invokes the functionality of a system. It may be a system or a
private entity, such that it requires an entity to be pertinent to the functionalities of
the system to which it is going to interact.
Once both the actors and use cases are enlisted, the relation between the actor and
use case/ system is inspected. It identifies the no of times an actor communicates with
the system. Basically, an actor can interact multiple times with a use case or system at
a particular instance of time.
Following are some rules that must be followed while drawing a use case diagram:
1. A pertinent and meaningful name should be assigned to the actor or a use case
of a system.
2. The communication of an actor with a use case must be defined in an
understandable way.
3. Specified notations to be used as and when required.
4. The most significant interactions should be represented among the multiple no
of interactions between the use case and actors.
Here the Web Customer actor makes use of any online shopping website to purchase
online. The top-level uses are as follows; View Items, Make Purchase, Checkout, Client
Register. The View Items use case is utilized by the customer who searches and view
products. The Client Register use case allows the customer to register itself with the
website for availing gift vouchers, coupons, or getting a private sale invitation. It is to
be noted that the Checkout is an included use case, which is part of Making
Purchase, and it is not available by itself.
The View Items is further extended by several use cases such as; Search Items, Browse
Items, View Recommended Items, Add to Shopping Cart, Add to Wish list. All of these
extended use cases provide some functions to customers, which allows them to search
for an item. The View Items is further extended by several use cases such as; Search
Items, Browse Items, View Recommended Items, Add to Shopping Cart, Add to Wish
list. All of these extended use cases provide some functions to customers, which allows
them to search for an item.
Both View Recommended Item and Add to Wish List include the Customer
Authentication use case, as they necessitate authenticated customers, and
simultaneously item can be added to the shopping cart without any user
authentication.
Similarly, the Checkout use case also includes the following use cases, as shown
below. It requires an authenticated Web Customer, which can be done by login page,
user authentication cookie ("Remember me"), or Single Sign-On (SSO). SSO needs an
external identity provider's participation, while Web site authentication service is
utilized in all these use cases.
The Checkout use case involves Payment use case that can be done either by the credit
card and external credit payment services or with PayPal.
Important tips for drawing a Use Case diagram
Following are some important tips that are to be kept in mind while drawing a use
case diagram: