2. About
Basics of OOPs started in the early 1960s at MIT.
First Programming language to use objects was Simula-67.
Developed by Kristen Nygaard and Ole-Johan Dahl in Norway.
The term "object oriented programming " was first used by Xerox
PARC in their Smalltalk programming language
Niklaus Wirth and his team were looking Modular programming
and data abstraction.
They developed two systems with Modular programming and data
abstraction.
* Oberon *Modula 2
5. Objects
Objects are the things you think about first in designing a
program .
They are also the units of code that are eventually derived from the
process.
Each object is an instance of a particular class or subclass with the
class's own methods or procedures and data variables.
Syntax: ClassName ObjectName;
When a class is defined, no memory is allocated but when it is
instantiated (i.e. an object is created) memory is allocated.
6. Example of Object
When we take a mobile as an object, its basic functionality for which it
was invented were Calling & Receiving a call & Messaging. But now a
days thousands of new features & models were added & the count is still
increasing.
7. Classes
The building block of C++ that leads to Object Oriented
programming is a Class.
It is a user defined data type, which holds its own data members
and member functions,
It can be accessed and used by creating an instance of that class.
A class is like a blueprint for an object.
It serves as a template for creating, or instantiating, specific
objects within a program.
Several programming languages support classes,
including Java, C++, Objective C, and PHP 5 and later
8. Example of Classes
A Class is a plan which describes the object. We call it as a blue print of
how the object should be represented. Mainly a class would consist of a
name, attributes & operations. Considering the above example, A Mobile
can be a class which has some attributes like Profile Type, IMEI Number,
Processor, and some more.) & operations like Dial, Receive & Send
Message.
9. Abstraction
The process of removing physical spatial or temporal details
Attributes in the study of object or system in order to more
closely attend to other details of interest
it is also very similar in nature to the process
of generalization.
the abstract concept-objects which are created by keeping
common features .
attributes to various concrete objects or systems of study.
Abstraction, in general, is a fundamental concept to
computer science and software development.
10. Abstraction of example
• Dialing a number call some method internally which concatenate the numbers and
displays it on screen but what is it doing we don’t know.
• Clicking on green button actual send signals to calling person’s mobile but we are unaware
of how it is doing.
• This is called abstraction where creating method which is taking some parameter &
returning some result after some logic execution without understating what is written
within the method
11. Encapsulation
In object oriented programming
languages, encapsulation is used to refer to one of two
related but distinct notions, and sometimes to the
combination.
A language mechanism for restricting direct access to
some of the object's components.
A language construct that facilitates the bundling of data
with the methods or other functions operating on that
data.
12. Encapsulation of example
Let’s say Samsung mobile have the 5MP camera available i.e. – it is having a
functionality of Camera Click(). Now same mobile is having Panorama mode
available in camera, so functionality would be same but with mode. This type is
said to be Static polymorphism or Compile time polymorphism. Compile time
polymorphism the compiler knows which overloaded method it is going to call.
.
Another point where in Send Message was intended to send message to single
person at a time but suppose Nokia had given provision for sending message to
a group at once. i.e. - Overriding the functionality to send message to a group.
This type is called Dynamic polymorphism or Runtime polymorphism.
13. Inheritance
In object-oriented programming, inheritance is the
mechanism of basing an object .
class upon another object prototypal inheritance.
In most class-based object-oriented languages, an object
created through inheritance (a "child object") acquires all
the properties and behaviors of the parent object.
The relationships of objects or classes through inheritance
give rise to a directed graph.
14. Inheritance of example
• Above fig. shows what is inheritance. Basic Mobile functionality is to
Send Message, dial & receive call. So the brands of mobile is using this
basic functionality by extending the mobile class functionality and adding
their own new features to their respective brand.
15. Overloading
• Function overloading or method overloading is the ability to
create multiple methods of the same name with different
implementations.
• To call the latter an object must be passed as a parameter whereas
the former does not require a parameter and is called with an
empty parameter field.
Calls to an overloaded function will run a specific
implementation of that function appropriate to the context of the
call.
16. Overloading of example
In this example they (that family) hire some
painter who knows only painting. If this family
provides different types of statues to this painter
then he has to do the work. In this way we can
achieve overloading.
In this example first brush is used to give a
color and after finishing color of whole statue,
this brush gets cleaned by using water & used
for removing shadu from small surface area
like between finger, below eye, between legs,
corner of legs / hands, etc.
In this case brush is used as an operator.
17. Exception Handling
Exception handling is the process of responding to the
occurrence, during computation, of exceptions – anomalous or
exceptional conditions requiring special processing – often
changing the normal flow of program execution
exceptions are a powerful mechanism for centralized processing
of errors and exceptional situations.
This mechanism replaces the procedure-oriented method of
error handling in which each function returns a code indicating
an error or a successful execution.
18. Example of Exception Handling
You provide a web form for users to fill in and submit but incase there
are a lot of conditions to be handled and the conditions keeps changing
periodically, you use exception handling to simplify the process
Database connectivity uses exception handling(why???) this is because
the reason for database connectivity failure cannot be predicted and
handled as it can be caused by many variables such as power failure,
unreachable server,failure at client front/back end and so on.
Internet communication
Arithmetic exceptions such as division by zero and so on.
Operating systems use exception handling to resolve deadlocks,recover
from crash and so forth
19. Polymorphism
Polymorphism is the way in which we can define a multiple
function in a single name. i.e single name & multiple meaning.
Polymorphism means assigning a single name but there can be
multiple behaviors. Means name of the function is same but its
definitions are different.
Polymorphism means single name & multiple meaning &
whenever we try to access that particular name there must be a
binding between that call & between that function, so there are
two types of binding to call that function.
20. Example of polymorphism
Suppose if you are in class room that time you behave like a student,
when you are in market at that time you behave like a customer, when
you at your home at that time you behave like a son or daughter, Here
one person present in different-different behaviors.
We behave differently in front of elders, and friends. A single person is
behaving differently at different time.
A software engineer can perform different task at different instance of
time depending on the task assigned to him .He can done coding ,
testing , analysis and designing depending on the task assign and the
requirement.
.