The Final Countdown?
Michael Feathers’ thought-provoking post about deprecating the use of final (sealed in c#) has generated a good discussion – judging by the comments. The discussion is about the use of final applied to classes and methods – not to instance variables (c# makes a distinction by using the readonly modifier for this usage.)
I rarely use final/sealed (I use final/readonly frequently.) Final/sealed makes your classes much harder to test. It can also make classes that use your classes harder to test. And since you care if your code works or not, you’ll avoid final/sealed. In addition to making testing more difficult, it conflicts with the open/closed principle – which may translate into increased maintenance issues. It also suggests a lack of trust in those using your code (which in the case of the java.lang.string example posed by Michael Feathers, may be appropriate.) I’d guess a lot of people choose final/sealed because they feel it will improve performance – I’d favour code that works (and the performance benefits may be insignificant.)