Unless you tend to use composition over inheritance. Inheritance tends to be
overused.
I wholeheartedly agree, of course. With both sentences.
However, your correction is for "final", not for "private".
The "design by contract" approach tends to reduce the kind of errors you're
talking about. If the contract of the class is clear, and the designer wants
to restrict extension, that's the designer's choice. It isn't a mistake
because someone else wants to extend it and is frustrated that they cannot get
at the internals. It was the designer's intention to frustrate that attempt;
if anything the fact that the would-be extender gripes is ratification that
the API designer did their job correctly.
As I said in my previous post, if the design is flawless, the
accessibility is generally obvious. However, code lives, and having
lived, lives some more. And most of the designs I deal with are large
systems with stuff added when it was needed, resulting in unforeseen
evolution of the code.
Additionally, this may vary with examples, but I maintain that it's
more efficient, or generous, whatever, to write a class as a new tool
for your ever-growing kit than as a tailored solution to a precise
problem. Of course, it's not a very accurate remark without any
example, but this is how I prefer to imagine the perfect OO coder. I
prefer to wonder why to restrict access instead of why to enable it.
However I think Patricia provides a very useful insight, by comparing
two evils. In essence, she's saying that over-protected classes are
easily corrected, which is true, when modification of uselessly over-
displayed stuff is tricky at best.
Only thing missing from her reasoning, if you read my (longish) post,
is that I've almost never had to modify public/protected stuff, but
have in a number of occasions been disturbed by private annoyances. Of
course that's only my own experience.
Perhaps it all boils down to a point of view: Java is powerful,
because you can choose what to deliver, a foolproof closed system, or
a powerful tin-opener that may badly cut. Translate that to any
production domain, maybe the alternative is present everywhere...