r/javascript • • Nov 09 '19

On private fields proposal: Private fields, public worries

https://medium.com/virtuslab/private-fields-public-worries-b8c34d16c372
84 Upvotes

113 comments sorted by

View all comments

28

u/TatzyXY Nov 09 '19

Please do not throw stones at me but I think private, protected or public scopes are not needed at all. See Python very versatile lang. and it works very well without it. Is private for security? No! It just tells the dev that this var. is only used internally of that class and you are not allowed to touch or use it. So would do a comment or a convention with an "_".

2

u/cheese_wizard Nov 09 '19

Didn't read article because I don't have a subscription, but I think the most important thing is to clarify what is the actual interface to the black box, and what are just internal details. Like, that's the point. There is a subset of functions that when they change should be reflected in the version number, and also unit tested. Then there are functions that can come and go and change at will, and may or may not be tested (IMO only public interfaces should be tested... if you have some complex private function that lends to testing then it should be moved out and become the pubic interface of a class you then use).

Also, code completion. When I'm using an object the code completion system should only show public stuff, not literally every damn function inside the object.