Comment

Comment by gernb

I know it's a tradeoff but I think I fall on the side of I wish the language I was writing in required `this` or `self` for members/properties.

C++

    foo = bar \* 2;
Are foo and bar local variables or members of some instance?

vs

Python

    self.foo = self.bar \* 2
100% clear. No naming convention needed.

I bring this up because `_foo` for members is a naming convention that wouldn't be needed in a language that required `self` or `this`

That said, I get that maybe refactoring some code from standalone function to class method is easier if you don't have to change the code as much but I'd be curious how often that's a net win.

parent gernb 3 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton