Just A Refresher For OOP Concepts

Hello and welcome back to my blog! I had a really fun time during the first few weeks of the semester and I am looking forward to the rest of it. The first POGIL group activity we did caught me off guard since I did not remember what the terms abstraction, encapsulation, polymorphism, and inheritance meant. These concepts were taught in one of the earlier programming classes and I have done school projects and labs that involved these concepts in the past. But I don't actually remember the terms or the clear cut definitions of them. Maybe part of the reason why I did not remember them is because we briefly went over those topics and we were also not forced to remember them since those classes were more about if you could write the code correctly. So that is why I decided to focus my blog around those four concepts. The in-class activity was a good refresher but I wanted to do research to fully have a firm understanding of them. Having a strong understanding of these concepts will help me later on in my computer science journey since these concepts are going to be seen over and over again in object orientated programming.

Let's start with abstraction. Abstraction is basically hiding unnecessary details and leaving only the necessary and relevant details. Hiding unnecessary information is useful because, well, it is not needed to show that information to the user. An example in real life is your smart phone. All that's important to the user is the screen and they do not need to know what processor or how much RAM the phone has.

Encapsulation is bundling data with the code that modifies the data and it can also prevent outside sources from accessing that data. In Java, encapsulation is used in classes where data can be declared as private and outside methods cannot access that data.

Polymorphism is the ability to take on many forms. In Java, that means you can perform one tank many ways. An example of that is calculating the area of a shape. You can use the same method area() to calculate the area of a triangle, octagon, or any other shape. There's also overriding methods where the child class has the same method as the parent class.

Inheritance is gaining the properties of one class to another class. It's like a parent-child relationship. In Java, a child class inherits all the methods and attributes from its parent class. The vehicle example is a really good one. Vehicle would be the parent class and car and truck would be the child classes. Both car and truck would share the same attributes from vehicle but also have their own attributes as well.

This has been a good review for me and the website really helped me understand what the four OOP concepts are. In the future I hope to apply all of these concepts into my work.

Site used: https://www.nerd.vision/post/polymorphism-encapsulation-data-abstraction-and-inheritance-in-object-oriented-programming

 

Comments

Popular posts from this blog

YAGNI.

SOLID Principles