That was exactly the reason why the Object Oriented Programming Paradigm was introduced. Now, there are certain fundamental features that you would find in every object oriented programming language.

Lets now take a look at each of them individually,
Lets take up CLASSES first. They consists of entities called objects-or they are blueprints of objects.
For example, a car would be a class & a van would be an object that belongs to the class called cars. Now, once we know the behavior of this object, we can use it anywhere we need in the program without having to define the behavior/properties again & again, which is the basic aim of OOP.
The objects here act as building blocks of the program. Though the objects can differ in terms of specific attributes(like a van could be red or blue), the classes would only depict the common behavior of all objects(like each car would have 4 wheels, turn left, right & so on...)
Now, the basic features of OOP...
A) Polymorphism - It simply implies "something having various forms".
In the OOP world, this is evident with variables & functions.(and hence, with objects as well)
For instance, A variable called MEMBERID could take a name or a number & the program would recognize & accept both.
Another example is the "+" sign which can denote the mathematical operation, or strings or lists.
B) Inheritance - It is simply forming new classes(derived classes) from previously existing ones(base classes). In the process, the derived classes inherit certain properties of the base classes.
The concept is similar to how children inherit certain features from their parents, hence, the base classes are also sometimes refereed to as ancestor classes.
In terms of relationships, we call the relation between the base & derived class the as-is relationship. Consider the base class "car" & the derived class "bmw". Then we can say "bmw" is-a "car" which is generalized to "derived class" is-a "base class".
In one single statement, Abstraction is a technique that lets us know what information should be visible, and what information should be hidden. Encapsulation is the technique to display the information in a way as to hide what should be hidden, and show what's needed.
Then, Information Hiding is the process of hiding all the inessential details of an object.
No comments:
Post a Comment