Re: Ensuring a method is overridden
This message is in MIME format. The first part should be readable text,
while the remaining parts are likely unreadable without MIME-aware tools.
---910079544-1181654886-1252532069=:7128
Content-Type: TEXT/PLAIN; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8BIT
On Wed, 9 Sep 2009, Lew wrote:
On Sep 9, 3:32?pm, Daniel Pitts
<newsgroup.spamfil...@virtualinfinity.net> wrote:
Lew wrote:
Daniel Pitts wrote:
You don't need to test for all invariants everywhere, especially
invariants that would cause an exception anyway (such as a collection
must only contain objects of a certain class. That will be caught by a
ClassCastException, which is a built-in assertion you can not disable)
A ClassCastException is not an assertion. ?It's an exception.
It isn't an "assert" assertion, but it is still an "assertion" in the
English sense of the word. ?The JVM asserts that the class you cast to
is the runtime type of the class.
That is only one example.
NullPointerException, ArrayIndexOutOfBounds, etc.. are the same kind of
thing.
Technically, they are Exceptions, specifically RuntimeExceptions, but
that doesn't prevent them from being a kind of JVM level assertion.
A very disingenuous approach, that.
I would choose a stronger word than "disingenuous".
Those exceptions happen when computation *cannot* proceed. If invoking a
method on a null pointer didn't throw an exception, what would happen? If
asking for a nonexistent element of an array didn't throw an exception,
what would happen? Neither of those operations have possible results -
there's nothing that can happen *but* an exception.
This is entirely different from an assertion. The whole point of
assertions is that the kind of thing they check for are those which do not
prevent the mechanical operation of the program, but do stop its operation
being meaningful. An entirely different class of problem.
"Assertion" in computer science, and in Java particularly, has a
specific technical meaning. To argue that you meant it in "the English
sense of the word" when you didn't say so at first is misleading.
Please be aware that when you use a specific technical term in its
specific technical context, that people will expect the technical
meaning not the non-technical meaning, and to pretend otherwise only
causes confusion.
On top of which, a ClassCastException is not an assertion in any form of
English with which i am familiar.
tom
--
secular utopianism is based on a belief in an unstoppable human ability
to make a better world -- Rt Rev Tom Wright
---910079544-1181654886-1252532069=:7128--