4 ms·
You can argue that either way. Seeing 'this' unambiguously implies instance variable. Otherwise you have to spot the underscore and be aware of the conventions
by joshvm 8y ago
You can argue that either way.
Seeing 'this' unambiguously implies instance variable. Otherwise you have to spot the underscore and be aware of the conventions in the codebase. A good IDE should highlight class variables vs locals, though.
On the other hand code can get really messy with boilerplate like this everywhere, and I personally agree with you. Although I believe Google also promotes human-readable variables over less typing.
- tokyodude 8y agoI actually think implicit "this" is a language wart. I think C++, C#, Java, Swift, etc.. would all be better languages if they required `this`. As it is, nearly every one of them ends up needing a per team naming convention to help make the code readable. int area(int width) { return width * height; } What is "height". Is it a global variable? variable in some outer scope? A member/property of the current object? Absolutely no idea.