On Aug 22, 2008, at 9:47 AM, Karl Wettin wrote:

...

I also like to declare everything final that can be, except method
params and locals, where it makes for too much noise. But I won't

I think final only makes sense in superclass methods that are not ment to be extended. There is lots of class, method and field finalization in Lucene that I can't stand. (This is especially true for Document and Term.) It forces me to do stuff like aggregating code when I really want to extend it. It can be rather expensive if you got enough instances to keep track of.


Another argument against excessive use of final is that they make testing harder. Sometimes it's convenient to write a test-only subclass to override a particular method so that it returns stubbed behavior, for example.

I'm much more likely to use final for data values, rather than methods, to promote more of a functional style of programming, i.e., preferring immutable value objects.

...



Dean Wampler, Ph.D.
dean at objectmentor.com
http://www.objectmentor.com
See also:
http://www.aspectprogramming.com  AOP advocacy site
http://aquarium.rubyforge.org     AOP for Ruby
http://www.contract4j.org         Design by Contract for Java5

I want my tombstone to say:
  Unknown Application Error in Dean Wampler.exe.
  Application Terminated.
      [Okay]        [Cancel]






Reply via email to