170 likes
·
3.8K reads
9 comments
Great article and great (and funny) examples
Regarding Encapsulation
"To encapsulate the code, you can also use setters and getters.
I disagree with you. When you expose setters and getters you break your object's encapsulation.
Keep witting these articles!
Thanks a lot for the feedback, sir! I'll check the setters and getters part
If you write an arrow functions as shown example, your methods are not registered to prototype such that it creates memory footprint every time you create instances...
Good article! Keep writing more like this but I'm curious to ask, why choose JavaScript as the language of choice to explain OOP? Java or C# would've made more sense IMO.
Because most people know JavaScript then Java or C# (according to stack overflow's survey) OR JavaScript is easy to understand.
Mubashir Jamali IMO, Java or C# might actually be easier to understand in comparison to JS due to lack of type safety and many odd behaviors that JS exhibits but easy or not might be subjective.
It is true that JS is probably the most used language according to Stack Overflow but I still think it is an odd choice for explaining OOP because of two reasons:
- It has a very unconventional OOP due to prototypical inheritance.
- Classes were not a part of JavaScript until 2015.
Nonetheless, I just wanted to pick author’s brain on the thought process behind the choice 😁
Thanks! I was planning to use C# but most web developers are more used to JavaScript, that's why I used JavaScript
Nice article!
Thank you so much!