๐
In non-OOP (Object Oriented Programming) languages, we've data in variables and functions that operate on them.
๐ฅฒ There isn't anything wrong with it till the code base is small.
๐ฅฒ However, things become difficult when the codebase becomes large.
๐ฅฒ There isn't anything wrong with it till the code base is small.
๐ฅฒ However, things become difficult when the codebase becomes large.
โก๏ธ Because any real-world project has several hundred lines and in such scenarios, coding things up in non-OOP style gets cumbersome.
How?
Let me explain...๐
How?
Let me explain...๐
๐ก๏ธ Imagine the function you're working on takes in the returned output of another function defined a hundred lines above, so now you've to go there.
โณ You go to that function but it uses a variable assigned 300 lines below. So now you scroll more.
๐คฎ Get the problem?
โณ You go to that function but it uses a variable assigned 300 lines below. So now you scroll more.
๐คฎ Get the problem?
๐งฟ In addition to not making the developer constantly scroll up and down, OOP offers several other advantages, which is why it is widely used in industry.
๐ฅฐ Now back to encapsulation
๐ฅฐ Now back to encapsulation
๐ Encapsulation simply refers to the grouping together of functions and data on which they operate into one entity called Objects.
โ Entity in which functions and data are grouped = Objects
โ Data in those objects = Properties
โ Functions defined in those objects = Methods
โ Entity in which functions and data are grouped = Objects
โ Data in those objects = Properties
โ Functions defined in those objects = Methods
๐ Now, this clubbing together of data and functions in one place has several advantages:
๐ก Program has easy-to-manage chunks
โก It is easier to debug these programs
๐ It is easier to add new features to the app without wondering about what might break somewhere else.
๐ก Program has easy-to-manage chunks
โก It is easier to debug these programs
๐ It is easier to add new features to the app without wondering about what might break somewhere else.
๐ Also, with things like private methods, developers can restrict access to some of the functionality defined in Objects, thereby making it leaner.
๐ It is due to these advantages that OOP is used widely and as such knowing OOP becomes imperative!
๐ It is due to these advantages that OOP is used widely and as such knowing OOP becomes imperative!
I write threads daily on web dev so if you enjoyed this thread, please:
โ Follow me @sumitsaurabh927 for more of these.
โค๏ธ Each like, every comment of y'all motivates me to come up with awesome new stuff!
โ RT the tweet below to show me some love.
โ Follow me @sumitsaurabh927 for more of these.
โค๏ธ Each like, every comment of y'all motivates me to come up with awesome new stuff!
โ RT the tweet below to show me some love.
Loading suggestions...