Sign in
Log inSign up
Atul Kumar

170 likes

·

3.8K reads

9 comments

Maxi Contieri⭐⭐⭐
Maxi Contieri⭐⭐⭐
May 15, 2022

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!

11
·
·1 reply
Atul Kumar
Atul Kumar
Author
·May 16, 2022

Thanks a lot for the feedback, sir! I'll check the setters and getters part

9
·
Paul B Kim
Paul B Kim
May 16, 2022

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...

1
·
Haseeb Ahmed
Haseeb Ahmed
May 22, 2022

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.

1
·
·3 replies
Mubashir Jamali
Mubashir Jamali
May 22, 2022

Because most people know JavaScript then Java or C# (according to stack overflow's survey) OR JavaScript is easy to understand.

2
·
Haseeb Ahmed
Haseeb Ahmed
May 22, 2022

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:

  1. It has a very unconventional OOP due to prototypical inheritance.
  2. 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 😁

1
·
Atul Kumar
Atul Kumar
Author
·May 23, 2022

Thanks! I was planning to use C# but most web developers are more used to JavaScript, that's why I used JavaScript

2
·
Soshan Fernandes
Soshan Fernandes
Sep 19, 2022

Nice article!

·
·1 reply
Atul Kumar
Atul Kumar
Author
·Sep 20, 2022

Thank you so much!

·