Sumit | Javascript + React
Sumit | Javascript + React

@sumitsaurabh927

9 Tweets 4 reads Apr 05, 2023
๐Ÿ“Œ Object Oriented Programming is used in big projects with a large codebase.
Here's the first pillar of OOP in Javascript, explained in easily digestible language.
A thread ๐Ÿงต
๐Ÿ™… 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.
โžก๏ธ 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...๐Ÿ‘‡
๐Ÿ›ก๏ธ 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?
๐Ÿงฟ 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
๐Ÿ“Œ 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
๐Ÿ‘‰ 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.
๐ŸŒŸ 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!
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.

Loading suggestions...