Oops

Post on 10-Jul-2015

704 views 0 download

Tags:

Transcript of Oops

Supported languages like C++, C#, Java

Examples:-Real world objects Replica in Prog world

Bank net banking

Shopping mall online shopping

Reservation counter online ticket booking

Developing a sw means We are copying the real world objects into the prog world, it means both the objects must look similar to each other.

Non object oriented languages like C failed in creating the exact replica of the real world object in prog world. So that’s why OOPS is invented.

With the following example we can prove, how a non object oriented lang is failed in creating the replica.

So firstly will see an example of shopping mall using

1. non object oriented language

2. object oriented language

So firstly we analyze a shopping mall

In Real World

Salesman Cashier Manager

Finally we need a collection of objects…

5 Sales Persons Describes product()

speak()

2 Managers Salaries()

speak()

2 Cashiers bill()

speak()

Without OOPS or in C language

Void main(){Speak();Salaries();}

String Speak(question){Return answer;}

int salaries(work done){Return salary;}

In previous code where are those

sales persons, managers and cashiers ?

Can you locate them????

So without OOPS we are able to see

Functions of our shopping mall members

But actual persons are really missing…

it means objects are really missing…

With OOPS we can see them and we can feel their presence.

With OOPS

Contd…

Class SalesPerson{

String DescibesProduct(question){Return answer;}

String Speak(question){Return answer;}

};

Class Cashier{

Int bill(products, rate){Return total bill;}

String Speak(question){Return answer;}

};

Void main(){

Manager Mahesh;Mahesh.Speak();

Cashier Neha;Neha.Bill();

SalesPerson Ram;SalesPerson Sam;SalesPerson Vicky;…etc

}

As our software is completely dependent on real world objects, to create exact replica, developers started analyzing the real world objects like pen, car, water bottle etc and finally they learned 4 principles & named them as OOPS.

They finally concluded that, if we satisfy all the 4 principles in our programming language then definitely we can create exact replica of real world objects.

But today we understanding OOPS in programmes but we are failing to analyze it in real world…

Encapsulation

Abstraction

Inheritance

Polymorphism

Every real world object like bag, mobile & pen-drive behaves like a container which is used for the purpose of storing & hiding the things.

This is called encapsulation.

So developers copied this principle in programming & they are achieving encapsulation through a kw called class.

Hiding all the things is not a good idea, so Every real world object like pen-drive is used for some purpose.

so exposing those necessary functions is called abstraction.

So developers copied this principle in programming & they are achieving abstraction through a access modifiers.

Each object in the real world is based on their ancestors/parents & they also deriving some common things from them.

example:- pen-drive object is derived some storing mechanisms from hard-disk object.

This is called inheritance.

So developers copied this principle in programming & they are achieving inheritance through a colon : symbol.

Each object in the real world behaves according to the situation.example:- a power button of an LCD monitor behaves as a power-off button if monitor is already switched on vice versa.

This is called polymorphism.

So developers copied this principle in programming & they are achieving polymorphism through a overloading & overriding.

Advantages:-

It is helpful in developing

Meaningful code.

Maintenance is easy.

Mapping with real world

Objects.

Q. Why it is required?

To map software product similar to real life

Product.

To develop meaningful code.

To increase Passion in programming

C lang + OOPS=

Modified

OOPS

C

C++

Java C##