Path: csiph.com!eternal-september.org!feeder.eternal-september.org!aioe.org!.POSTED!not-for-mail From: =?UTF-8?Q?Arne_Vajh=c3=b8j?= Newsgroups: comp.lang.java.programmer Subject: Re: Using this Date: Fri, 20 Nov 2015 20:26:09 -0500 Organization: Aioe.org NNTP Server Lines: 33 Message-ID: References: <87poz5ytcf.fsf@Equus.decebal.nl> NNTP-Posting-Host: 1lM8B9/qdtKBc/uIRK2Gjw.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 X-Notice: Filtered by postfilter v. 0.8.2 Xref: csiph.com comp.lang.java.programmer:33172 On 11/20/2015 3:21 AM, Cecil Westerhof wrote: > What is the ‘best’ way to use this? I normally only use it when > necessary. (A function has a parameter with the same name.) But at the > company I am working there are people who say you should use it > always. This resulted at on line of code with four times a this. Made > the line a lot longer and I find it very ugly. Is there a rational for > constantly using this? I think there are 3 practices: A) only use it when needed B) also use it whenever the surrounding code use it C) always use it It is my impression that: usage(A) > usage(B) > usage(C) I am somewhat inclined to B myself. public class X { private int a; private int b; public X(int a) { this.a = a; this.b = FOOBAR; // this is not needed here but because it is used at the line above then I think it looks more readable this way } ... } Arne