Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #11568
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!.POSTED!not-for-mail |
|---|---|
| From | Lew <noone@lewscanon.com> |
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: Curious compiler warning |
| Date | Sat, 21 Jan 2012 12:13:22 -0800 |
| Organization | albasani.net |
| Lines | 75 |
| Message-ID | <jff693$bpa$1@news.albasani.net> (permalink) |
| References | <Xns9FD6D451D5F1Djpnasty@94.75.214.39> <jeir2s$7v0$3@news.albasani.net> <jeisjs$4k4$1@speranza.aioe.org> <jeiu63$es3$1@news.albasani.net> <MPG.2984bb6da639873a9896e2@202.177.16.121> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-Trace | news.albasani.net 0Qz50e25JzynzWOV0DpP43XE321S6Rg1XkzqSvdjpHcXY1KgNZ2T6Swj8om1YSIhKLVhNk5cCxnoxsxM4udrsrYUjxnYO0PkB6EdAXgBpH+JqpcG+zrL2+2KkpCEJ611 |
| NNTP-Posting-Date | Sat, 21 Jan 2012 20:13:23 +0000 (UTC) |
| Injection-Info | news.albasani.net; logging-data="Z23a+DnRyU2P4XML6RvTlYz0hjiTYcBRy6xPTr1RVIcPSKm9nfhX+R+eiEu3shv8sjWsidrZClUgXorfOvUfCaeNaDx5830+/clDt/wWvp7xMvc77KUri0fiNunZ9oLC"; mail-complaints-to="abuse@albasani.net" |
| User-Agent | Mozilla/5.0 (X11; Linux x86_64; rv:8.0) Gecko/20111124 Thunderbird/8.0 |
| In-Reply-To | <MPG.2984bb6da639873a9896e2@202.177.16.121> |
| Cancel-Lock | sha1:aOv573SJ5VMojrtzsLQC4beBWGc= |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:11568 |
Show key headers only | View raw
Wanja Gayk wrote:
> My best guess is that the warning to "not assign the parameters" is
> style-check warning, that just gives a hint on the best practice not to
> assign values to the parameters of a method.
That is correct.
>
> So maybe he's rather asking for some change like:
>
> void foo(int x, int y){
> x++;
> ...
> }
>
> to
>
> void foo(int x, int y){
> int start = x+1;
> ...
> }
>
> as solution to his warning.
That's a workaround, but as many in this thread have pointed out, there's
really nothing wrong with assigning to a parameter variable save that it
breaks the documentary connection to its parameter-ness. The Checkstyle
rationale cited /infra/ uses the same weasel-wording one typically encounters:
passive voice conditional "can be confusing", ducking the questions of to whom
and under what circumstances.
In the OP's case we've already discussed the option to disable this warning in
the Eclipse settings.
> Checkstyle says:
>
> "FinalParameters
> Description
>
> Check that method/constructor/catch block parameters are final.
> Interface and abstract methods are not checked - the final keyword does
> not make sense for interface and abstract method parameters as there is
> no code that could modify the parameter.
>
> Rationale: Changing the value of parameters during the execution of the
> method's algorithm can be confusing and should be avoided. A great way
> to let the Java compiler prevent this coding style is to declare
> parameters final."
>
> While Java rockstar Adam Bien says:
>> http://www.adam-bien.com/roller/abien/entry/final_method_parameters_should_generate
>
> (Which I disagree on and I have made my point in the answers, which you
> might like or not).
He also makes some factual errors. His example purporting to require the
'final' keyword would have worked if the anonymous class referred to the outer
class member instead of the method parameter.
I see no harm in declaring a method parameter 'final', but I'm generally a fan
of verbosity in Java programming anyway. People who don't like it call it
"noise", but universally without justifying the epithet in engineering terms.
Is it "noise" if it enforces non-assignment, which the very critics of 'final'
seem to find an error?
The impact is low enough that I recommend to code reviewers to enforce
consistency rather than one practice or the other. If an author's default is
to declare 'final', let them Javadoc when they omit it, and vice versa.
Even though I might know the right answer, if the cost is low and the benefit
likewise there's greater reward in cooperation than correctness.
--
Lew
Honi soit qui mal y pense.
http://upload.wikimedia.org/wikipedia/commons/c/cf/Friz.jpg
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Curious compiler warning Novice <novice@example..com> - 2012-01-11 01:51 +0000
Re: Curious compiler warning Lew <noone@lewscanon.com> - 2012-01-10 18:10 -0800
Re: Curious compiler warning glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2012-01-11 02:36 +0000
Re: Curious compiler warning Lew <noone@lewscanon.com> - 2012-01-10 19:03 -0800
Re: Curious compiler warning glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2012-01-11 07:50 +0000
Re: Curious compiler warning Lew <noone@lewscanon.com> - 2012-01-10 23:57 -0800
Re: Curious compiler warning Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2012-01-11 05:47 -0400
Re: Curious compiler warning glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2012-01-11 13:25 +0000
Re: Curious compiler warning Lew <noone@lewscanon.com> - 2012-01-11 06:58 -0800
Re: Curious compiler warning Lew <noone@lewscanon.com> - 2012-01-11 07:01 -0800
Re: Curious compiler warning Patricia Shanahan <pats@acm.org> - 2012-01-11 10:03 -0800
Re: Curious compiler warning Lew <noone@lewscanon.com> - 2012-01-11 23:30 -0800
Re: Curious compiler warning Gene Wirchenko <genew@ocis.net> - 2012-01-11 18:10 -0800
Re: Curious compiler warning Lew <noone@lewscanon.com> - 2012-01-11 23:32 -0800
Re: Curious compiler warning Leif Roar Moldskred <leifm@dimnakorr.com> - 2012-01-12 01:44 -0600
Re: Curious compiler warning Lew <noone@lewscanon.com> - 2012-01-12 07:42 -0800
Re: Curious compiler warning Leif Roar Moldskred <leifm@dimnakorr.com> - 2012-01-12 10:51 -0600
Re: Curious compiler warning Patricia Shanahan <pats@acm.org> - 2012-01-12 07:50 -0800
Re: Curious compiler warning Leif Roar Moldskred <leifm@dimnakorr.com> - 2012-01-12 10:54 -0600
Re: Curious compiler warning Wanja Gayk <brixomatic@yahoo.com> - 2012-01-21 12:52 +0100
Re: Curious compiler warning Gene Wirchenko <genew@ocis.net> - 2012-01-12 11:51 -0800
Re: Curious compiler warning Lew <noone@lewscanon.com> - 2012-01-12 20:58 -0800
Re: Curious compiler warning "Gavino" <invalid@invalid.invalid> - 2012-01-11 20:05 +0100
Re: Curious compiler warning Lew <noone@lewscanon.com> - 2012-01-12 07:47 -0800
Re: Curious compiler warning Wanja Gayk <brixomatic@yahoo.com> - 2012-01-21 12:52 +0100
Re: Curious compiler warning Lew <noone@lewscanon.com> - 2012-01-21 12:13 -0800
Re: Curious compiler warning Novice <novice@example..com> - 2012-01-11 04:55 +0000
Re: Curious compiler warning Lew <noone@lewscanon.com> - 2012-01-10 21:46 -0800
Re: Curious compiler warning glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2012-01-11 07:55 +0000
Re: Curious compiler warning Roedy Green <see_website@mindprod.com.invalid> - 2012-01-11 01:35 -0800
Re: Curious compiler warning "Gavino" <invalid@invalid.invalid> - 2012-01-11 20:05 +0100
Re: Curious compiler warning Gene Wirchenko <genew@ocis.net> - 2012-01-11 18:18 -0800
Re: Curious compiler warning Lew <noone@lewscanon.com> - 2012-01-12 07:55 -0800
Re: Curious compiler warning Gene Wirchenko <genew@ocis.net> - 2012-01-12 11:59 -0800
Re: Curious compiler warning Martin Gregorie <martin@address-in-sig.invalid> - 2012-01-13 00:02 +0000
Re: Curious compiler warning Patricia Shanahan <pats@acm.org> - 2012-01-12 16:11 -0800
Re: Curious compiler warning Martin Gregorie <martin@address-in-sig.invalid> - 2012-01-13 01:31 +0000
Re: Curious compiler warning Roedy Green <see_website@mindprod.com.invalid> - 2012-01-11 18:26 -0800
Re: Curious compiler warning Patricia Shanahan <pats@acm.org> - 2012-01-11 19:01 -0800
Re: Curious compiler warning Eric Sosman <esosman@ieee-dot-org.invalid> - 2012-01-11 23:23 -0500
Re: Curious compiler warning Lew <noone@lewscanon.com> - 2012-01-12 08:00 -0800
Re: Curious compiler warning Wanja Gayk <brixomatic@yahoo.com> - 2012-01-21 12:52 +0100
Re: Curious compiler warning Lew <noone@lewscanon.com> - 2012-01-12 07:50 -0800
Re: Curious compiler warning Gene Wirchenko <genew@ocis.net> - 2012-01-11 18:14 -0800
Re: Curious compiler warning Lew <noone@lewscanon.com> - 2012-01-12 08:05 -0800
Re: Curious compiler warning Gene Wirchenko <genew@ocis.net> - 2012-01-12 12:02 -0800
Re: Curious compiler warning Eric Sosman <esosman@ieee-dot-org.invalid> - 2012-01-10 21:11 -0500
Re: Curious compiler warning Lew <noone@lewscanon.com> - 2012-01-10 18:17 -0800
Re: Curious compiler warning bugbear <bugbear@trim_papermule.co.uk_trim> - 2012-01-11 16:10 +0000
Re: Curious compiler warning Lars Enderin <lars.enderin@telia.com> - 2012-01-11 20:45 +0100
Re: Curious compiler warning Lew <noone@lewscanon.com> - 2012-01-12 08:09 -0800
Re: Curious compiler warning Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2012-01-12 18:14 +0200
Re: Curious compiler warning Wanja Gayk <brixomatic@yahoo.com> - 2012-01-21 12:52 +0100
Re: Curious compiler warning David Lamb <dalamb@cs.queensu.ca> - 2012-01-21 09:12 -0500
Re: Curious compiler warning Gene Wirchenko <genew@ocis.net> - 2012-01-11 18:21 -0800
Re: Curious compiler warning Lew <noone@lewscanon.com> - 2012-01-12 08:08 -0800
Re: Eclipse 3.7.1 compiler warning v_borchert@despammed.com (Volker Borchert) - 2012-01-11 21:10 +0000
csiph-web