On Mon, 12 Oct 2009, Lew wrote:
Lew wrote:
Every time you omit 'final' in a class declaration you should
consider carefully. Read the item in /Effective Java/ referenced
upthread for a thorough explanation of why to prefer
non-heritability.
Rze?nik wrote:
If there is such guidance there then the book is useless rubbish -
but I can't say for sure because I actually did not read this.
You didn't read it, yet you feel confident in refuting the arguments
you didn't read?
Interesting.
FWIW, far from being "useless rubbish", /Effective Java/ is arguably
the most useful book published to help one write idiomatic and, well,
effective Java code.
Nonetheless, it does contain at least one piece of pretty questionable
advice, namely this one.
I say that despite the fact that i haven't read the book, and don't
intend to. I have, however, come across problems in my work which we
could solve by subclassing an existing class in a third-party library
and overriding some of its methods, in a way that its designers
almost certainly did not intend. If they'd taken JoBo's advice of
finalising everything that wasn't explicitly intended to be
overridable, we wouldn't have been able to do that.
Another bit of useful advice from Effective Java: prefer aggregation. No