A therapeutic approach to OOP(Object-oriented programming) - part 1
Sometimes, people tend to get sick or discouraged when they hear of OOP and I am even guilty of this as well. I remember when I started Android development using Java, doing the UI aspect wasn't a problem but when it came to the functionality of the app, I find myself struggling and my boss told me to go back and understand object oriented programming. As you advance in programming, you will notice that those OOP is a building block for you and when you don't understand it you tend to hook. Object-oriented programming is nothing really to be scared of! Let us look at it from a practical point of view, take a minute and look around you, what do you see? I am sure you will definitely see things like your tables, chairs, cars, trees, computers, phones, etc. if I should leave you, you will probably have more things to add to your list LOL. So the basic idea of this exercise is that all these things you see around you are objects and are real-life entities. These objects have their state and behavior, for example, the state of your phone will be phone name, type of phone, the color of the phone, etc and while the behavior will be calls, send messages, pictures, etc. You can do a little exercise as well and list the state and behavior of the objects around you.
The basic concept of OOPs is to create objects, re-use them throughout the program, and manipulate these objects to get results. The OOPs work with the concept of:
A class is a blueprint that describes what the object should look like. In a class you list all the fields, then the implementations.
Constructors are special methods, you can create an object and initialize it in a constructor.
An object is an actual entity that is created from that class.
This deals with hiding details from users. For example, when data is hidden it can only be accessed within that class and cant be accessed by other classes.
It's the ability of a variable, object to take different forms. For example, the word "run" when used with human, laptop, business, it means different things so the same applies to our program.
This is when an object takes the properties of the parent class. You can relate it also to us humans when we inherit some things from our parents such as height, complexion, etc so the same case applies here.
There is more OOPs concept like association, aggregation, abstraction but I will only be discussing the ones I listed above. OOP is not something you rush, you have to take your time to understand it and so now we have understood what OOP itself means, in my incoming articles, later on, I will be explaining each of the concepts I listed above weekly in details. So watch out for my articles on OOP. If you have any question don't hesitate to reach out and I will be happy to answer your questions.
3.4K+ developers have started their personal blogs on Hashnode in the last one month.
Write in Markdown · Publish articles on custom domain · Gain readership on day zero · Automatic GitHub backup and more