Upload
pina-chhatrala
View
395
Download
1
Embed Size (px)
Citation preview
Object Oriented Programming
Concept
Prepared By : Pina Chhatrala
Introduction It is a type of programming in which programmers define not only the data
type of a data structure, but also the types of operations (functions) that canbe applied to the data structure.
In this way, the data structure becomes an object that includes both data andfunctions.
In addition, programmers can create relationships between one object andanother. For example, objects can inherit characteristics from other objects.
One of the principal advantages of object-oriented programming techniquesover procedural programming techniques is that they enable programmers tocreate modules that do not need to be changed when a new type of object isadded.
A programmer can simply create a new object that inherits many of its featuresfrom existing objects.
This makes object-oriented programs easier to modify.
2
Object Objects are the basic run-time entities in an object-oriented system.
When a program is executed, objects interact with each other by sendingmessages.
Different objects can also interact with each other without knowing the detailsof their data or code.
An object is an instance of a class.
A class must be instantiated into an object before it can be used in thesoftware.
More than one instance of the same class can be in existence at any one time.
3
Class A class is a collection of objects of a similar type.
Once a class is defined, any number of objects can be created which belong tothat class.
A class is a blueprint, or prototype, that defines the variables and the methodscommon to all objects of a certain kind.
4
Instance The instance is the actual object created at runtime.
One can have an instance of a class or a particular object.
5
State The set of values of the attributes of a particular object is called its state.
The object consists of state and the behaviour that's defined in the object'sclass.
6
Method Method describes the object’s ability.
A Bird has ability to Fly. So Fly() is one of the method of the Bird class.
7
Message Passing The process by which an object sends data to another object or asks the other
object to invoke a method.
Message passing corresponds to "method calling".
8
Abstraction Abstraction refers to the act of representing essential features without
including the background details or explanations.
Classes use the concept of abstraction and are defined as a list of abstractattributes.
9
Encapsulation It is the mechanism that binds together code and data in manipulates, and
keeps both safe from outside interference and misuse.
In short, it isolates a particular code and data from all other codes and data.
A well-defined interface controls the access to that particular code and data.
The act of placing data and the operations that perform on that data in thesame class.
The class then becomes the 'capsule' or container for the data and operations.
Storing data and functions in a single unit (class) is encapsulation.
Data cannot be accessible to the outside world and only those functions whichare stored in the class can access it.
10
Inheritance It is the process by which one object acquires the properties of another object.
This supports the hierarchical classification.
Without the use of hierarchies, each object would need to define all itscharacteristics explicitly.
However, by use of inheritance, an object need only define those qualities thatmake it unique within its class.
It can inherit its general attributes from its parent.
A new sub-class inherits all of the attributes of all of its ancestors.
11
Polymorphism Polymorphism means the ability to take more than one form.
An operation may exhibit different behaviours in different instances.
The behaviour depends on the data types used in the operation.
It is a feature that allows one interface to be used for a general class of actions.
The specific action is determined by the exact nature of the situation. Ingeneral, polymorphism means "one interface, multiple methods", This meansthat it is possible to design a generic interface to a group of related activities.
This helps reduce complexity by allowing the same interface to be used tospecify a general class of action.
It is the compiler's job to select the specific action (that is, method) as itapplies to each situation.
12
Generalization Generalization describes an is-a relationship which represent a hierarchy
between classes of objects.
Eg:- a “Bird" is a generalization of “Dove", “Sparrow", “Parrot" and manyothers.
13
Specialization Specialization means an object can inherit the common state and behavior of a
generic object.
However, each object needs to define its own special and particular state andbehavior.
Specialization means to subclass. Bird is the generalization and Sparrow is thespecialization, indicating that a Sparrow is a special kind of Bird.
14
Advantage of OOP OOP provides a clear modular structure for programs which makes it good for
defining abstract data types where implementation details are hidden and theunit has a clearly defined interface.
OOP makes it easy to maintain and modify existing code as new objects canbe created with small differences to existing ones.
OOP provides a good framework for code libraries where supplied softwarecomponents can be easily adapted and modified by the programmer.
15
Special Thankshttp://www.codeproject.com/Articles/27775/Object-Oriented-Programming-Concepts
16
Thank
You
17