Tech Elevator Week 3: “The 4 Principles Of Object Oriented Programming”
It’s mind-blowing what I’ve learned in three short weeks at Tech Elevator.
Week 3 topics:
Monday: Inheritance + Resume Presentation
Tuesday: Polymorphism
Wednesday: Inheritance Part 2 + Side Project Presentation
Thursday: Unit Testing + Resume Workshop
Friday: Test-Driven Development + Panel Presentation: “Lessons I learned in My IT Career”
Recently we’ve been focused on object-oriented programming (OOP). The four principles of OOP are abstraction, encapsulation, inheritance, and polymorphism.
A Simple Explanation
Abstraction
Imagine starting a car. You turn a key or push a button and the engine starts. Everything works, but you don’t need to understanding what happens under the hood.
Abstraction in software engineering means exposing only the essential mechanisms while hiding the irrelevant detail from other parts of the application.
Encapsulation
Your circuit breaker is an example of encapsulation. When one circuit trips you can still have power in the rest of your house.
Encapsulation means binding data with the code that manipulates it. This modular approach makes code easier to test and maintain.
Inheritance
Cars, trucks, and motorcycles are all subclasses of vehicles. Sedans, minivans, and hatchbacks are subclasses of cars.
Inheritance means objects exist in a hierarchy that can pass on properties and methods. Inheritance allows developers to reuse code and therefore write less of it.
Polymorphism
Polymorphism means “many forms”.
Let’s say you want to compare the area of different shapes such as circles, triangles, and squares. They all calculate their area with a different formula.
However, if they inherit an abstract “getArea” method from an interface, they can be grouped together in a list because of this shared method.
Hopefully now you have high level understanding of the four principles of object-oriented programming! Do you have any questions for me?
Thanks for reading my latest post documenting my transition to the tech industry. This is week 3 of 14. I hope you’ll check out my previous posts and come back next week.
Kindly,
Garrett