javax.swing.ButtonGroup's add method violates implied contract

O

Oliver Wong

Kent Paul Dolan said:
Monique said:
And if it

[adding a button to a ButtonGroup]
fails, what are you going to do about it? What's
the point of being able to detect something if
there's no reasonable course of action at that
point?

Sigh: read, learn, evolve:

http://www.ccel.org/a/aquinas/summa/FS/FS076.html
http://groups.google.com/groups?q=invincible.ignorance+author:Kent.Paul.Dolan

I'm glad you provided the clues that you did, because I fail to see how
what one particular person considers to be the cause of sins to be of any
relevance to this discussion.
[Clue 1: the contract of Container is that if you
"add(...)", the thing added _will be there_. Thus,
you "do" whatever you do when you cannot trust that
the button made it into the ButtonGroup, which might
very well be "notify the user of the failure, then
exit with a non-zero exit code". What you _don't_ do
is blunder on in blind ignorance that your
application has become unstable, and behave as if
the add(...) had been successful, causing a cascade
of unintended consequences.

I'm not sure if you realize this, but in Java, an uncaught exception in
fact, does notify the user of the failure, then exits (whether with a
non-zero exit code or not, I am unsure, as exit codes may be a platform
specific concept). So by NOT trying to handle the exception, as Monique (and
others) have recommended, does lead you to your desired behaviour.

And this point was brought up earlier, but you seem to have forgotten
it: ButtonGroup does not have an IS-A relationship with Container.
Therefore, the contract of Container is of no relevance to the behaviour of
Container.

[snip]
Clue 2: It is going to take roughly _one_ more
question like from you like that one, applying "she
couldn't possibly be that stupid"-level industrial
strength ignorance to an issue, pretending that your
faux ignorance resolves the issue in your favor, and
you will no longer have to worry about _me_ reading
_your_ postings, much less about plonking me.]

(1) There's a difference between ignorance and stupidity.
(2) There is no shame in being ignorant. We are all born ignorant. You
yourself were ignorant of the syntax of generics, for example.
(3) Regardless of whether Monique's suggestion is correct or not, it
certainly isn't "stupid". "Don't catch exceptions if you can't handle them"
is a commonly recommended rule of thumb that I believe Sun even gives in
their tutorial on exceptions (see
http://java.sun.com/docs/books/tutorial/essential/exceptions/)
(4) Insulting people (e.g. by calling them stupid) is generally
considered rude, particularly if you are "starting it". As far as I can see,
Monique did not insult you in her post, so it does appear that you are
"starting it".

- Oliver
 
O

Oliver Wong

Kent Paul Dolan said:
Oh, and by the way, since one consequence of failure
is lots of people potentially dying of thirst (we're
doing water resource planning for three decades out,
in the desert, in this particular application), yes,
life or death _is_ involved, however intangibly and
marginally.

Elsewhere in this thread, you wrote with respect to why you are so
concerned with the behaviour of ButtonGroup:

<quote>
my
user-base has a series of image overlays choosable
for a base object, but the software doing the image
processing can't successfully blend more than two
such overlays into a result useful to the user. So,
out of half a dozen possible, 0, 1, or 2 are
allowable, and to bullet-proof the interface, I want
to make that limit a software-enforced one.
</quote>
http://groups.google.ca/group/comp.lang.java.programmer/msg/044e76849044d9fc

So yes, it would seem that the relation to life-or-death is indeed very
marginal.
Well, having written code for money in over twelve
dozen programming languages, including several
incompatible versions of the above two, I'm one who
fully agrees with Dijkstra. Programming should have
been deferred until Pascal came along.

Statements like the life-and-death importance of the possibility that
ButtonGroup might throw an exception when you add a Button to the group, and
"Programming should have been deferred until Pascal came along" makes it
sound like (to me at least) that you are willing to uphold certain
principles regardless of how impractical these principles may be in certain
situations. That humanity should have refused to perform any form of
programming until the invention of the Pascal programming language seems
like a naive viewpoint, for many reasons, not the least of which being that
the Pascal programming language would probably never have been invented if
humans did not program. Thus your statement seems to reduce to "Humans
should never program", which I think many people are in disagreement with.
You are confusing "habits" with "requirements".
Using strncat instead of strcat is a "habit", using
DoD 1267a instead of Mad Magazine as programming
guidelines is a "requirement".

Would you consider "accepting that ButtonGroup's 'add' method does not
declare that it may throw an exception" a habit, or a requirement (or
perhaps something else)?
The reasonable man adapts himself to the world;
the unreasonable one persists in trying to adapt
the world to himself. Therefore, all progress
depends on the unreasonable man.
-- George Bernard Shaw

The problem with your statement is precisely the
problem with John's statement: if you could
pre-judge which errors were "reasonable", you could
simply create a checklist for them, and never give
code containing them to the compiler.

The statement I made above tried to reuse as much of your original claim
as possible, to show that your claim was did not apply to the situation at
hand. Here it is again:

<yourClaim>
Instead, you make habits, from the first, that will stand you in good stead
in all the cases you can ever reasonably expect to encounter.
</yourClaim>

The situation at hand is dealing with the case where ButtonGroup's add
method fails. A lot of people think that this case is unreasonable, and you
seem to be of the same opinion, so I was just pointing out that your claim
here is somewhat off topic.
I'm sure that
giving a list of all "reasonable" errors can be put,
by formal proof, equivalent to Solving the Halting
Problem -- impossible even in theory.

You haven't defined what "'reasonable' errors" means here. If you
consider the list of all Throwables in Sun's standard library to be a list
of all "reasonable errors" that can occur in Java, then I can give you that
list, even though I cannot solve the halting problem, thus demonstrating
their non-equivalence.

I'm not sure how you've infer[r]ed the above from
what John said. Here's what I see John saying:
<quote>
A more precise question might be "Why would it
fail predictably?".
</quote>

Precisely the phase I quoted above.

So are you saying these two statements imply the same thing?

(1) Why would it [ButtonGroup] fail predictably?
(2) A programmer can predict software bugs with assurance.

I disagree. In fact, I think they imply opposite things.

John asks why ButtonGroup would fail predictably. Meaning John does not know
of a situation where ButtonGroup would fail predictably. Meaning John is of
the opinion that ButtonGroup will not fail predictably. Meaning John is of
the opinion that a programmer cannot predict ButtonGroup's failing. Meaning
John is of the opinion that a programmer cannot predict software bugs with
assurance.
I've interpret[ed] this as an essentially
rhetorical question indicating that he does not
predict it would fail, and that if it does fail,
it [would do] so unpredictably.

Umm, and I've interpreted it as an attempt to claim
that ignorance of a counter-example constitutes
proof of a contention, a debased arguing tactic. I
stand by my objection, both to his statement and to
your rewording of it above.

You object to my rewording, the rewording being "If ButtonGroup fails,
it would do so unpredictably"? Does that mean you believe that if
ButtonGroup fails, it would do so predictably? I.e. that you could predict
ButtonGroup's failing?
Were that the intent, the tone would be helpful
rather than taunting.

Obviously, if someone plonks you, they are displeased with you, so you
should not expect a friendly tone. That being said though, the two instances
in which you were plonked in this thread did seem to offer some potentially
helpful advice.

Thomas G Marshall wrote:
<quote>
Pick up a book on OO principals, and learn what "contract", "is-a", and
"has-a" *really* means.

<PLONK>
</quote>

Monique Y. Mudama wrote:
<quote>
You seem to suffer from a need to ridicule other people (see your final
paragraph). I'll just go ahead and killfile you now to save myself the
trouble of reading your posts.
</quote>

If one person plonks you, then perhaps that person is intolerant. Fine,
whatever. But if two or more people plonk you, especially within the same
thread, then perhaps you are doing something wrong. In both announcements of
plonking, the authors gave hints as to how to avoid further plonking in the
future.

In Thomas' case, he suggests that you may be misunderstanding what
certain terms mean, and that had you known the "correct" definitions, you
would not have gotten plonked. Now it's entirely possible that Thomas is, in
fact, in error and you know the correct definitions; but it may be
worthwhile to look it up somewhere, just in case. At worst, you will have
wasted a few minutes reading something you already kenw. At best, you will
have learned something new, or corrected a mistaken belief.

In Monique's case, she plonked you because you were ridiculing other
people (these "other people" maybe have included Monique herself). Perhaps
Monique is overly sensitive, and you felt you were not ridiculing, so much
as expressing disagreement.

However, I too feel that you occasionally insert insults into your posts
where they are inappropriate, and off topic for the discussion. This latter
problem is somewhat harder to solve in that you cannot simply look something
up to resolve it.

If you want, I can try to help point out posts you've made where you may
have inserted an inappropriate insult, and offer an alternative wording that
would have gotten your point across without nescessarily angering or hurting
the person you were responding to. The first step to ending undesired
behaviour, they say, is realizing that you are behaving in that manner in
the first place.

- Oliver
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,682
Members
48,796
Latest member
Greg L.

Latest Threads

Top