Yes immutable objects are the big plus. But I also find that final locals vastly improve code structure. IME the vast majority of objects are set once and never modified. Any attempt to do so is generally a sign of a bug. Having the compiler catch that is a real boon.
On Wed, May 21, 2014 at 9:41 AM, Hervé BOUTEMY <herve.bout...@free.fr>wrote: > Le mardi 20 mai 2014 09:59:24 Jason van Zyl a écrit : > > On May 19, 2014, at 7:52 PM, William Ferguson > <william.fergu...@xandar.com.au> wrote: > > > One of the Maven Java code conventions (listed on that page) is to > > > > > > - Avoid using final modifier on all member variables and arguments. > > > > > > I was just querying the sanity of that. All the other code conventions > > > either make sense or are a reasonable arbitrary decision. This one > appears > > > to be the exact opposite of what should be done. > > > > So this is not a good idea in general, but we do not heavily employ > > constructor injection yet and a lot of our code still relies on setter or > > field injection. If the code in question is not a container controlled > > component definitely make fields final where you can. If they are > injected > > you can't. It's a long slog but I have a branch where I'm flipping the > core > > to JSR330 and everywhere possible I'm using constructor injection and > > private final fields. So I would agree in general that rule is not a good > > one, just a vestige of how we use our container. > ok for member variables: if we could use constructor injection, we whould > be > able to use final member variables, and that would be better > > but for final arguments (and final local variables), we just avoid final > since it > doesn't give much value and is less readable: this one is really a choice > that > I'm fine with. > > Regards, > > Hervé > > > > William > > > > Thanks, > > > > Jason > > > > ---------------------------------------------------------- > > Jason van Zyl > > Founder, Apache Maven > > http://twitter.com/jvanzyl > > http://twitter.com/takari_io > > --------------------------------------------------------- > > > > A language that doesn’t affect the way you think about programming is not > > worth knowing. > > > > -- Alan Perlis > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: dev-unsubscr...@maven.apache.org > For additional commands, e-mail: dev-h...@maven.apache.org > >