Object Oriented Programming Concepts C++ With Full Book Download in PDF ( By Tasleem Mustafa )
Object Oriented Programming (OOP) is a software paradigm based around the idea of “classes” and “adata”. An object Oriented programming system is one in which the data models and interactions between objects are defined by a tool that takes an object as an argument and produces a fully qualified and reusable application. The source code and/or modules are contained within the class or object itself. Typically, an OOP system has a generic or inherited type hierarchy whereby various types are identified and used to define entities.
OOPs differ from traditional procedural programming in that an object oriented programming system allows for both direct and indirect references to an abstract or base class or object. Direct references refer to functions or procedures which are specific to a single entity, such as an interface. Indirect references are implemented via interfaces and allow for both direct and indirect references to be implemented by sub-entities. An example of an object oriented programming concept is the dependency injection, where in an object oriented programming system, an instance is instantiated before any other processes.
Polymorphism is the ability to transform an object in a way that it can be dynamically accessed without qualification. For example, in Java, an object oriented programming language, a method can be defined which when executed will return a value of a certain type. The return type can be dependent on the arguments that were supplied during the call. For instance, if there is an object oriented programming technique, which uses an overloaded operator, the programmer may decide to change the operators so that they can return different types, for instance an int can be returned instead of a float when an int is needed rather than a float when a double is needed.
Another object-oriented programming concept is encapsulation. Encapsulation is the act of handling an abstract concept. In the case of an object-oriented language, an encapsulation can be achieved by defining and utilizing interfaces. When dealing with an imperative language, dealing with encapsulation is not as easy because the programmer must consider each possible syntactic syntax or keyword when determining how to encapsulate a variable or function. For an object-oriented programming concept however, the use of interfaces makes encapsulation easy.
Object Oriented Programming can be seen as a set of techniques that enable an individual to reuse code and implement the same object-oriented program from different perspectives. For example, let us look at an object oriented programming language that uses inheritance. Inheritance refers to the process where one entity is derived from another entity.
When inheritance is applied to an object oriented programming concept, it results in creating a new class that is derived from the parent class. Let us look at an example that will make a clearer understanding of encapsulation and inheritance. Consider the scenario of the parent class that has a method that calculates the minimum amount. If this method were encapsulated, the resulting class would only require the minimum amount as the base and could then be accessed as the resulting value. The resulting value would be encapsulated and this would make the method encapsulate the method as well.
The OOP concept then states that an object-oriented programming concept can be defined as a generic way to manage the usage of objects. As stated earlier, OOPs allow for reuse of code and the implementation of methods. However, as an object-oriented programming concept continues to evolve, the ability for code re-use decreases. As such, encapsulation can no longer be achieved as the original object oriented programming concept does not allow for it. This is the reason why encapsulation was introduced.
The final component of object-oriented programming involves the implementation of data members. Encapsulation allows one another to have a safe, secure interaction with the data members. A data member function usually returns a value and performs its duties only once the data member is accessed. Since data members are never reused, the possibility of data member corruption due to a memory error or system crash is greatly reduced.