The Four Pillars of Object Oriented Programming
The four pillars of object oriented programming are Abstraction, Encapsulation, Polymorphism and Inheritance. The way that I remember what these pillars are and what they do is by narrowing the definition to something that I can explain. The first two, I think go well together, are Abstraction and Encapsulation. Encapsulation allows for classes in an application to only be accessible to other classes through certain methods. The most common way of doing this is to keep an object and its properties private and allow access to that class using certain methods. Abstraction takes a robust application and ensures that only the high-level mechanisms for it are exposed to other functions. So there's no need to try to figure out everything that is happening with an object in order to communicate with it. There only needs to be exposure to the mechanisms that are relevant to other objects, essentially leaving all the other stuff encapsulated. Inheritance is a way to use existing code from a parent object so that you don't need to rewrite code over and over. The child object can have its own code as well as access to the code from the parent object. It inherits it, there's no need to rewrite it. And finally we have Polymorphism, did you know that Polymorphism means “many shapes” in Greek? Well, Polymorphism is cool because let's say that you have a few classes that inherit methods from a parent class. If you have a method implemented for the parent class?—?but you’d like to use it for the children as well, Polymorphism gives a way to do this without the confusion with mixing types. Each child class keeps its own methods as they are. This typically happens by defining a (parent) interface to be reused. It outlines a bunch of common methods. Then, each child class implements its own version of these methods.
The object-oriented version of spaghetti code is, of course, ‘lasagna code’. Too many layers.