There is a rising concern in the software world that OOP is disappearing. Being avid Java fans here, at H2K Infosys, we decided to delve deeper and find out the truth behind it. So, let’s see the good and bad of object-oriented programming. And why the world thinks that OOP is likely to vanish. Keeping the prejudices apart, if you happen to be a die-hard Java fan, learn Java online from H2K Infosys.
The three pillars of OOP
Java is one programming language that is essentially built around OOP. Encapsulation, Polymorphism, and Inheritance are its three pillars.
The concept of encapsulation is all about hiding the data under a specific head.
Polymorphism is the feature that enables the existence of the variable/object/function in many forms.
Inheritance is the mechanism through which the child/subclass inherits the properties of the parent/superclass.
Although other programming languages such as C++, .NET strongly support OOP, what they really do is support after all. For one, C++ is a hybrid language offering both object-oriented programming as well as functional programming. And .NET platform, on the other hand, although manages to support OOP, we are not going much far with it.
However, the debate here is not about which is a better OOP language or for how long they have been in existence. The point here is whether OOP will survive in competition.
Is it the downfall of OOP?
Inheritance seems to be the weakest link in the OOP model. Why? One of the biggest reasons why inheritance could be a failure is the loosely developed concept of the superclass. A subclass is completely dependant on how the superclass is defined. And, any change that takes place in the superclass spoils the behavior of the subclass.
When the variables or the methods are public, then the purpose of encapsulation which is to protect the data is not served. These entities are anyway available to all the classes in that package.
The best way to accomplish encapsulation and inheritance together is when the variables are declared as private and the methods are public. That’s the only way to access the private variables defined in a class by the subclass. But, these private entities are restricted to the package. They are not accessible outside it.
However, declaring the variables, methods, and constructors as protected resolves most of the issues. Only the subclasses which extend the superclass within the package or outside the package can access these entities. No other class can access these protected entities.
Therefore, any change in declaring the variables in the superclass directly affects the functionality of the subclass and ultimately influences the concept of inheritance.
So, is OOP dying?
On the whole, OOP has its disadvantages. At the same time, there is no perfect alternative either that can replace OOP any time soon.
Final Verdict: It is more of an inclination of the programmers towards other computer languages which has triggered this apprehension that OOP is dying. We would say it is rather a baseless belief than reality.
Enroll for Java online course at www.h2kinfosys.com. Don’t forget to request for a demo before you decide if Java is the right course for you.