Oose Unit 1
Oose Unit 1
Oose Unit 1
UNIT-1
Object Orientation
Object-oriented programming (OOP) is a programming paradigm based on the concept of
"objects," which can contain data, in the form of fields (often known as attributes or properties),
and code, in the form of procedures (often known as methods). These objects are instances of
classes, which act as blueprints for creating objects. Object-oriented programming provides a
way to structure software in a more modular and organized manner, making it easier to manage
and maintain.
In the object-oriented design method, the system is viewed as a collection of objects (i.e.,
entities). The state is distributed among the objects, and each object handles its state data. For
example, in a Library Automation Software, each library representative may be a separate
object with its data and functions to operate on these data. The tasks defined for one purpose
cannot refer or change data of other objects. Objects have their internal data which represent
their state. Similar objects create a class. In other words, each object is a member of some
class. Classes may inherit features from the superclass.
1. Class:
A class is a user-defined data type. It consists of data members and member functions, which
can be accessed and used by creating an instance of that class. It represents the set of
properties or methods that are common to all objects of one type. 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
brands 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.
2. Object:
It is a basic unit of Object-Oriented Programming and represents the real-life entities. An Object
is an instance of a Class. When a class is defined, no memory is allocated but when it is
instantiated (i.e. an object is created) memory is allocated. An object has an identity, state, and
behavior. Each object contains data and code to manipulate the data. Objects can interact
without having to know details of each other’s data or code, it is sufficient to know the type of
message accepted and type of response returned by the objects.
For example “Dog” is a real-life Object, which has some characteristics like color, Breed, Bark,
Sleep, and Eats.
3. Data Abstraction:
Data abstraction is one of the most essential and important features of object-oriented
programming. 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 the car or applying brakes will stop the car, but he does not know about how on
pressing the accelerator the speed is increasing, he does not know about the inner mechanism
of the car or the implementation of the accelerator, brakes, etc in the car. This is what
abstraction is.
4. Encapsulation:
Encapsulation is defined as the wrapping up of data under a single unit. It is the mechanism that
binds together code and the data it manipulates. In Encapsulation, the variables or data of a
class are hidden from any other class and can be accessed only through any member function
of their class in which they are declared. As in encapsulation, the data in a class is hidden from
other classes, so it is also known as data-hiding.
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 section handles all the
financial transactions and keeps 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 the 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
the 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 the sales
section and the employees that can manipulate them are wrapped under a single name “sales
section”.
5. Inheritance:
Inheritance is an important pillar of OOP(Object-Oriented Programming). The capability of a
class to derive properties and characteristics from another class is called Inheritance. When we
write a class, we inherit properties from other classes. So when we create a class, we do not
need to write all the properties and functions again and again, as these can be inherited from
another class that possesses it. Inheritance allows the user to reuse the code whenever
possible and reduce its redundancy.
6. Polymorphism:
The word polymorphism means having many forms. In simple words, we can define
polymorphism as the ability of a message to be displayed in more than one form. For example,
A person at the same time can have different characteristics. 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.
7. Message Passing:
It is a form of communication used in object-oriented programming as well as parallel
programming. Objects communicate with one another by sending and receiving information to
each other. A message for an object is a request for execution of a procedure and therefore will
invoke a function in the receiving object that generates the desired results. Message passing
involves specifying the name of the object, the name of the function, and the information to be
sent.
Association:
Association is a relation between two separate classes which establishes through their Objects.
Association can be one-to-one, one-to-many, many-to-one, many-to-many. In Object-Oriented
programming, an Object communicates to another object to use functionality and services
provided by that object. Composition and Aggregation are the two forms of association.
Aggregation:
Association between two objects that defines the "has-a" relationship is referred to as
Aggregation. In Aggregation, linked objects are independent of each other. if we delete the
parent object, the child object will still exist in the system. For example, if we remove wheels
from a car, the car can function adequately with another wheel.
Aggregation implies a relationship where the child can exist independently of the parent. For
example, Bank and Employee, delete the Bank and the Employee still exist.
Composition:
A specific type of Aggregation that implies ownership is referred to as Composition. In
Composition, objects are tightly coupled or dependent on each other. if we delete a parent
object, the child object also gets deleted. For example, if we delete a folder, the files will also get
deleted which contain in the folder. Composition implies a relationship where the child cannot
exist independent of the parent. Example: Human and heart, heart don’t exist separate to a
Human
We start with a high level description of what the program does. Then, in each step, we take one
part of our high level description and refine it. Refinement is actually a process of elaboration.
The process should proceed from a highly conceptual model to lower level details. The
refinement of each module is done until we reach the statement level of our programming
language.
Objects are independent entities that may readily be changed because all state and
representation information is held within the object itself. Object may be distributed and may
execute sequentially or in parallel. Object oriented technology contains following three keywords
–
1. Objects –
Software package are designed and developed to correspond with real world entities
that contain all the data and services to function as their associated entities messages.
2. Communication –
Communication mechanisms are established that provide the means by which object
work together.
3. Methods –
Methods are services that objects perform to satisfy the functional requirements of the
problem domain. Objects request services of the other objects through messages.
Generalization
Generalization is the process of extracting common properties from a set of entities and creating
a generalized entity from it. It is a bottom-up approach in which two or more entities can be
generalized to a higher-level entity if they have some attributes in common. For Example,
STUDENT and FACULTY can be generalized to a higher-level entity called PERSON as shown
in Figure 1. In this case, common attributes like P_NAME, and P_ADD become part of a higher
entity (PERSON), and specialized attributes like S_FEE become part of a specialized entity
(STUDENT).
Generalization is also called as ‘ Bottom-up approach”.
Specialization
In specialization, an entity is divided into sub-entities based on its characteristics. It is a
top-down approach where the higher-level entity is specialized into two or more lower-level
entities. For Example, an EMPLOYEE entity in an Employee management system can be
specialized into DEVELOPER, TESTER, etc. as shown in Figure 2. In this case, common
attributes like E_NAME, E_SAL, etc. become part of a higher entity (EMPLOYEE), and
specialized attributes like TES_TYPE become part of a specialized entity (TESTER).
Aggregation
An ER diagram is not capable of representing the relationship between an entity and a
relationship which may be required in some scenarios. In those cases, a relationship with its
corresponding entities is aggregated into a higher-level entity. Aggregation is an abstraction
through which we can represent relationships as higher-level entity sets.
For Example, an Employee working on a project may require some machinery. So, REQUIRE
relationship is needed between the relationship WORKS_FOR and entity MACHINERY. Using
aggregation, WORKS_FOR relationship with its entities EMPLOYEE and PROJECT is
aggregated into a single entity and relationship REQUIRE is created between the aggregated
entity and MACHINERY.
Principles of modeling
1. The choice of what models to create has a profound influence on how a problem
is attacked and how a solution is shaped.
Choose your models well. The right models will highlight the most nasty development
problems. Wrong models will mislead you, causing you to focus on irrelevant issues.
Importance of modeling
A good model includes those elements that have broad effect and omits those minor elements
that are not relevant to the given level of abstraction. A model may be structural, emphasizing
the organization of the system, or it may be behavioral, emphasizing the dynamics of the
system.
The larger and more complex the system becomes, the more important modeling becomes, for
one very simple reason:
We build models of complex systems because we cannot comprehend such a system in its
entirety.
Every project can benefit from modeling. Modeling can help the development team better
visualize the plan of their system and allow them to develop more rapidly by helping them build
the right thing. The more complex your project, the more likely it is that you will fail or that you
will build the wrong thing if you do on modeling at all.
In software field, there are several ways to approach for building a model. The two most
common ways are: from an algorithmic perspective and from an object oriented 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 the
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.
The contemporary (another) view of software development takes an object oriented perspective.
In object oriented modeling, the main building block of all software systems is the object or
class.
The object oriented approach to software development is a part of the mainstream development
simply because it has proven to be of value in building systems in all sorts of problem domains
and cover all degrees of size and complexity.
The most common language used to do object-oriented modeling is the Object Management
Group's Unified Modeling Language (UML).
Different diagrams are used for different types of UML modeling. There are three important
types of UML modeling.
Structural Modeling
Structural modeling captures the static features of a system. They consist of the following −
Classes diagrams
Objects diagrams
Deployment diagrams
Package diagrams
Composite structure diagram
Component diagram
Structural model represents the framework for the system and this framework is the place where
all other components exist. Hence, the class diagram, component diagram and deployment
diagrams are part of structural modeling. They all represent the elements and the mechanism to
assemble them.
The structural model never describes the dynamic behavior of the system. Class diagram is the
most widely used structural diagram.
Behavioral Modeling
Behavioral model describes the interaction in the system. It represents the interaction among
the structural diagrams. Behavioral modeling shows the dynamic nature of the system. They
consist of the following −
Activity diagrams
Interaction diagrams
Use case diagrams
All the above show the dynamic sequence of flow in a system.
Architectural Modeling
Architectural model represents the overall framework of the system. It contains both structural
and behavioral elements of the system. Architectural model can be defined as the blueprint of
the entire system. Package diagram comes under architectural modeling.
Object oriented analysis
Object-Oriented Analysis (OOA) is the first technical activity performed as part of object-oriented
software engineering. OOA introduces new concepts to investigate a problem. It is based on a
set of basic principles, which are as follows:
● The information domain is modeled:
Lets say you’re building a game. OOA helps you figure out all the things you need to
know about the game world – the characters, their features, and how they interact. It’s
like making a map of everything important.
● Behavior is represented:
OOA also helps you understand what your game characters will do. If a character jumps
when you press a button, OOA helps describe that action. It’s like writing down a script
for each character.
● The function is described:
Every program has specific tasks or jobs it needs to do. OOA helps you list and describe
these jobs. In our game, it could be tasks like moving characters or keeping score. It’s
like making a to-do list for your software.
● Data, functional, and behavioral models are divided to uncover greater detail:
OOA is smart about breaking things into different parts. It splits the job into three
categories: things your game knows (like scores), things your game does (like jumping),
and how things in your game behave (like characters moving around). This makes it
easier to understand.
● Starting Simple, Getting Detailed:
OOA knows that at first, you just want to understand the big picture. So, it starts with a
simple version of your game or program. Later on, you add more details to make it work
perfectly. It’s like sketching a quick drawing before adding all the colors and details.
Structured Analysis:
1. Focus on processes: Structured Analysis focuses on the processes involved in a
software system, modeling them as a series of connected steps.
2. Top-down approach: Structured Analysis follows a top-down approach, breaking down
complex systems into smaller, simpler parts that can be more easily understood.
3. Data-centered: Structured Analysis focuses on the data that a software system
manipulates, modeling it as data flows between processes.
4. Emphasis on functional decomposition: Structured Analysis emphasizes the functional
decomposition of a software system into smaller, independent functions.
1. Structured Analysis :
Structured analysis is a method of development that allows and gives permission to the
analyst to understand and know about the system and all of its activities in a logical way.
It is simply a graphic that is used to specify the presentation of the application.
Example –
2. Object-Oriented Analysis :
Object-Oriented Analysis (OOA) is a technical approach generally used for analyzing and
application designing, system designing, or even business designing just by applying
object-oriented programming even with the use of visual modeling throughout the process of
development to just simply guide the stakeholder communication and quality of the product. it is
actually a process of discovery where a team of developers understands and models all the
requirements of the system.
Example –
The main focus is on the process and The main focus is on data structure and
procedures of the system. real-world objects that are important.
This technique is old and is not This technique is new and is mostly
preferred usually. preferred.
The requirements analysis stage strives to achieve an understanding of the client’s application
domain. The task that a software solution must address emerge in the course of requirement
analysis. The requirement analysis phase remains completely independent of any
implementation technique that might be applied later.
In the system specification stage, the wants’ definition describes what the software product must
do, but not how this goal is to be achieved.
One point of divergence from conventional phase model arises because implementation with
object-oriented programming is marked by the assembly of already existing components. The
class library serves as a tool that extends beyond the scope of an individual project because
class provided by one project can increase productivity in subsequent projects.
Advantages of Object-Oriented Life Cycle Model
1. Design is no longer carried out independently of the later implementation because during
the design phase we must consider which components are available for the solution of
the problem.
2. Design and implementation become more closely associated.
3. Duration of the implementation phase is reduced.
4. A new job title emerges, the class librarian, who is responsible for ensuring the efficient
usability of the class library.
Requirement Elicitation
Requirements elicitation is the process of gathering and defining the requirements for a software
system. The goal of requirements elicitation is to ensure that the software development process
is based on a clear and comprehensive understanding of the customer’s needs and
requirements. This article focuses on discussing Requirement Elicitation in detail.
1. Interviews
Objective of conducting an interview is to understand the customer’s expectations from the
software.
It is impossible to interview every stakeholder hence representatives from groups are selected
based on their expertise and credibility. Interviews maybe be open-ended or structured.
1. In open-ended interviews there is no pre-set agenda. Context free questions may be
asked to understand the problem.
2. In a structured interview, an agenda of fairly open questions is prepared. Sometimes a
proper questionnaire is designed for the interview.
2. Brainstorming Sessions
● It is a group technique
● It is intended to generate lots of new ideas hence providing a platform to share views
● A highly trained facilitator is required to handle group bias and group conflicts.
● Every idea is documented so that everyone can see it.
● Finally, a document is prepared which consists of the list of requirements and their
priority if possible.
Requirement Modeling
The technique of modeling requirements and solutions as they change through collaborative
work and cooperation is known as Requirements Modeling. You may ensure that your team
satisfies the stakeholders’ exact requirements by employing this approach of cross-functional,
self-organizing teams.
Requirements Modeling is the process of documenting, analyzing, and managing
Requirements. Requirements can be anything that a customer or user wants from a software
system. They can include functional requirements (what the system should do), non-functional
requirements (such as performance, security, etc.), as well as constraints (things that might limit
what the system can do).
Analysis Model is a technical representation of the system. It acts as a link between the
system description and the design model. In Analysis Modelling, information, behavior,
and functions of the system are defined and translated into the architecture, component,
and interface level design in the design modeling.
5. Process Specification:
It stores the description of each function present in the data flow diagram. It
describes the input to a function, the algorithm that is applied for the
transformation of input, and the output that is produced. It also shows regulations
and barriers imposed on the performance characteristics that are applicable to
the process and layout constraints that could influence the way in which the
process will be implemented.
6. Control Specification:
It stores additional information about the control aspects of the software. It is
used to indicate how the software behaves when an event occurs and which
processes are invoked due to the occurrence of the event. It also provides the
details of the processes which are executed to manage events.
I. Initiating: It determines high level requirements, the scope of the system and the
resources that will be required.
II. Developing: It involves the detailed analysis, design and implementation of the
system.
III. Deploying: It introduces the system to the user and subsequent maintenance of the
system.
Actor
● Someone interacts with use case (system function).
● Named by noun.
● Actor plays a role in the business
● Similar to the concept of user, but a user can play
different roles
● For example:
● A prof. can be instructor and also researcher
● plays 2 roles with two systems
● Actor triggers use case(s).
● Actor has a responsibility toward the system (inputs),
and Actor has expectations from the system (outputs).
Use Case
● System function (process - automated or manual)
● Named by verb + Noun (or Noun Phrase).
● i.e. Do something
● Each Actor must be linked to a use case, while some
use cases may not be linked to actors.
Communication Link
● The participation of an actor in a use case is shown by
connecting an actor to a use case by a solid link.
● Actors may be connected to use cases by
associations, indicating that the actor and the use case
communicate with one another using messages.
Boundary of system
● The system boundary is potentially the entire system
as defined in the requirements document.
● For large and complex systems, each module may be
the system boundary.
● For example, for an ERP system for an organization,
each of the modules such as personnel, payroll,
accounting, etc.
● can form a system boundary for use cases specific to
each of these business functions.
● The entire system can span all of these modules
depicting the overall system boundary
Structuring Use Case Diagram with Relationships
Use cases share different kinds of relationships. Defining the relationship between two use
cases is the decision of the software analysts of the use case diagram. A relationship between
two use cases is basically modeling the dependency between the two use cases. The reuse of
an existing use case by using different types of relationships reduces the overall effort required
in developing a system. Use case relationships are listed as the following:
Use Case Relationship Visual Representation
Extends
● Indicates that an "Invalid Password" use case may
include (subject to specified in the extension) the
behavior specified by base use case "Login Account".
● Depict with a directed arrow having a dotted line. The
tip of arrowhead points to the base use case and the
child use case is connected at the base of the arrow.
● The stereotype "<<extends>>" identifies as an extend
relationship
Include
● When a use case is depicted as using the functionality
of another use case, the relationship between the use
cases is named as include or uses relationship.
● A use case includes the functionality described in
another use case as a part of its business process
flow.
● A uses relationship from base use case to child use
case indicates that an instance of the base use case
will include the behavior as specified in the child use
case.
● An include relationship is depicted with a directed
arrow having a dotted line. The tip of arrowhead points
to the child use case and the parent use case
connected at the base of the arrow.
● The stereotype "<<include>>" identifies the
relationship as an include relationship.
Generalization
● A generalization relationship is a parent-child
relationship between use cases.
● The child use case is an enhancement of the parent
use case.
● Generalization is shown as a directed arrow with a
triangle arrowhead.
● The child use case is connected at the base of the
arrow. The tip of the arrow is connected to the parent
use case.
Use Case Examples