r/programming • • Aug 11 '15

Top 10 Useful, Yet Paranoid Java Programming Techniques

http://blog.jooq.org/2015/08/11/top-10-useful-yet-paranoid-java-programming-techniques/
28 Upvotes

35 comments sorted by

View all comments

1

u/MrAndersson Aug 12 '15

6. All methods are final ... Yes. It’s final. If that doesn’t work for you, patch it, or instrument it, >or rewrite the byte code. Or send a feature request. I’m sure that >your intent of overriding the above isn’t a good idea anyway.

It might be a valid stance if you are the only user of the code, if you respond to feature requests in one hour or less, or if you always ship all source code to customers. Barring that, those finals should be removed before the software ships. It's not fun to have to add bytecode rewriting simply work around bugs in other peoples code when a classpath update and a couple overrides would have worked.

If we are to write code defensively, we should also be careful to avoid overestimating our own ability to know what other people might have to do with the code/library, and not make it hard for the people paying us to fix their problem when we for some reson can't.