I prefer to remember the four pillars by the acronym, APIE.

  • Abstraction
    The way that I started to understand Abstraction was to think of a process that I do on a daily basis, but don't ever stop to think about the complexities of it. I just know the first step to drive a car, is to get in and turn it on. I don't stop to think what happens when I turn the key or press the start button. It just cranks up, I put it in drive and go. Abstraction works the same way in code. You can build a helper method that lives in a different file, or call a service layer method that completes a set of instructions behind the scene. You can't see what those instructions are, but you know it's getting the job done.
  • Polymorphism
    Below, you'll read about Inheritance and how Child classes can take on from their parents. What can also happen once they inherit from their parent is that they can be added on to or change their original inherited items. For instance, in the example below, “Sedan” inherits from “Motor Vehicle”. With Polymorphism, you can change how many seats are in the car, what type of engine it has, and so much more. The fine tuning that can be done really shows how powerful Polymorphism can be.
  • Inheritance
    Figuring out Inheritance was one of the easier pillars for me. I didn't even really need to compare it to real world examples and hopefully I can convey it here without any jargon. To understand Inheritance, think of a parent Class called “Motor Vehicle”. inside the class it contains variables like “hasFourWheels”, “hasEngine”, and “hasSeats”. From here, you can create a child Class called “Sedan”, “Coupe”, or "SUV and they would all inherit the traits from the parent. You could then use Polymorphism to add on to what the child Classes contain.
  • Encapsulation
    Envisioning Encapsulation started to become easier when I compared it to companies that have a secret process or recipe for a product they make. Its when you make certain parts of your data private or hidden from the rest of the project. Think about the major cola brands. You know they use water, sweeteners, coloring, and artificial flavors for their products. What you don't know is the amounts, or how and when those ingredients are added along the way because it's private information. Similarly, we do the same with private methods or variables that don't need to be accessed outside of the file they're in.

 

 

0 Likes

It's Quiet.... Too Quiet

0 Comments

0 comments

Edit | Back to List