Re: Is 'Final' for classes and methods a good feature or something that should be eliminated?



rmoldskr+usenet@xxxxxxxxx wrote:
Michael Feathers <mfeathers@xxxxxxxxxxxxxxxx> wrote:

rmoldskr+usenet@xxxxxxxxx wrote:

It hampers _one_ particular testing technique, it doesn't make anything
untestable.


Which one technique are you thinking of?


On second thought I suppose there's actually two related techniques: To
create a light-weight proxy of the library object by subclassing and
overriding the library logic, and to "whiten the box" by subclassing and
adding instrumenting or monitoring code.


Final gets in the way of both of those. Really, there are very few alternatives at the unit level. In Java you can do some byte code manipulation but why should you really have to fight a library designer to do something as practical as unit testing. Sad, isn't it?


----
Michael Feathers
http://www.objectmentor.com
http://michaelfeathers.typepad.com
author of: Working Effectively with Legacy Code (Prentice Hall 2005)
.