In the next video, you will learn about two of the most widely used paradigms to develop a system: procedural programming and object-oriented programming.
In the previous video, you learned about procedural paradigm and object-oriented paradigm to build software. In procedural programming, an application is visualized as a sequence of steps, whereas in object-oriented programming, an application is visualized as a group of objects. Because a system is designed in a sequence of steps, the procedural approach becomes difficult when you want to evolve your system, as adding a new step in between may break all steps afterwards. But this is not the case with the object-oriented approach, where everything is visualized as an object and adding new functionality is like adding a new object. So if you have to develop a system, object-oriented programming is a better choice than procedural programming. Because of this, most of the systems today are developed in object-oriented programming languages, such as Java and C++.
Now that we understand requirements of a product that we are going to build now let's say how do I go ahead building it, how do I implement it? Historically there are like two ways that you can think of how can I build a product? One is hey, I have a product. Let's say I'm going to build an app. First I click on my home button, something else appears, a bunch of other icons and images appears and then I click on another button and then next set of events happens. So this kind of drives as a sequence. When it drives through a sequence at first as step one do something and then on this it could deviate into two different ways based on the user action, user behavior, it could be two or three and so on. So based on the user action, your product could behave differently, your application behaves differently.
So this becomes more of a sequential way where it becomes more of a procedural. You know that there is a procedure and you go in sequence in contrary, the other approach that we can think of is object oriented where you visualize, you think everything as an object. For example, let's take the same example of an application mobile app that we built where everything that you see on Nap, you visualize it as an object. If I take WhatsApp as an example, let's say the very fundamental thing that we do is a message. A message. If I see it as an object,
I can think of this message could be of different types one as a text, other as an audio, another as a video or my location and so on. So I think of object and I think of messages and object and different types of messages are different types or subtypes of a message. Similarly, every other action that I can do in my app, for example, creating a group and viewing my contacts, each of my contact, everything can be viewed as an object. So that's when you actually start thinking about an object how this plays over a procedural, let's say the product evolves over a period of time. Let's say I need another functionality to my object wherein let's say for example I need to delete a message or I need to auto kill a message after some time. So when I need a new functionality or a behavior, it becomes quite challenging in my procedural world where I am not sure where I need to introduce that new feature either after step two, one three or before step one. And when I do this, since things are all in procedural and sequential way, I need to be really careful how the following steps behave and what could break in. Contrary, in object oriented principles we think everything as an object and if I need a new functionality or a new icon that becomes a new object and all the features or behaviors becomes attached to this object. I introduce a new object and have methods. And if something breaks or anything happens, it matters only to this object and it doesn't impact the others. So that's where thinking in terms of objects helps. And that's where it helps you evolve the product as well.
There are two historical ways to build a product - procedural and object-oriented.
Procedural approach is sequential where the product behavior is based on the user's action, while object-oriented approach visualizes everything as an object.
In an object-oriented approach, each action in the product is considered as an object with its own functionalities and behaviors attached to it.
When a new feature needs to be added in the procedural approach, it becomes challenging to decide where to introduce it without breaking the sequential flow.
In an object-oriented approach, a new feature becomes a new object with its own functionalities and does not impact the existing objects.
Thinking in terms of objects helps in evolving the product over time.
So now you know, in object-oriented programming languages, everything is visualized as an object. But what really is an object. In the next video, you will learn more about objects.
In the previous video, you learned about objects. Object normally represent some physical entity in your system but is not just limited to that. For example, you can create an object to represent a user who is a physical entity. But you can also create an object to represent menu buttons, which is not a physical entity. An object has two things, attributes and methods. Attributes represent properties of an object, whereas methods represent actions that can be performed by that object. For example, in your WhatsApp app, if a user is an object, then its attributes will be the name, status, DP and so on. Its methods will be such as send message, delete message, join group and so on.
In this segment, you learned about procedural paradigm and object-oriented paradigm of software development. Object-oriented programming or OOP is better than procedural programming to build huge system. You also learned about objects, attributes and methods.