[go: up one dir, main page]

0% found this document useful (0 votes)
60 views14 pages

Unit1 Oosd

Unit 1 AKTU Object-oriented System Design notes.

Uploaded by

Rishit Yadav
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
60 views14 pages

Unit1 Oosd

Unit 1 AKTU Object-oriented System Design notes.

Uploaded by

Rishit Yadav
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

1.

INTRODUCTION:
1.1 Object Orientation-
End users of computer systems as well as computer- based systems can notice the effects of object-oriented
design (OOD) in the form of increasingly easy-to-use-

➢ Software Applications
➢ Database Management Systems
➢ Operating System

Concepts of OOP are:


▪ Objects: These are the fundamental run-time sections that trade data once the program is sent off.
▪ Classes: Similar kinds of items are called classes.
▪ Inheritance: This is the precondition of reusability in OOP in light of the fact that legacy permits a
particular sort of object to procure the qualities of an article having a place with an alternate class.
▪ Polymorphism: It’s a component that addresses an item’s inclination to play out numerous tasks.
▪ Data encapsulation and abstraction: This empowers the framework to uncover basic elements without
the need to give any extra subtleties.
Structured Programming and object-oriented programming (OOP) are different in the following aspects:
Structured programming views the two core elements of any program, i.e.,Data and Functions as two separate
entities whereas object-oriented programming views them as a single entity.

1.2 Procedural oriented programming-

In this programming, the program can be decomposed into functions.

The important features of procedural oriented programming as follows:

• Emphasis is given on algorithms rather than data.


• Larger programs are divided into smaller sub programs known as functions.
• Data declared globally can be accessible by all functions.
• Local data can be visible only in a given functions.
• Data move from function to function around the system.

Examples of procedural oriented programming includes-Pascal, Fortan, C, etc.


1.3 Object oriented programming-

In object-oriented programming (OOP), more emphasis is given to the data rather than functions. In OOP,
data is encapsulated with the associated functions that operate on it. Thatgives rise to a concept called data
encapsulation. In OOP, the real-life problem can be decomposed into a number of entities called Objects and
then data and functions are built around these objects. The organization of data and functions in an object-
oriented programming is shown in fig.

The important features of object-oriented programming as follows:

• Emphasis on data rather than algorithm.


• Programs are divided into objects.
• Data abstraction introduced.
• Data and associated functions are tied together into a single unit.
• Data is hidden and is not accessible to the external functions.
• Object communication takes place using functions.
• Further data and functions can be added without disturbing the existing code.

Examples of object-oriented programming includes-C++, Smalltalk, Java, Simula and Eiffel.


Difference between Procedural Programming and Object-Oriented Programming:
PROCEDURAL ORIENTED OBJECT ORIENTED
PROGRAMMING PROGRAMMING

In procedural programming, program In object-oriented programming,


is divided into small parts program is divided into small parts
called functions. called objects.

Procedural programming follows top Object oriented programming


down approach. follows bottom up approach.

There is no access specifier in Object oriented programming have


procedural programming. access specifiers like private, public,
protected etc.

Adding new data and function is not Adding new data and function is
easy. easy.
Procedural programming does not Object oriented programming
have any proper way for hiding data provides data hiding so it is more
so it is less secure. secure.

In procedural programming, Overloading is possible in object


overloading is not possible. oriented programming.

In procedural programming, function In object-oriented programming, data


is more important than data. is more important than function.
Procedural programming is based Object oriented programming is
on unreal world. based on real world.

Examples: C, FORTRAN, Pascal,etc Examples: C++, Java, Python, C# etc


OBJECT-ORIENTED MERITS AND DE-MERITS:

Merits:
• Easier Troubleshooting
• Code Reusability
• Data Redundancy
• Code Flexibility
• Polymorphism Flexibility
• Better Productivity
• Security

Demerits:
• It requires more data protection.
• Inadequate for concurrent problems
• Inability to work with existing systems.
• Compile time and run time overhead.
• Unfamiliarity causes training overheads.
What do you understand by object identity
Object identity is a property of data that is created in the context of an object data model, where an object
is assigned a unique internal object identifier, or oid. The object identifier is used to define associations
between objects and to support retrieval and comparison of object-oriented data based on the internal
identifier rather than the attribute values of an object.

• In an object data model, an object is created as an instance of a class. An object has an object identifier
as well as a state.
• An object identifier is immutable, meaning that the value of the object identifier cannot change over the
lifetime of the object.
• The state, on the other hand, is mutable, representing the attributes that describe the object and the
relationships that define associations among objects.
• Relationships in an object data model are defined using object references based on internal object
identifiers rather than attribute...

Class: A class in C++ is the building block that leads to Object-Oriented programming. It isa 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 C++ class is like a blueprint for 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 applying brakes, increase speed etc.

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.
ENCAPSULATION:
Encapsulation is one of the key features of object-oriented programming. It involves the bundling of data
members and functions inside a single class. Bundling similar data members and functions inside a class
together also helps in data hiding.

C++ Encapsulation: In general, encapsulation is a process of wrapping similar code in one place. In C++, we
can bundle data members and functions that operate together inside a single class. For example,

class Rectangle {
public:
int length;
int breadth;

int getArea() {
return length * breadth;
}
};
In the above program, the function getArea() calculates the area of a rectangle. To calculate the area, it needs
length and breadth.
Hence, the data members (length and breadth) and the function getArea() are kept together in
the Rectangle class.
Why Encapsulation?
• In C++, encapsulation helps us keep related data and functions together, which makes our code cleaner
and easy to read.
• It helps to control the modification of our data members.
Consider a situation where we want the length field in a class to be non-negative. Here we can make
the length variable private and apply the logic inside the method setAge(). For example,

class Rectangle {
private:
int age;

public:
void setLength(int len) {
if (len >= 0)
length = len;
}
};

• The getter and setter functions provide read-only or write-only access to our class members. For
example,
getLength() // provides read-only access
setLength() // provides write-only access

• It helps to decouple components of a system. For example, we can encapsulate code into multiple
bundles.

These decoupled components (bundles) can be developed, tested, and debugged independently and
concurrently. And any changes in a particular component do not have any effect on other components.

• We can also achieve data hiding using encapsulation. In Example 1, if we change


the length and breadth variables into private or protected, then the access to these fields is restricted.
And, they are kept hidden from outer classes. This is called data hiding.

How Encapsulation is achieved in a class


To do this:
1) Make the entire data members private.
2) Create public setter and getter functions for each data member in such a way that the setfunction set
the value of data member and get function get the value of data member.

In normal terms Encapsulation is defined as wrapping up of data and information under a single unit. In
Object Oriented Programming, Encapsulation is defined as binding together the data and the functions that
manipulates them.

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 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”.
Information/Data Hiding:
• Data hiding is a way of restricting the access of our data members by hiding the implementation details.
Encapsulation also provides a way for data hiding.
• Is the process whereby the details that show how the programmed program came into function are hidden
to avoid access of these details of function to the public users, so it is private and protected act.
• We can use access modifiers to achieve data hiding in C++.

• It supports information hiding by allowing private: and protected: sections in class declarations.
• A "supported" way to violate it is via the friend keyword, that allows external functions or classes to
access the private and protected members of a class (although it's debatable if that's actually a
"violation").

Also, in a C++ program there's no runtime enforcing of the visibility rules, so if you manage to get a
pointer to an internal field or a function pointer to an internal method nothing stops you from using it
(again, this may be intentional - the class itself gave you that pointer - or "abusive" - you have a pointer
to the object itself and add some offset to get to an internal member).
POLYMORPHISM:
Polymorphism is the ability of any data to be processed in more than one form. Polymorphism is one
of the most important concepts of object-oriented programming language. The most common use
of polymorphism in object- oriented programming occurs when a parent class reference is used to refer to a
child class object.

For example, you have a Smartphone for communication. The communication mode you choose could be
anything. It can be a call, a text message, a picture message, mail, etc. So, the goal is common that is
communication, but their approach is different. This is called Polymorphism.

Real life example of polymorphism, a person at the same time can have different roles toplay in life. Like
a woman at the same time is a mother, a wife, an employee and a daughter. So, the same person has to have
many features but has to implement each as per the situation and the condition. 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

• Polymorphism means to process objects differently based on their data type.


• In other words, it means one method with multiple implementations, for a certain class of action. And
which implementation to be used is decided at runtime depending uponthe situation (i.e., data type of the
object)
• This can be implemented by designing a generic interface, which provides generic methods for a certain
class of action and there can be multiple classes, which provides the implementation of these generic
methods.
What do you mean by modeling?
1. A model is an abstraction of something for the purpose of understanding it before building it.
2. Since a model leave out non-essential detail, it is easier to manipulate them.
3. To build hardware and software systems, the developer needs to:
i. Abstract different views of the system.
ii. Build models using precise notations.
iii. Make sure that the model satisfies the requirements of the system.
iv. Add details to transform the model into an implementation.
4. Model serves the following purpose:

a. Testing a physical entity before building it:


i. Simulating a model is cheaper. Also, it provides information that is too inaccessible to be measured from
physical model
ii. Computer models are usually cheaper than building a complete system and it enable flaws to be corrected
early.
For example: Scale models of airplane and cars are tested in wind tunnels to improve their aerodynamic.

b. Communication with customers:


i. Software designers build models to show their customers.
For example: Demonstration products like mock-ups that imitate some or all of the external behavior of
a system

c. Visualization:
i. Storyboards of movies, television shows, and advertisements allow the writers to see how their idea flows.
ii. Using models unnecessary segments can be modified before the final development begins.
d. Reduction of complexity:
i. Modeling helps in understanding the systems that are too complex to understand directly.
ii. Model reduces complexity by leaving out the non-essential details
Object oriented modelling:

Object Modeling Techniques (OMT)


• It was one of the first object-oriented methodologies and was introduced by Rumbaugh in 1991.
• OMT uses three different models that are combined in a way that is analogous to the older structured
methodologies.

a. Analysis
• The main goal of the analysis is to build models of the world.
• The requirements of the users, developers and managers provide the information needed to develop the
initial problem statement.
b. OMT Models

I. Object Model
II. Dynamic Model
III. Functional Model

c. Design
• It specifies all of the details needed to describe how the system will be implemented. Manipulators are helping
functions. It is used to manipulate or modify the input or output stream. The modification is possible by using the
insertion (<<) and extraction (>>) operators.

There are three types of models in object-oriented languages are:


1. Object model:
a. The object model identifies the classes in the system and their relationship, as well as their attributes and operations.
b. It represents the static structure of the system. The object model is represented graphically by a class diagram.
2. Dynamic model:
a. The dynamic model indicates the dynamics of the objects and their changes in state.
b. The dynamic model captures the functional behavior of the system by exploring the behavior of the objects over
time and the flow of control and events among the objects.
3. Functional model:
a. The functional model is a data flow diagram of the system and describes what the system does, not how it is done.
b. A DFD is a network representation of the system to show the functional relationships of the values that are
computed by a system.
a. c. Data flow diagrams consist of processes, data flows, actors and data stor
What Does Object-Oriented Modeling (OOM) Mean?

• Object-oriented modelling (OOM) is the construction of objects using a collection of objects that
contain stored values of the instance variables found within an object. Unlike models that are
record-oriented, object-oriented values are solely objects.

• The object-oriented modelling approach creates the union of the application and database development
and transforms it into a unified data model and language environment. Object-oriented modeling
allows for object identification and communication while supporting data abstraction, inheritance
and encapsulation.

• Object-oriented modeling is the process of preparing and designing what the model’s code will
actually, look like. During the construction or programming phase, the modeling techniques
are implemented by using a language that supports the object-oriented programming model.
Need of Object-Oriented Data Model:
To represent the complex real-world problems there was a need for a data model that is closely related to
real world. Object Oriented Data Model represents the real-world problems easily.
Advantages of Object-Oriented Data Model:
• Codes can be reused due to inheritance.
• Easily understandable.
• Cost of maintenance can reduce due to reusability of attributes and functions because of
inheritance.
Disadvantages of Object-Oriented Data Model:
• It is not properly developed so not accepted by users easily.

Conceptual Model of the Unified Modeling Language (UML)


The Unified Modeling Language (UML) is a standard visual language for describing and modelling
software blueprints. The UML is more than just a graphical language. Stated formally, the UML is for:
Visualizing, Specifying, Constructing, and Documenting. The artifacts of a software-intensive system
(particularly systems built using the object-oriented style).
Three Aspects of UML:

Note – Language, Model, and Unified are the important aspect of UML as described in the map above.

1. Language:
• It enables us to communicate about a subject which includes the requirements and the system.
• It is difficult to communicate and collaborate for a team to successfully develop a system without a
language.
2. Model:
• It is a representation of a subject.
• It captures a set of ideas (known as abstractions) about its subject.

3. Unified:
• It is to bring together the information systems and technology industry’s best engineering practices.
• These practices involve applying techniques that allow us to successfully develop systems.

A Conceptual Model:
A conceptual model of the language underlines the three major elements:

• The Building Blocks


• The Rules
• Some Common Mechanisms
• Once you understand these elements, you will be able to read and recognize the models
as well as create some of them.

Building Blocks:
The vocabulary of the UML encompasses three kinds of building blocks:
1. Things:
Things are the abstractions that are first-class citizens in a model; relationships tie these things
together; diagrams group interesting collections of things.
There are 4 kinds of things in the UML:
1Structural things
2. Behavioral things
3. Grouping things
4. A notational things
These things are the basic object-oriented building blocks of the UML. You use them to write well-
formed models.
2. Relationships:
There are 4 kinds of relationships in the UML:
1. Dependency
2. Association
3. Generalization
4. Realization
These relationships are the basic relational building blocks of the UML.

3. Diagrams:
It is the graphical presentation of a set of elements. It is rendered as a connected graph of vertices
(things) and arcs (relationships).
1. Class diagram
2. Object diagram
3. Use case diagram
4. Sequence diagram
5. Collaboration diagram
6. State chart diagram
7. Activity diagram
8. Component diagram
9. Deployment diagram

Rules:
The UML has a number of rules that specify what a well-formed model should look like. A well-formed
model is one that is semantically self-consistent and in harmony with all its related models.
The UML has semantic rules for:
1. Names – What you can call things, relationships, and diagrams.
2. Scope – The context that gives specific meaning to a name.
3. Visibility – How those names can be seen and used by others.
4. Integrity – How things properly and consistently relate to one another.
5. Execution – What it means to run or simulate a dynamic model.

Relationships in the UML


There are four kinds of relationships in the UML:
1. Dependency
2. Association
3. Generalization
4. Realization

First, a dependency is a semantic relationship between two model elements in which a change to
one element (the independent one) may affect the semantics of the other element (the dependent
one). Graphically, a dependency is rendered as a dashed line, possibly directed, and occasionally
including a label

Second, an association is a structural relationship among classes that describes a set of links, a link being
a connection among objects that are instances of the classes. Aggregation is a special kind of
association, representing a structural relationship between a whole and its parts. Graphically, an association
is rendered as a solid line, possibly directed, occasionally including a label, and often containing
other adornments, such as multiplicity and end names.

Third, a generalization is a specialization/generalization relationship in which the specialized element


(the child) builds on the specification of the generalized element (the parent). The child shares the structure
and the behavior of the parent. Graphically, a generalization relationship is rendered as a solid line with a
hollow arrowhead pointing to the parent.
Fourth, a realization is a semantic relationship between classifiers, wherein one classifier specifies a
contract that another classifier guarantees to carry out. You'll encounter realization relationships in two
places: between interfaces and the classes or components that realize them, and between use cases and
the collaborations that realize them. Graphically, a realization relationship is rendered as a cross between
a generalization and a dependency relationship.

• Composition: Foo has a Bar object as data member -> Foo contains a Bar. It can't exist without it.
• Aggregation: Foo has a pointer to Bar object and manages the lifetime of that object -> Foo
contains a Bar, but can also exist without it.

You might also like