14
crisz
7y

I hate people who put underscore at the beginning of private variables names in Typescript. And I don't care if they have their reasons, I just hate them.

Comments
  • 4
    It's a common convention in more than just Typescript...
  • 5
    Well, naming privates with underscore in front is common practice. Can't see why you are mad
  • 0
    Because you have visibility keywords for it. What's the purpose to type "private" if then you have to put an underscore?
  • 0
    Obviously I'm talking only about Typescript
  • 2
    @crisz because I might want to create public attribute with the same name, but it is already taken by private attribute. Imagine you have car object and it has private _speed stored. Then, you want to make read-only public field speed, with only getter. You may use GetSpeed() instead, but that's much, much worse.
  • 3
    The leading underscore makes it extremely obvious at-a-glance that the var is private. This improves code readability and is consistent with many other languages. It's expected and standard.

    To hate this is like hating people who use coffee cups for coffee.
  • 2
    @Ashkin I hate who uses coffee cups for coffee
Add Comment