Date post: | 19-Jan-2015 |
Category: |
Technology |
Upload: | sanchit-saini |
View: | 9,942 times |
Download: | 7 times |
A Presentation on-
OBJECT ORIENTED PROGRAMMING
O.O.P. is favoured so much as it overcomes the limitations of other programming paradigms.
LIMITATION OF PROCEDURAL PROGRAMMING-
As it focuses on the procedure taken rather than the data, it is susceptible to design changes and leads to increased time and cost overheads during these. It doesn’t incorporate data reusability.
LIMITATION OF OBJECT BASED PROGRAMMING-
It is a subset of OOP, but, it fails to represent real world relationships that exist b/w objects as it doesn’t incorporate “inheritance”.
Why Object Oriented
Programming ?
HOW DOES O.O.P. WORK
The concepts that O.O.P. incorporates helps it work on the limitations of other programming paradigms. These are-
Data abstraction
Data encapsulation
Modularity
Inheritance
Polymorphism
The general concepts of
Object Oriented
Programming concepts in
C++
DATA ABSTRACTIONDefinition-
The act of representing essential features without including the background details or explanations.
Levels of abstraction-
Physical level: The lowest level of abstraction describes how a system actually stores data.
Logical level: The next higher level of abstraction describes what data the database stores, and what relationships exist among those data .
View level: The highest level of abstraction describes only part of the entire database
Diagram showing the levels of abstraction
Example of Data Abstraction
A Sales Person
Real world
Genetic history Name
Cars sold
Talents
Credit record
Family
Commission rate
Medical history
Example of Data Abstraction
A Sales Person
Cars sold
Name
Commission rateAbstraction for sales tracking system
DATA ENCAPSULATIONDefinition –
The wrapping up of data and functions into a single unit (which is called class).
Encapsulation means that some or all of an object's internalstructure is "hidden" from the outside world.
Hidden information may only be accessed through theobject's methods, called the object's public interface.
Access to object is safe, controlled.
Example of Data Encapsulation
HR dept.
AccountsDept.
Purchase dept.
Production dept.
Sales dept..
Head of dept.Supervisors
WorkersClerks
Records and folders
Internal structure of dept.
Quality Dept.
Various departments of a company
Encapsulation for class builders and class users.
MODULARITYDefinition-
It is the property of a system that has been decomposed into a set of cohesive and loosely coupled modules.
Importance-
1) It reduces the complexity to some degree.
2) It creates a number of well-defined, documented boundaries within the program (known as sub-routines).
How it is implemented in C++ -
In C++, it is implemented through separately compiled files, namely, the header files. These can be used in programs through the #include directive.
Example of Modularity
Home theatre
Even though the parts of the home theater are complete units in themselves, yet they are a subpart of the home theater.
Example of Modularity in C++
The use of data as
is also modularity.
INHERITANCEDefinition-
It is the capability of one class to inherit capabilities or properties from another class.
Importance-
1) It ensures closeness with the real world.
2) It implements the idea of reusability.
3) It is transitive in nature.
Major advantage-
If a class B is inheriting from another class A and class C is inheriting from class B (thus, A becomes the base class).If we later find a mistake in class A and rectify it, it is automatically reflected in the classes B and C too. This reduces overhead costs and time which were a major problem in Procedural Programming.
Inheritance Schemes
Example of Inheritance
Vehicles
Automobiles(motor driven)
Pulled vehicles
Rickshaw
CartBusCar
POLYMORPHISMDefinition-
The ability for a message or data to be processed in more than one form
The simplest way to define it is- “ONE ENTITY, MANY FORMS”
Means the same name can be assigned to differentfunctions/methods: the actual function triggered by thename is determined by the types of the arguments.
It is sometimes called overloading.
It allows designers to use the most "natural" and understandablenames for functions. Example-
Example of Polymorphism
Mammals Mammals
Whale
Man
Dog
Rat
Cat
RatCat
See through daylight See through darkness
Polymorphism for class builders and class users.
Advantages and
disadvantages of Object Oriented
Programming concepts
Advantages of OOP
•Quick development as parallel development of classes is possible.•Reusability.•Easier to test manage and maintain•Easy to understand.•Models the real world well.
Disadvantages of OOP
•Design is tricky.•Overly generalized classes.•Proper planning and design is required•Artificial at times.•Needs proper skills such as programming skills, thinking in terms of objects..
Thank
You