Professional Documents
Culture Documents
There is the some dispute about exactly what characteristics (Principles) are required by an OO approach, but they
generally include:
o identity
o classification
o inheritance
o polymorphism
o Data abstraction
o Dynamic Binding
o Message passing
Object identity
An object is an instance of a class. Object identity is a fundamental object orientation concept. Identity is a property of
an object that distinguishes the object from all other objects in the application by their own inherent identity. In other
words, two objects are distinct even if all their attribute values (such as name and size) are identical. An object has an
existence which is independent of its value. Thus two notions of object equivalence exist: two objects can be identical
(they are the same object) or they can be equal (they have the same value). This has two implications: one is object
sharing and the other one is object updates.
Object sharing: Consider the following example: a Person has a name, an age and a set of children. Assume Peter
and Susan both have a 15-year-old child named John. In real life, two situations may arise: Susan and Peter are parent
of the same child or there are two children involved. In a system without identity, Peter is represented by:
(peter, 40, {(john, 15, {})})
and Susan is represented by:
(susan, 41, {(john, 15, {})}).
Thus, there is no way of expressing whether Peter and Susan are the parents of the same child. In an identity-based
model, these two structures can share the common part (john, 15, {}) or not, thus capturing either situations.
Object updates: assume that Peter and Susan are indeed parents of a child named John. In this case, all updates to
Susan's son will be applied to the object John and, consequently, also to Peter's son. In a value-based system, both sub-
objects must be updated separately.
Classification
Classification means that objects with the same data structure (attributes) and behavior (operations) are grouped in
to a class.
Class is a user defined data type, which holds its own data members and member functions, which can be accessed and
used by creating an instance of that class. A class is like a blueprint for an object.
For Example: Consider the Class of Cars. There may be many cars with different names and brand but all of them will
share some common properties like all of them will have 4 wheels, Speed Limit, Mileage range etc. So here, Car is the
class and wheels, speed limits, mileage are their properties.
• A Class is a user defined data-type which has data members and member functions.
• Data members are the data variables and member functions are the functions used to manipulate these variables and
together these data members and member functions defines the properties and behavior of the objects in a Class.
• In the above example of class Car, the data member will be speed limit, mileage etc and member functions can be
apply brakes, increase speed etc
Object : Anything that can be seen or touched is an object. Objects are everywhere around you. They may represent a
book, your computer, a place, a person, concepts or any item that the program has to deal with. Objects are basic
elements in an object-oriented system. They are also known as class instances, class objects or instance objects.
Object definition
Objects in programming are the basic run-time entities that contain the data and the functions which contain the code
to manipulate that data.
When a class is defined, no memory is allocated but when it is instantiated (i.e. an object is created) memory is
allocated.
A class is defined in C++ using keyword class followed by the name of class. The body of class is defined inside the
curly brackets and terminated by a semicolon at the end.
Encapsulation
For a computer novice, data hiding and data encapsulation might mean the same thing. However, there are major
differences between the two concepts.
Data encapsulation and data hiding both involve objects (classified as values, data, structures, or functions), classes
(collection of data and methods), the computer code, and methods.
In general, encapsulation is the inclusion of one thing within another thing so that the included thing is not apparent. In
normal terms Encapsulation is defined as wrapping up of data and information under a single unit.
Decapsulation is the removal or the making apparent a thing previously encapsulated.
Consider a real life example of encapsulation, in a company there are different sections like the accounts section,
finance section, sales section etc. The finance sections handle all the financial transactions and keep records of all the
data related to finance. Similarly the sales section handles all the sales related activities and keeps records of all the
sales. Now there may arise a situation when for some reason an official from finance section needs all the data about
sales in a particular month. In this case, he is not allowed to directly access the data of sales section. He will first have
to contact some other officer in the sales section and then request him to give the particular data. This is what
encapsulation is. Here the data of sales section and the employees that can manipulate them are wrapped under a
single name “sales section”.
The process of implementing encapsulation can be sub-divided into two steps:
1. The data members should be labeled as private using the private access specifiers
2. The member function which manipulates the data members should be labeled as public using the public access
specifier.
On the other hand, data hiding is the process of hiding the details of an object or function. It is also a potent
(important) technique in programming that result in data security and less data complexity.
The data inside is classified as private or non-accessible from other objects, classes, and API’s in the system. The
data appear as invisible to outsiders – whether objects, other classes, or users.
Data encapsulation is one of the chief mechanisms of data hiding. Data hiding works by nesting the data or
arranging it into capsules.
Summary
1. Data encapsulation is a process, while data hiding is both a process and a technique. They both share the category of
object-oriented programming.
2. The data in data encapsulation is either public or private, while the data in data hiding is private and non-accessible.
3. Data encapsulation is one of the mechanisms of data hiding.
4. Data encapsulation’s concern is for consolidation, which is related to data’s hiding goal of reaching less complexity in
data. On the other hand, data hiding encompasses not only less data complexity, but also data protection and security.
5. The focus of data encapsulation is on the data inside the capsule, while data hiding is concerned with restrictions on
terms of access and use.
Abstraction
Data abstraction is one of the most essential and important feature of object oriented programming in C++.
Abstraction means displaying only essential information and hiding the details. Data abstraction refers to providing
only essential information about the data to the outside world, hiding the background details or implementation.
Consider a real life example of a man driving a car. The man only knows that pressing the accelerators will
increase the speed of car or applying brakes will stop the car but he does not know about how on pressing accelerator
the speed is actually increasing, he does not know about the inner mechanism of the car or the implementation of
accelerator, brakes etc in the car. This is what abstraction is.
Access specifiers are the main pillar of implementing abstraction in C++. We can use access specifiers to enforce
restrictions on class members. For example:
• Members declared as public in a class, can be accessed from anywhere in the program.
• Members declared as private in a class, can be accessed only from within the class. They are not allowed to be
accessed from any part of code outside the class.
Polymorphism
Polymorphism (from the Greek meaning "having multiple forms") is the characteristic of being able to assign a different
meaning or usage to something in different contexts - specifically, to allow an entity such as a variable, a function, or
an object to have more than one form. In single statement objects are allowed to take on more than one form
depending on the context.
Real life example of polymorphism, a person at the same time can have different characteristic. Like a man at the
same time is a father, a husband, an employee. So the same person posses different behavior in different situations.
This is called polymorphism. Polymorphism is considered as one of the important features of Object Oriented
Programming.
In C++ polymorphism is mainly divided into two types:
• Compile time Polymorphism
• Runtime Polymorphism
Compile time polymorphism: This type of polymorphism is achieved by function overloading or operator overloading.
Runtime polymorphism: This type of polymorphism is achieved by Function Overriding.
Inheritance: Inheritance is the process by which one object can acquire the properties of another class.
When the class child, inherits the class parent, the class child is referred to as derived class (sub class) and the class
parent as a base class (super class). In this case, the class child has two parts: a derived part and an incremental part.
The derived part is inherited from the class parent. The incremental part is the new code written specifically for the
class child.
Dynamic binding and Static binding:
Binding generally refers to a mapping of one thing to another. In the context of compiled languages, binding is the link
between a function call and the function definition. There are two types of binding in C++:
• Static (or early/ compile time) binding
BRIJESH KUMAR VERMA 4
Object Oriented System Design (KCS-056)
• Modeling:
A model is a simplification of reality. A model provides the blueprints of a system. A model may be structural,
emphasizing the organization of the system, or it may be behavioral, emphasizing the dynamics of the system.
“Object-oriented modeling is the process of preparing and designing what the model’s code will actually look like.”
Important of modeling
We build models so that we can better understand the system we are developing.
Through modeling, we achieve four aims.
1. Models help us to visualize a system as it is or as we want it to be.
2. Models permit us to specify the structure or behavior of a system.
3. Models give us a template that guides us in constructing a system.
4. Models document the decisions we have made.
We build models of complex systems because we cannot comprehend such a system in its entirety. We build model so
that we can better understand the system we are developing. A model may encompass an overview of the system
under consideration, as well as a detailed planning for system design, implementation and testing.
Principles of Modeling
1. The choice of model is important
The choice of what models to create has a profound influence on how a problem is attacked and how a solution is
shaped. We need to choose your models well.
• The right models will highlight the most critical development problems.
• Wrong models will mislead you, causing you to focus on irrelevant issues.
For Example: We can use different types of diagrams for different phases in software development.
In software, there are several ways to approach a model. The two most common ways are
1. Algorithmic perspective
2. Object-oriented perspective
1. Algorithmic Perspective
The traditional view of software development takes an algorithmic perspective. In this approach, the main building
block of all software is the procedure or function. This view leads developers to focus on issues of control and the
decomposition of larger algorithms into smaller ones. As requirements change and the system grows, systems built
with an algorithmic focus turn out to be very hard to maintain.
2. Object-oriented perspective
The contemporary view of software development takes an object-oriented perspective. In this approach, the main
building block of all software systems is the object or class. A class is a description of a set of common objects. Every
object has identity, state, and behavior. Object-oriented development provides the conceptual foundation for
assembling systems out of components using technology such as Java Beans or COM+.
• Introduction to Unified Modeling Language (UML)
UML is a visual modeling language
“A picture is worth a thousand words.” - Old saying
The Unified Modeling Language is a standard language for writing software blueprints (Blue print of source code). The
UML may be used to visualize, specify, construct, and document the artifacts of a software-intensive system as well as
for business modeling and other non-software systems.
The UML is appropriate for modeling systems ranging from enterprise information systems to distributed Web-based
applications and even to hard real time embedded systems. It is a very expressive language, addressing all the views
needed to develop and then deploy such systems.
The UML is a very important part of developing objects oriented software and the software development process. The
UML uses mostly graphical notations to express the design of software projects. Using the UML helps project teams
communicate, explore potential designs, and validate the architectural design of the software.
The UML is a language for
o Visualizing
o Specifying
o Constructing
o Documenting
Visualizing The UML is more than just a bunch of graphical symbols. Rather, behind each symbol in the UML notation is
a well-defined semantics. In this manner, one developer can write a model in the UML, and another developer, or even
another tool, can interpret that model unambiguously
Specifying means building models that are precise, unambiguous, and complete.
Constructing the UML is not a visual programming language, but its models can be directly connected to a variety of
programming languages
Documenting a healthy software organization produces all sorts of artifacts in addition to raw executable code. These
artifacts include
1. Requirements 2.Architecture 3.Design 4.Source code 5.Project plans
6. Tests 7.Prototypes 8.Releases
Why UML
As the strategic value of software increases for many companies, the industry looks for techniques to automate the
production of software and to improve quality and reduce cost and time-to-market. These techniques include
component technology, visual programming, patterns and frameworks. Businesses also seek techniques to manage the
complexity of systems as they increase in scope and scale. In particular, they recognize the need to solve recurring
architectural problems, such as physical distribution, concurrency, replication, security, load balancing and fault
tolerance. Additionally, the development for the World Wide Web, while making some things simpler, has exacerbated
these architectural problems. The Unified Modeling Language (UML) was designed to respond to these needs. The
primary goals in the design of the UML summarize by Page-Jones in Fundamental Object-Oriented Design in UML as
follows:
1. Provide users with a ready-to-use, expressive visual modeling language so they can develop and exchange meaningful
models.
2. Provide extensibility and specialization mechanisms to extend the core concepts.
3. Be independent of particular programming languages and development processes.
4. Provide a formal basis for understanding the modeling language.
5. Encourage the growth of the OO tools market.
6. Support higher-level development concepts such as collaborations, frameworks, patterns and components.
7. Integrate best practices
Conceptual Model of UML
To understand the UML, you need to form a conceptual model of the language, and this requires learning
three major elements: the UML's basic building blocks, the rules that dictate how those building blocks may be put
together, and some common mechanisms that apply throughout the UML.
These are the fundamental elements in UML. Every diagram can be represented using these building blocks. The
An attribute is a named property of a class that describes a range of values that instances of the property may hold. A
class may have any number of attributes or no attributes at all. An attribute represents some property
of the thing you are modeling that is shared by all objects of that class.
For example, every wall has a height, width, and thickness; you might model your customers in such a way
that each has a name, address, phone number, and date of birth. At a given moment, an object of a class will
have specific values for every one of its class's attributes.
An operation is the implementation of a service that can be requested from any object of the class to affect behavior. A
class may have any number of operations or no operations at all.
Example :
Interface
Interface is a collection of operations that specify a service of a class or component. An interface therefore describes
the externally visible behavior of that element. An interface is rendered as a circle together with its name. An interface
rarely stands alone. Rather, it is typically attached to the class or component that realizes the interface.
Graphical representation:
Use Cases:
A use case is a collection of actions, defining the interactions between a role (actor) and the system. Graphically use
case is represented as a solid ellipse with its name written inside the ellipse.
Graphical representation: A Simple example
Active classes:
a class whose instance is an active object; an active object is an object that owns a process or thread (units
of execution). Graphically, an active class is rendered as a class with double lines on the left and right; in another
notation with heavy lines, usually including its name, attributes, and operations it usually includes its name, attributes,
and operations, as in Figure
Components:
A component is a physical and replaceable part of a system. Graphically component is represented as a tabbed
rectangle. Examples of components are executable files, dll files, database tables, files and documents.
Graphical representation:
Example: Orderform.java
Nodes:
A physical element that exists at run-time and represents a computational resource (typically, hardware
resources).
1.1.2 Behavioral Things are the dynamic parts of UML models. These are the verbs of a model, representing
behavior over time and space. In all, there are two primary kinds of behavioral things
1.Interaction
2. State machine (as a sequence of state changes)
Interaction: A behavior made up of a set of messages exchanged among a set of objects to perform a particular task. A
message is represented as a solid arrow. Below is an example of interaction representing a phone conversation:
State Machine: A behavior that specifies the sequences of states an object or interaction goes through during its’
lifetime in response to events. A state is represented as a rectangle with rounded corners. Below is an example of state
machine representing the states of a phone system:
Example
1.1.4 Annotational things are the explanatory parts of UML models. These are the comments you may apply to
describe about any element in a model. A note is simply a symbol for rendering constraints and comments attached to
an element or a collection of elements. Graphically, a note is rendered as a rectangle with a dog-eared corner, together
with a textual or graphical comment
Graphical representation:
1.2 Relationships
The things in a diagram are connected through relationships. So, a relationship is a connection between two or more
things.
Relationships in the UML are four kinds of relationships in the UML:
1. Dependency
2. Association
3. Generalization
4. Realization
1.2.1 Dependency: Dependency is a semantic relationship between two things in which a change to one
thing (the independent thing) may affect the semantics of the other thing (the dependent thing). Graphically
a dependency is rendered as a dashed line, possibly directed, and occasionally including a label.
Notation:
(Arrow-head points to the independent thing)
1.2.2 Association: An association describes a group of links with common structure and common semantics.
A link being a connection among objects. Graphically an association is rendered as a solid line, possibly directed,
occasionally including a label, and often containing other adornments, such as multiplicity and role names. Given an
association connecting two classes, you can navigate from an object of one class to an object of the other class, and
vice versa.
Degree of an Association
Degree of an association denotes the number of classes involved in a connection. Degree may be unary, binary, or
ternary.
• A unary/self Association (relationship) connects objects of the same class.
• A binary Association (relationship) connects objects of two classes.
• A ternary relationship(N-ary Association) connects objects of three or more classes.
Cardinality Ratios of Associations
Cardinality of an association denotes the number of instances participating in an association. There are three types of
cardinality ratios, namely
• One–to–One − A single object of class A is associated with a single object of class B.
• One–to–Many − A single object of class A is associated with many objects of class B.
• Many–to–Many − An object of class A may be associated with many objects of class B and conversely an object of class
B may be associated with many objects of class A.
Name: An association can have a name, and you use that name to describe the nature of the relationship.
Role: When a class participates in an association, it has a specific role that it plays in that
relationship. In Figure, a Person playing the role of employee is associated with a Company playing the role of
employer.
Multiplicity specifies how many objects (instances of one class) may relate to a single instance of an associated class.
Multiplicity constraints can only be used with binary associations. This "how many" is called the multiplicity of an
association's role, and is written as an expression that evaluates to a range of values or an explicit value as in Fig.
When you state a multiplicity at one end of an association, you are specifying that, for each object of the class at the
opposite end, there must be that many objects at the near end. You can show a multiplicity of exactly one (1), zero or
one (0..1), many (0..*), or
one or more (1..*). You can even state an exact number (for example, 3, which is equivalent to 3..3).
For example, a car class can be defined to contain other classes such as engine class, seat class, wheels class etc.
A car object is an aggregation of engine, seat, wheels and other objects.
Example
A single Employee can not belong to multiple Companies (legally!!), but if we delete the Company, Employee object
will not destroy.
1.2.2.2 Composition when one class owns other class and other class cannot meaningfully exist, when it's
owner destroyed, for example, Human class is a composition of several body parts including Hand, Leg and Heart.
When human object dies, all it's body part ceased to exist meaningfully, this is one example of Composition.
Example
House can contain multiple rooms there is no independent life for room and any room can not belong to two different
house. If we delete the house room will also be automatically deleted.
1.2.3 Generalization:
A generalization is a relationship between a class and one or more refined versions of that class. Generalization is
transitive.
In other word a relationship between a general thing (called “parent” or “superclass”) and a more specific kind of that
thing (called the “child” or “subclass”), such that the latter can substitute the former. Also known as “is-a” relationship.
Generalization is a mechanism for combining similar classes of objects into a single, more general class.
Graphical representation:
Specialization is the reverse process of Generalization means creating new sub classes from an existing class.
1.2.4 Realization:
Defines a semantic relationship in which one class specifies something that another class will perform. In a realization
relationship of UML, one entity denotes some responsibility which is not implemented by itself and the other entity
that implements them. This relationship is mostly found in the case of interfaces.
Graphical representation:
8. Component diagram
9. Deployment diagram
Class Diagram:
A class diagram shows a set of classes, interfaces, and collaborations and their relationships. These diagrams are the
most common diagram found in modeling object-oriented systems. Class diagrams are the main building block of any
object-oriented solution. Class diagrams address the static design view of a system.
Terms and Concepts
A class diagram is a diagram that shows a set of classes, interfaces, and collaborations and their relationships.
Graphically, a class diagram is a collection of vertices and arcs.
Contents
Class diagrams commonly contain the following things:
· Classes
· Interfaces
· Collaborations
· Dependency, generalization, and association relationships
The class BankAccount, for example, will define attributes such as account No and balance.
The operations defined for the BankAccount class could include functions such as returnBalance () or updateBalance
().
Minus sign ("-") in front of the attribute name indicates that these attributes are private.
The operations have a plus sign ("+") in front of them showing that they are public.
The notion of classifying UML class attributes and operations as either private or public reflects the way in which class
variables and methods in object oriented programming languages are declared.
Naming conventions used here. If a class, attribute or operation has a name that contains more than one word, there
is no space between the words. The name of the class has a capital letter at the start of each word it contains. For
attribute and operation names however, the first word should always start with a lower-case letter. The name of an
operation is followed by a pair of parentheses.
A class diagram usually includes a number of class icons, connected together by lines that indicate the type of
relationship that exists between the interconnected classes. They provide a static view of the system, because although
they show the relationships between the various classes they provide no information about what actually happens
when these classes interact.
class diagrams are a useful tool for enabling analysts to explain the system to clients. By the same token, they are also
useful for enabling clients to discuss the problem domain with analysts. Once completed, they will form a design
blueprint that can be used by programmers to create the application’s data structures and program logic.
Attributes: The attributes of a class (assuming there are any) are listed in the middle rectangle of the class icon, and
represent some item of data that can be recorded about an instance of the class. An instance of the
class BankAccount will have a unique account number, and an account balance that will vary over time.
UML allows you to specify the data type for an attribute (e.g. string, integer, floating-point, Boolean etc.), and an initial
default value. Below is a modified version of the BankAccount class that demonstrates the principle.
We should at some point therefore specify the data type that is to be used for these attributes. This is a good example
of how software designers can communicate their requirements very precisely to programmers.
Associations: We can draw lines to connect the various classes together in order to show the relationships that exist
between the various classes. These connections, when they appear on class diagrams, are usually referred to
as associations. The connecting line may have an arrowhead at one end to indicate which way the association works,
and a label that provides a name or brief description of the relationship. If no arrowhead is present, the association is
assumed to be bi-directional.
The multiplicity of an association may also be shown on a class diagram. The multiplicity of a relationship
essentially tells us whether the relationship between two classes is a one-to-one, one-to-many, or many-to-
many relationship. In the case of a one-to-many relationship, the notation used must tell us which end of the
association represents the one and which end represents the many. Below is part of the simple bank system class
diagram.
The association between the BankAccount and Transaction classes has a one-to-zero-or-more relationship. From the
point of view of our system, a transaction can only relate to one account. When the bank account is first opened, there
will be zero transactions, so at that point in time we have a one-to-zero situation (one bank account, zero transactions).
Over time, however, we can expect a number of transactions to be made. Even if the account is closed again
immediately after it is opened (unlikely as that might seem), the multiplicity holds true because it allows for zero
transactions.
The association between the Customer and BankAccount classes is characterized by a one-to-one-or-more
relationship. A bank account can only belong to one customer. A customer, on the other hand, might have several
accounts (e.g. current account, savings account, business account, and so on).
At the BankAccount end of the association, the multiplicity is going to be one-or-more rather than zero-or-
more. This is because, due to the nature of a bank, a customer is not a customer until they have opened some kind of
account.
Generalization and inheritance In the UML, the word generalizations used instead of inheritance, but it means more or
less the same thing, which is that one class can be a sub-class, or child class, of another class (the parent class). The
child class will have a different name, but inherits all of the characteristics of the parent class including its attributes
and operations.
You can see from the diagram that the classes CurrentAccount and SavingsAccount are both children of
the BankAccount class. A class that is used purely as a generalization from which to derive other (child) classes, and
which is not used to create objects (instances) in its own right, is called an abstract class.
Object Diagram:
Objects are the real-world entities whose behavior is defined by the classes. Objects are used to represent the static
view of an object-oriented system but this static view is a snapshot of the system at a particular moment. We cannot
define an object without its class. Object diagrams are derived from class diagrams so object diagrams are dependent
upon class diagrams.
“Object diagrams describe the static structure of a system at a particular time. It shows a complete or partial
view of the structure of a modeled system at a specific time. They can be used to test class diagrams for accuracy.”
An object diagram describes the instance of a class diagram. It visualizes the particular functionality of a
system.
Both class diagrams and object diagrams represent a static, structural view of a system. Object diagrams are not
frequently used, but they can sometimes be useful for demonstrating the way in which objects interact in a system "at
run time".
A class icon represents all of the instances of a particular class that exist, have existed, or ever will exist in a system; an
object icon represents exactly one instance of a class at one particular moment in time. The illustration below shows
the difference between how a class icon, and its instantiation as an object, are represented in the UML.
The name of the object is underlined to show that it is an object. It is also the convention to add the name of the class
of which the object is an instance, following the name of the object and separated from it by a colon. In our example
we have "HartleyJR : BankAccount", which indicates an object of type BankAccount with the name "HarleyJR" (note
that the names of objects normally start with a lower case character).
The icon shows the details of the first object, with additional objects being implied by the addition of a second
rectangle drawn in such a fashion that it appears to be behind the first.
The object diagram shown above is designed to highlight the fact that a single course (in this case "Computing and
Informatics") is administered by the Faculty of Technology, and includes a number of modules administered by
the Computing department (as you might expect, given the title of the course). It also tells us that the course includes
modules administered by both the Management department and the Finance department, both of which are in turn
administered by the Faculty of Business Studies.
Object diagrams can be used to highlight all kinds of situations that can arise at some moment in the life of an
information system, at an arbitrary level of detail (the level of detail shown on an object diagram should only be as
much as is necessary to make the point we are trying to make). They are useful for helping stakeholders to understand
a class diagram, or for showing a client how part of the system is supposed to work in a given scenario. They are not as
a rule used by system designers or programmers to design an application or write program code (class diagrams are far
better suited for that purpose).
Use Case Diagram: Terms and Concepts
A use case diagram at its simplest is a representation of a user's interaction with the system that shows the relationship
between the user and the different use cases in which the user is involved. a use-case diagram can help provide a
higher-level view of the system. They provide the simplified and graphical representation of what the system must
actually does (i.e. its functionality), not how it does it.
Contents
Use case diagrams commonly contain
· Use cases
· Actors
· Dependency, generalization, and association relationships
The elements of a use case diagram include:
• use cases - Draw use cases using ovals and specific pieces of the system's functionality
• actors - people or things(users of the system) that interact with the system's use cases
• Relationships - used to link actors with the use cases they interact with
• System boundary - defines what functionality is included within the system. Draw your system's boundaries using a
rectangle that contains use cases. Place actors outside the system's boundaries.
In the above use case diagram, there are two actors named student and a teacher. There are a total of five use cases
that represent the specific functionality of a student management system. Each actor interacts with a particular use
case. A student actor can check attendance, timetable as well as test marks on the application or a system. This actor
can perform only these interactions with the system even though other use cases are remaining in the system.
It is not necessary that each actor should interact with all the use cases, but it can happen.
The second actor named teacher can interact with all the functionalities or use cases of the system. This actor
can also update the attendance of a student and marks of the student. These interactions of both student and a
teacher actor together sum up the entire student management application.
In general use case diagrams are used for:
The primary purpose of a use case diagram is to describe the behavior of a system from the user's point of view. Use
case diagrams capture the dynamic behaviour of a live system. It models how an external entity interacts with the
system to make it work. Use case diagrams are responsible for visualizing the external things that interact with the part
of the system.
• Analyzing the requirements of a system
• High-level visual software designing
The purpose of a collaboration diagram is to emphasize structural view of messaging objects i.e., how various lifelines
in the system connect.
Contents
Interaction diagrams commonly contain
· Objects
· Links
· Messages
Sequence Diagram:
A sequence diagram simply depicts interaction between objects in a sequential order i.e. the order in which these
interactions take place. A sequence diagram is a type of interaction diagram because it describes how—and in what
order—a group of objects works together. We can also use the terms event diagrams or event scenarios to refer to a
sequence diagram. These diagrams are widely used by businessmen and software developers to document and
understand requirements for new and existing systems.
Basic Sequence Diagram Notations
• Class Roles or Participants- Class roles describe the way an object will behave in context. Use the UML object symbol
to illustrate class roles, but don't list object attributes.
• Lifeline Notation: Lifelines are vertical dashed lines that indicate the
object's presence over time. A sequence diagram is made up of several of these
lifeline Notations that should be arranged horizontally across the top of the diagram.
No two lifeline notations should overlap each other. They represent the different
objects or parts that interact with each other in the system during the sequence.
I. A lifeline represents an individual participant in the Interaction.
• Actor
It Shows entities that interact with or are external to the system. It represents roles
played by human users, external hardware, or other subjects.
I. An actor does not necessarily represent a specific physical entity but merely a
particular role of some entity
II. A person may play the role of several different actors and, conversely, a given
actor may be played by multiple different person.
• Call Message is a kind of message that represents an invocation of operation of target lifeline.
• Return Message is a kind of message that represents the pass of information back to the caller of a corresponded
former message.
• Self Message is a kind of message that represents the invocation of message of the same lifeline.
• Create Message is a kind of message that represents the instantiation of (target) lifeline.
• Destroy Message is a kind of message that represents the request of destroying the lifecycle of target lifeline.
• Duration Message shows the distance between two time instants for a message invocation.
• Note A note (comment) gives the ability to attach various remarks to elements. A comment carries no semantic force,
but may contain information that is useful to a modeler.
• Found Message A message sent from an unknown recipient, shown by an arrow from an endpoint to a lifeline.
• Lost Message A message sent to an unknown recipient. It's shown by an arrow going from a lifeline to an endpoint, a
filled circle or an x.
From the above use case diagram example of ‘Create New Online Library Account’, we will focus on the use case
named ‘Create New User Account’ to draw our sequence diagram example.
Before drawing the sequence diagram, it’s necessary to identify the objects or actors that would be involved in creating
a new user account. These would be;
I. Librarian
II. Online Library Management system
III. User credentials database
IV. Email system
Once you identify the objects, it is then important to write a detailed description on what the use case does. From this
description, you can easily figure out the interactions (that should go in the sequence diagram) that would occur
between the objects above, once the use case is executed.
Here are the steps that occur in the use case named ‘Create New Library User Account’.
• The librarian request the system to create a new online library account
• The librarian then selects the library user account type
• The librarian enters the user’s details
• The user’s details are checked using the user Credentials Database
• The new library user account is created
• A summary of the of the new account’s details are then emailed to the user
From each of these steps, you can easily specify what messages should be exchanged between the objects in the
sequence diagram. Once it’s clear, you can go ahead and start drawing the sequence diagram.
The sequence diagram below shows how the objects in the online library management system interact with each other
to perform the function ‘Create New Library User Account’.
A collaboration diagram is a type of visual presentation that shows how various software objects interact with each
other within the system. This is difficult to determine from a sequence diagram.
State – We use a rounded rectangle to represent a state. A state represents the conditions or circumstances of an
object of a class at an instant of time.
Transition - We use a solid arrow to represent the transition or change of control from one state to another. The arrow
is labelled with the event which causes the change in state.
Self transition – We use a solid arrow pointing back to the state itself to represent a self transition. There might be
scenarios when the state of the object does not change upon the occurrence of an event. We use self transitions to
represent such cases.
Final State - An arrow pointing to a filled circle nested inside another circle represents the object's final state.
Fork – We use a rounded solid rectangular bar to represent a Fork notation with
incoming arrow from the parent state and outgoing arrows towards the newly
created states. We use the fork notation to represent a state splitting into two
or more concurrent states.
Join – We use a rounded solid rectangular bar to represent a Join notation
with incoming arrows from the joining states and outgoing arrow towards
the common goal state. We use the join notation when two or more states
concurrently converge into one on the occurrence of an event or events.
Activity Diagram: An activity diagram visually presents a series of actions or flow of control from activity to activity in a
system similar to flowchart or a data flow diagram. Activity diagrams are often used in business process modeling.
You use activity diagrams to model the dynamic aspects of a system. For the most part, this involves modeling the
sequential (and possibly concurrent) steps in a computational process. It is also called object-oriented flowchart.Most
similar to state diagram)
Terms and Concepts
An activity diagram shows the flow from activity to activity. An is an ongoing nonatomic execution within a state
machine. Activities ultimately result in some action, which is made up of executable atomic computations that result in
a change in state of the system or the return of a value. Graphically, an activity diagram is a collection of vertices and
arcs.
Some of the most common components of an activity diagram include:
• Action: A step in the activity wherein the users or software perform a given task. Actions are symbolized with round-
edged rectangles.
• Decision node: A conditional branch in the flow that is represented by a diamond. It includes a single input and two or
more outputs.
• Control flows: Another name for the connectors that show the flow between steps in the diagram.
• Start node: Symbolizes the beginning of the activity. The start node is represented by a black circle.
• End node: Represents the final step in the activity. The end node is represented by an outlined black circle.
A fork and join mode used together are often referred to as synchronization.
Component diagram - Component diagrams are different in terms of nature and behavior. Component diagrams are
used to model the physical aspects of a system. Physical aspects are the elements such as executables, libraries, files,
documents, etc. which reside in a node.
A component is a replaceable and executable piece of a system whose implementation details are hidden. A
component provides the set of interfaces that a component realizes or implements. Components also require
interfaces to carry out a function.
Interface -An interface (small circle or semi-circle on a stick) describes a group of operations used (required) or created
(provided) by components. A full circle represents an interface created or provided by the component. A semi-circle
represents a required interface, like a person's input.
Port - Ports are represented using a square along the edge of the system or a component. A port is often used to help
expose required and provided interfaces of a component.
Example
• Association: A line that indicates a message or other type of communication between nodes.
• Node as container: A node that contains another node inside of it—such as in the example below, where the nodes
contain components.
• Stereotype: A device, artifacts contained within the node, presented at the top of the node, with the name bracketed
by double arrows.
Terms and Concepts
A deployment diagram is a diagram that shows the configuration of run time processing nodes and the
components that live on them. Graphically, a deployment diagram is a collection of vertices and arcs.
Common Properties
A deployment diagram is just a special kind of diagram and shares the same common properties as all other diagrams•
a name and graphical contents that are a projection into a model. What distinguishes a deployment diagram from all
other kinds of diagrams is its particular content.
Contents
Deployment diagrams commonly contain
· Nodes
· Dependency and association relationships
When to Use Deployment Diagram
• What existing systems will the newly added system need to interact or integrate with?
• How robust does system need to be (e.g., redundant hardware in case of a system failure)?
• What and who will connect to or interact with system, and how will they do it
• What middleware, including the operating system and communications approaches and protocols, will system use?
• What hardware and software will users directly interact with (PCs, network computers, browsers, etc.)?
• How will you monitor the system once deployed?
• How secure does the system needs to be (needs a firewall, physically secure hardware, etc.)?
Rule: It is an accepted instruction that states the way things are or should be done, and tells you what you
are allowed or are not allowed to do. The UML has a number of rules that specify what a well-formed model should
look like. The UML rules for Names, Scope, Visibility, Integrity and Execution. The UML has semantic rules for
1. Name: What you can call things, relationships, and diagrams
2. Scope: The scope of a feature specifies whether each instance of the classifier has its own distinct value of the
feature
or whether there is just a single value of the feature shared by all instances of the classifier.
3. Visibility: How those names can be seen and used by others (types of visibility – public [+], protected [#], private
[-],
package [~]).
4. Integrity: How things properly and consistently relate to one another
5. Execution: What it means to run or simulate a dynamic model.
Common Mechanisms: It a system of parts working together in a system for particular task.
The UML is made simpler by the presence of four common mechanisms that apply consistently throughout the
language:
• notes
a. specificatins
b. adornments
• common divisions
• extensibility mechanisms.
a. Stereotypes
b. Tagged values
c. constraints
A note is used to specify things like: requirements, observations, reviews, explanations and constraints. A note
may
contain simple text or graphical symbols. A note has no effect on the semantics of a model means it does not
alter the
meaning of the model.
Specifications: Specification provides a textual statement of the syntax and semantics of a building block which
describing interesting aspects of a system.
Adornments: unique and direct graphical notation that provides a visual representation of the most important
aspects
of the element.
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
Extensibility Mechanisms
Extensibility mechanisms allow extending the language in controlled ways. They include Sterotypes, Tagged
Values
and Constraints
Architecture:
A system's architecture is perhaps the most important artifact that can be used to manage these different
viewpoints and so control the iterative and incremental development of a system throughout its life cycle.
Architecture is the set of significant decisions about
1. The organization of a software system
2. The selection of the structural elements and their interfaces by which the system is composed
3. Their behavior, as specified in the collaborations among those elements
4. The composition of these structural and behavioral elements into progressively larger subsystems
The architectural style that guides this organization: the static and dynamic elements and their interfaces,
their collaborations, and their composition.
Software architecture is not only concerned with structure and behavior, but also with usage, functionality,
performance, resilience, reuse, comprehensibility, economic and technology constraints and trade-offs, and
aesthetic concerns. Architecture can be best represented as a collection five views:
1) Use case view,
2) Design/logical view,
3) Implementation/development view,
4) Process view and
5) Deployment/physical view.
Use case view: The use case view of a system encompasses (covers) the use cases that describe the behavior
of
the system as seen by its end users, analysts, and testers. With the UML, the static aspects of this view are
captured in use case diagrams. The dynamic aspects of this view are captured in interaction diagrams, state
chart
diagrams, and activity diagrams.
Design View:
• The design view of a system encompasses (covers) the classes, interfaces, and collaborations that form
the
vocabulary of the problem and its solution.
• This view primarily supports the functional requirements of the system, meaning the services that the
system
should provide to its end users.
Process View:
• The process view of a system encompasses the threads and processes that form the system's concurrency
and
synchronization mechanisms.
• This view primarily addresses the performance, scalability, and throughput of the system
Implementation View:
The implementation view of a system encompasses the components and files that are used to assemble
and
release the physical system. This view primarily addresses the configuration management of the system's
releases, made up of somewhat independent components and files that can be assembled in various ways
to
produce a running system.
Deployment View:
The deployment view of a system encompasses the nodes that form the system's hardware topology on
which
the system executes. This view primarily addresses the distribution, delivery, and installation of the parts
that
Reverse engineering is the process of transforming code into a model through a mapping from a specific
implementation language. Reverse engineering results in a flood of information, some of which is at a lower
level of detail than you'll need to build useful models. At the same time, reverse engineering is incomplete.
There is a loss of information when forward engineering models into code, and so you can't completely
recreate a model from code unless your tools encode information in the source comments that goes beyond
the semantics of the implementation language.
To reverse engineer a class diagram,
•Identify the rules for mapping from your implementation language or languages of choice
• Using a tool, point to the code you'd like to reverse engineer. Use your tool to generate a new model or
modify an existing one that was previously forward engineered.
• Using your tool, create a class diagram by querying the model. For example, you might start with one or
more classes, then expand the diagram by following specific relationships or other