Re: 'this' instance field reference
Larry Karnowski <[email protected]>
| Newsgroups | gmane.org.user-groups.trijug.juglist |
|---|---|
| Organization | HickoryWind.org |
| Message-ID | <[email protected]> |
Kevin, I don't understand why people are so afraid of typing five extra letters. Just do it -- for both methods and instance variables. It immediately removes all doubt as to the scope of the member in question, improves readability, and doesn't hurt anything. In other languages, most notably Python, you are required to use it to reference instance members at all. (In Python it is "self." which is their equivalent of "this.") Larry "this.unafraid" Karnowski A. Kevin Baynes wrote: > In an unformal code review, I have a colleague who wrote : > > -- > 'Access to instance fields should be prefixed with "this."' > > and > > 'Note I'm talking about variables here, not methods. I agree that > "this." is unconventional on method calls, but I think there is fairly > universal agreement these days about use of "this." on *variables*.' > -- > > I know that 'this' is needed to resolve class level varaibles obscured > within a method by a local variable of the same name, and is needed to > call sibling constructors. > > I don't see any problem in referencing class variables as 'this.foo' > if you wish, it reads the same to me. > > My question is 'this' : > > Do any of you support this purported 'univeral agreement' theory? > -- Larry Karnowski HickoryWind.org, Keeps Callin' Me Home Americana Music News, Reviews, & Personality www.hickorywind.org