The paradigm most widely used by programmers is object-oriented programming, because each of the elements that a system or software needs is an “object” which has its own data and behaviors or functionalities. In programming, this data is called “attributes” and functionalities are called “methods.”
Attributes can be data like name, surname, email address, password, if the user is a premium user or not.
Methods can be functionalities like logging in or out, editing a profile, changing a password, becoming a premium user, etc.
With object-oriented programming, we go from having a top-down code, in which functionalities are all mixed up, to having one in which elements (or objects) are separated but they communicate between them. This way, it’s easier to manage a system and make it grow.
This paradigm uses “classes” or “molds,” which are, in essence, the templates that have the object’s basic structure (its attributes and functionalities), so that the programmer doesn’t have to perform the same action a thousand times and it’s automated. This process is called “instantiation,” that, as mentioned, is basically creating an object from a template. Thus, each object can also be called an “instance.” That’s how we can create thousands of objects without having to write the code again.
How does the process of using these objects in a real app work?
As a paradigm, object-oriented programming is based on four pillars that are the basis of this process:
1. Abstraction: It’s the process of thinking about which attributes and which methods an object will have. When creating a system, we must define an abstraction for all classes.
2. Encapsulation: As objects are in continuous communication between them, security is needed to protect information from unauthorized manipulation. So, when communicating with each other, objects can follow certain paths, which allows to keep the system organized and secure.
3. Polymorphism: It means giving the same command to different objects and that each of them responds in its own way. When we want the same action, we can simplify the work by giving coherent commands to several objects without worrying about how they will carry them out.
4. Inheritance: There is a “parent” class and the child classes inherit functionalities and attributes from it, but they aren’t identical. They take advantage of what exists, but new things are added.
Thank you very much for getting here. We hope this material has been useful! If so, don’t forget to share the blog with your colleagues, like the post on social media or comment on your return.