On Wed, 21 Apr 2004 23:52:04 GMT, Mohun Biswas wrote:
> Roedy Green wrote:
>> I'm with you. If in doubt put in the explicit this, especially when
>> you are dealing with two different objects at once this one and some
>> other.
>
> Let's take it a little farther to a related style issue I've never seen
> treated: let's say your class has private members foo and bar, and
> therefore accessors getFoo() and getBar(). Now in some third method I
> need the value of foo. My options include:
>
> this.getFoo()
> getFoo()
> foo
I use the last option normally. If I can't use an IDE with debugging
support and I need to see the changes, I'll convert my code to use
accessors. For this I introduce new private accessors.
private int foo;
becomes
private void foo(int value) { this.foo0 = value; }
private int foo() { return foo0; }
private int foo0;
For me, this affects readability the least. The change in the name of the
variable ensures that I won't miss any callsites.
|