oops

22
Supported languages like C++, C#, Java

Upload: snehatbangre

Post on 10-Jul-2015

704 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: Oops

Supported languages like C++, C#, Java

Page 2: Oops
Page 3: Oops

Examples:-Real world objects Replica in Prog world

Bank net banking

Shopping mall online shopping

Reservation counter online ticket booking

Page 4: Oops

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.

Page 5: Oops

So firstly will see an example of shopping mall using

1. non object oriented language

2. object oriented language

Page 6: Oops

So firstly we analyze a shopping mall

In Real World

Salesman Cashier Manager

Finally we need a collection of objects…

Page 7: Oops

5 Sales Persons Describes product()

speak()

2 Managers Salaries()

speak()

2 Cashiers bill()

speak()

Page 8: Oops

Without OOPS or in C language

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

String Speak(question){Return answer;}

int salaries(work done){Return salary;}

Page 9: Oops

In previous code where are those

sales persons, managers and cashiers ?

Can you locate them????

Page 10: Oops

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.

Page 11: Oops

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;}

};

Page 12: Oops

Void main(){

Manager Mahesh;Mahesh.Speak();

Cashier Neha;Neha.Bill();

SalesPerson Ram;SalesPerson Sam;SalesPerson Vicky;…etc

}

Page 13: Oops

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.

Page 14: Oops

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

Page 15: Oops

Encapsulation

Abstraction

Inheritance

Polymorphism

Page 16: Oops

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.

Page 17: Oops

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.

Page 18: Oops

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.

Page 19: Oops

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.

Page 20: Oops

Advantages:-

It is helpful in developing

Meaningful code.

Maintenance is easy.

Mapping with real world

Objects.

Page 21: Oops

Q. Why it is required?

To map software product similar to real life

Product.

To develop meaningful code.

To increase Passion in programming

Page 22: Oops

C lang + OOPS=

Modified

OOPS

C

C++

Java C##