Elements of Oops
Elements of Oops
Object-Oriented Programming is centered around the new concepts such as classes, polymorphism, inheritance, etc. it is a well suited paradigm for the following:
1. Modeling the real world problem as close as possible to the users perspective. 2. Interacting easily with computational environment using familiar metaphors 3. Constructing reusable software components and easily extendable libraries. 4. Easily modifying and extending impl ementations of components without having to recode every thing from scratch.
Definition of OOP:
OOP uses objects as its fundamental building blocks. Each object is an instance of some class. Classes allow the mechanism of data abstraction for creating new data types. Inheritance allows building of new classes from existing classes. Hence if any of these elements are missing in a program we cannot consider that program as objected oriented program.
Object oriented programming is a programming methodology that associates data structures with a set of operators which act upon it. In OOPs terminology an instance of such an entity is known as an object. It gives importance to relationships between objects rather than implementation details. Hiding the implementation details within an object results in the user being more concerned with an objects relationship to the rest of the system, than the implementation of the objects behavior.
Objects:
Objects are the basic run-time entities in an object-oriented system. Every object is associated with data and functions which define meaningful operations on that object.
What is Encapsulation
It is a mechanism that associates the code and the data it manipulates into a single unit to and keeps them safe from external interference and misuse. In C++ this is supported by construct called class. An instance of an object is known as object which represents a real world entity.
A data abstraction is a simplified view of an object that includes only features one is interested in while hides away the unnecessary details. In programming languages, a data abstraction becomes an abstract data type or a user-defined type. In OOP, it is implemented as a class.
What is Inheritance
Inheritance is a means of specifying hierarchical relationships between types C++ classes can inherit both data and function members from other (parent) classes. Terminology: "the child (or derived) class inherits (or is derived from) the parent (or base) class"
What is Polymorphism
Polymorphism is in short the ability to call different functions by just using one type of function call. It is a lot useful since it can group classes and their functions together. Polymorphism means that the same thing can exist in two forms. This is an important characteristic of true object oriented design - which means that one could develop good OO design with data abstraction and inheritance, but the real power of object oriented design seems to surface when polymorphism is used.
In C++, polymorphism means that if the same message is sent to different objects, the objects behavior depends on the nature of the object itself. This is sort of obvious for completely different objects, but the concept starts making sense when combined with inheritance.
It is the process of invoking an operation on an object. In response to a message the corresponding method is executed in the object.
What is Extensibility
C++ allows the extension of the functionality of the existing software components. In C++ this is achieved through abstract classes and inheritance.
What is Persistence
The phenomenon where the object (data) outlives the program execution time and exists between executions of a program is known as persistence. All data base systems support persistence. In c++ it is not supported. However the user can build it explicitly using file streams in a program.
What is Delegation
Delegation is a way of making object composition as powerful as inheritance. In delegation two objects are involved in handling a request a receiving object delegates operations to its delegate. This is analogous to child class sending requests to the parent class.
What is Genericity
It is technique for defining so ftware components that have more than one interpretation depending on the data type of parameters. Thus it allows the declaration of data items without specifying their exact data type.
The mechanism by which a class is derived from more than one base class is known as multiple inheritance. Instances of classes with multiple inheritance have instance variables for each of the inherited base classes. C++ supports multiple inheritance.