Re: Self-configuring classes
On Aug 5, 11:18 am, Twisted <twisted...@gmail.com> wrote:
On Aug 4, 5:22 am, Owen Jacobson <angrybald...@gmail.com> wrote:
I believe the flaming and viciousness you're receiving at the hands of
others here has nothing whatsoever to do with Swing.
And the flaming I'm receiving at the hands of you?
If my posts are coming across as flameage, I sincerely apologize. How
can I present the points I'm making (outlined below) in a way that you
will not take offence at? And, if that's not possible, how can I at
least convince you to accept their existence?
POINT 1: I (and many others here) believe you see offense and flameage
where none was intended, to the detriment of your ability to
contribute your not inconsiderable technical skills to this group.
That is, hopefully, the only thing in this entire posting that is
specific to you. All further pronouns should be interpreted as a
generic "you, the reader."
Manipulating Swing components from main has *never* been safe.
I don't see how this can be the case anyway. Race conditions between
the EDT and the main thread can't occur unless they're both trying to
access components simultaneously, pretty much by definition. In the
usual situation, main calling setVisible(true) at the very end, the
main thread stops accessing components right when it does something
that will cause the EDT to start doing so.
This is not guaranteed by the Swing API; it may create the EDT as soon
as you instantiate a GUI component, and the component may interact
with the EDT (even in the form of "are you visible yet?" or "are you
responsible for this event?" checks) at any point thereafter. To find
out specifics you'd have to read the API spec and ancillary docs in
detail, or read the source.
I've already demonstrated that at least one person has encountered
bugs directly caused by creating the UI on the main thread to the
point of .setVisislbe(true) only. For me, that's sufficient to
convince me never to do that. These computers being what they are, a
"one in a million chance" bug will have been triggered by next
Tuesday; assuming otherwise is bad engineering.
POINT 2: Interacting with Swing components from outside the EDT is
fraught with peril and the sooner this practice dies the better off
Java software as a whole will be.
Lest anyone think I'm talking down from a position of presumed
authority or superiority on this: there are, on my own site no less,
still snippets of code which start up Swing UI components from the
main thread that I have not yet gotten around to correcting.
POINT 3: Swing's handling of thread safety sucks in favour of Swing as
a whole being fast. Sun's handling of Swing bugs isn't much better.
POINT 4: It is only ever correct (as of this writing) to manipulate
Swing objects from the EDT.
In short, stop holding me to your goddamn perfectionist standards and
leave me in peace! This applies to every one of you.
My long-held opinion is that example code should be held to higher,
not lower, standards than other code, since people who may not have
the skills to spot problems with it are well within the target
audience. Therefore, were I to post an example of how to use NIO but
fail to, for example, correctly remove selectors from the ready set
out of pure ignorance, I would appreciate being corrected as
quickly as possible even if I had not asked for corrections. By
placing my code in a public place I opened it to criticism,
constructive or otherwise; it'd be up to me to take less-polite
criticism as constructively as possible in the interests of better
code all 'round.
Let me flip this around for illustration's sake. Let's say you
came here asking how to frobnicate apothecaries and someone replied
with an example that followed a fairly common but incorrect pattern.
Would you prefer that a second someone replied correcting the first,
or to come away with an incorrect answer to your question? If you'd
prefer the former, do you care *how* the first someone (who, in this
case, is not you) was corrected?
Consider your answer carefully.
POINT 5: I believe example code, by its very nature, is open to
criticism in the interests of correctness, even at the expense of
POINT 6: I believe it is in everyone's best interest to take
criticism, no matter how clumsily or poorly presented, in the most
constructive light possible.
It wasn't particularly polite, but this is a technical newsgroup and ex=
blunt and direct ... are par for the course, not an act of hostility.
This is a technical newsgroup and as such should be held to a higher
standard of civility of discourse than, say, alt.*. Also, this is a
technical discussion and as such the relative merits, perceived
personal failings, and whatnot of various personalities are not on-
topic for discussion here; the technical subject matter itself is.
Leave the person out of any dispute; only refer to their code, and use
phrases like "It's safer to do X" or "I think Y works better", never
"You shouldn't ... You aren't doing it right ... You idiot!". Using
the word "you" makes things personal. Don't.
"You shouldn't manipulate Swing components from outside the EDT" is a
factual statement, regardless of the person(s) the pronoun "you"
refers to. Often, "you" is a generic pronoun referring to "you, the
reader", though I can see how in the context of Thomas Hawtin's post
it could also be interpreted as "you, Twisted". Both are valid
interpretations of the text.
The statement is lacking an explanatory clause, which makes it rather
blunt and did somewhat invite an irritated (or merely curious) "well,
why not?" followup.
Discussion in this or any other technical newsgroup is, by long and
well-tested convention, focused primarily on facts and on solving
problems. Participating in these groups eventually requires one to
admit to owning or creating a problem, either intentionally (for
discussion's sake) or accidentally. Similarly, eventually everyone
posts something wrong; if we're lucky someone else comes along and
corrects them. If the correction is factually correct and not simply
rude (and "You shouldn't" doesn't strike me as rude in the slightest,
nor did the post stoop to name-calling or denigration of anyone's
skills as a whole, which I would have considered rude), who cares how
POINT 7: facts =FCber alles, here and everywhere else.
 An example from my own postings to this very group, in fact.
 Breaking with my pronoun use, I do mean Twisted in this paragraph.