Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!npeer02.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!post01.iad.highwinds-media.com!newsfe12.iad.POSTED!not-for-mail From: Daniel Pitts User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:15.0) Gecko/20120907 Thunderbird/15.0.1 MIME-Version: 1.0 Newsgroups: comp.lang.java.programmer Subject: Re: nomenclature References: <70c1d214-71ac-478d-95d7-a5984c3dc180@googlegroups.com> In-Reply-To: <70c1d214-71ac-478d-95d7-a5984c3dc180@googlegroups.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Lines: 26 Message-ID: X-Complaints-To: abuse@newsrazor.net NNTP-Posting-Date: Tue, 02 Oct 2012 20:18:21 UTC Date: Tue, 02 Oct 2012 13:18:21 -0700 X-Received-Bytes: 1640 Xref: csiph.com comp.lang.java.programmer:19053 On 10/2/12 12:51 PM, bob smith wrote: > Is this sort of thing bad practice (using parameter names that are the same as my field names in the constructor)? > > > > public My_Rectangle(double x, double y, double width, double height) { > this.x=x; > this.y=y; > this.width=width; > this.height=height; > > } > If you are considering objecting because it requires "this.", I actually find that to be a useful syntax, and my constructors (and setters) use it, even if there isn't a name collision with local symbols. Most experienced Java programmers will take more exception with the class name. Java convention would suggest MyRectangle, not My_Rectangle. I've seen people try to avoid "name collisions", with ugly results. Underscores before members, or before parameters, or other such conventions. Ugly... ugly.