Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #15589 > unrolled thread
| Started by | bilsch <bilsch01@gmail.com> |
|---|---|
| First post | 2012-06-25 15:31 -0700 |
| Last post | 2012-06-29 13:07 -0700 |
| Articles | 20 on this page of 75 — 16 participants |
Back to article view | Back to comp.lang.java.programmer
I need a different approach - suggestions please bilsch <bilsch01@gmail.com> - 2012-06-25 15:31 -0700
Re: I need a different approach - suggestions please markspace <-@.> - 2012-06-25 16:15 -0700
Re: I need a different approach - suggestions please bilsch <bilsch01@gmail.com> - 2012-06-25 16:47 -0700
Re: I need a different approach - suggestions please markspace <-@.> - 2012-06-25 18:10 -0700
Re: I need a different approach - suggestions please bilsch <bilsch01@gmail.com> - 2012-06-26 13:04 -0700
Re: I need a different approach - suggestions please Gene Wirchenko <genew@ocis.net> - 2012-06-26 14:01 -0700
Re: I need a different approach - suggestions please Eric Sosman <esosman@ieee-dot-org.invalid> - 2012-06-26 17:21 -0400
Re: I need a different approach - suggestions please bilsch <bilsch01@gmail.com> - 2012-06-27 14:44 -0700
Re: I need a different approach - suggestions please Lew <lewbloch@gmail.com> - 2012-06-27 14:56 -0700
Re: I need a different approach - suggestions please Eric Sosman <esosman@ieee-dot-org.invalid> - 2012-06-27 18:13 -0400
Re: I need a different approach - suggestions please bilsch <bilsch01@gmail.com> - 2012-06-27 18:48 -0700
Re: I need a different approach - suggestions please Patricia Shanahan <pats@acm.org> - 2012-06-27 15:21 -0700
Re: I need a different approach - suggestions please Jail Bush Cronies <do.not@ask.me> - 2012-06-27 18:46 -0400
Re: I need a different approach - suggestions please markspace <-@.> - 2012-06-26 14:25 -0700
Re: I need a different approach - suggestions please Lew <lewbloch@gmail.com> - 2012-06-26 14:32 -0700
Re: I need a different approach - suggestions please Arne Vajhøj <arne@vajhoej.dk> - 2012-06-26 17:49 -0400
Re: I need a different approach - suggestions please Lew <lewbloch@gmail.com> - 2012-06-26 15:20 -0700
Re: I need a different approach - suggestions please bilsch <bilsch01@gmail.com> - 2012-06-27 17:30 -0700
Re: I need a different approach - suggestions please Lew <lewbloch@gmail.com> - 2012-06-27 18:09 -0700
Re: I need a different approach - suggestions please Wanja Gayk <brixomatic@yahoo.com> - 2012-07-02 11:21 +0200
Re: I need a different approach - suggestions please Lew <lewbloch@gmail.com> - 2012-06-25 18:36 -0700
Re: I need a different approach - suggestions please bilsch <bilsch01@gmail.com> - 2012-06-26 13:24 -0700
Re: I need a different approach - suggestions please Lew <lewbloch@gmail.com> - 2012-06-26 13:49 -0700
Re: I need a different approach - suggestions please Gene Wirchenko <genew@ocis.net> - 2012-06-26 14:04 -0700
Re: I need a different approach - suggestions please Lew <lewbloch@gmail.com> - 2012-06-26 14:34 -0700
Re: I need a different approach - suggestions please Gene Wirchenko <genew@ocis.net> - 2012-06-26 16:26 -0700
Re: I need a different approach - suggestions please Lew <lewbloch@gmail.com> - 2012-06-26 16:47 -0700
Re: I need a different approach - suggestions please Gene Wirchenko <genew@ocis.net> - 2012-06-26 20:04 -0700
Re: I need a different approach - suggestions please Arne Vajhøj <arne@vajhoej.dk> - 2012-06-26 22:18 -0400
Re: I need a different approach - suggestions please Joshua Cranmer <Pidgeot18@verizon.invalid> - 2012-06-26 22:59 -0400
Re: I need a different approach - suggestions please Arne Vajhøj <arne@vajhoej.dk> - 2012-06-27 21:30 -0400
Re: I need a different approach - suggestions please Wanja Gayk <brixomatic@yahoo.com> - 2012-07-02 11:32 +0200
Re: I need a different approach - suggestions please Gene Wirchenko <genew@ocis.net> - 2012-07-02 09:47 -0700
Re: I need a different approach - suggestions please Gene Wirchenko <genew@ocis.net> - 2012-06-26 20:06 -0700
Re: I need a different approach - suggestions please Lew <lewbloch@gmail.com> - 2012-06-27 11:42 -0700
Re: I need a different approach - suggestions please Gene Wirchenko <genew@ocis.net> - 2012-06-27 14:09 -0700
Re: I need a different approach - suggestions please Patricia Shanahan <pats@acm.org> - 2012-06-27 15:11 -0700
Re: I need a different approach - suggestions please Arne Vajhøj <arne@vajhoej.dk> - 2012-06-27 21:59 -0400
Re: I need a different approach - suggestions please Devil's Advocate <legal@hell.org> - 2012-06-27 22:17 -0400
Re: I need a different approach - suggestions please Arne Vajhøj <arne@vajhoej.dk> - 2012-06-27 21:40 -0400
Re: I need a different approach - suggestions please Gene Wirchenko <genew@ocis.net> - 2012-06-27 19:12 -0700
Re: I need a different approach - suggestions please Leif Roar Moldskred <leifm@dimnakorr.com> - 2012-06-27 20:47 -0500
Re: I need a different approach - suggestions please Gene Wirchenko <genew@ocis.net> - 2012-06-27 19:12 -0700
Re: I need a different approach - suggestions please Arne Vajhøj <arne@vajhoej.dk> - 2012-06-27 21:28 -0400
Re: I need a different approach - suggestions please Gene Wirchenko <genew@ocis.net> - 2012-06-27 19:14 -0700
Re: I need a different approach - suggestions please Hydrangea <hydrangea393@foo.mail.quuzzle.edu> - 2012-06-27 22:28 -0400
Re: I need a different approach - suggestions please Gene Wirchenko <genew@ocis.net> - 2012-06-27 21:05 -0700
Re: I need a different approach - suggestions please Arne Vajhøj <arne@vajhoej.dk> - 2012-06-27 22:32 -0400
Re: I need a different approach - suggestions please Gene Wirchenko <genew@ocis.net> - 2012-06-27 21:08 -0700
Re: I need a different approach - suggestions please markspace <-@.> - 2012-06-26 14:10 -0700
Re: I need a different approach - suggestions please Lew <lewbloch@gmail.com> - 2012-06-26 14:35 -0700
Re: I need a different approach - suggestions please Arne Vajhøj <arne@vajhoej.dk> - 2012-06-26 17:51 -0400
Re: I need a different approach - suggestions please Lew <lewbloch@gmail.com> - 2012-06-26 15:20 -0700
Re: I need a different approach - suggestions please Arne Vajhøj <arne@vajhoej.dk> - 2012-06-26 19:35 -0400
Re: I need a different approach - suggestions please Lew <lewbloch@gmail.com> - 2012-06-26 16:44 -0700
Re: I need a different approach - suggestions please Arne Vajhøj <arne@vajhoej.dk> - 2012-06-26 22:06 -0400
Re: I need a different approach - suggestions please Patricia Shanahan <pats@acm.org> - 2012-06-27 08:15 -0700
Re: I need a different approach - suggestions please bilsch <bilsch01@gmail.com> - 2012-06-27 18:36 -0700
Re: I need a different approach - suggestions please Lew <lewbloch@gmail.com> - 2012-06-27 18:54 -0700
Re: I need a different approach - suggestions please B1ll G4tes <wm.gat3s@micro5oft.quux> - 2012-06-27 22:23 -0400
Re: I need a different approach - suggestions please Lew <lewbloch@gmail.com> - 2012-06-28 09:55 -0700
Re: I need a different approach - suggestions please bilsch <bilsch01@gmail.com> - 2012-06-28 04:02 -0700
Re: I need a different approach - suggestions please Mike Winter <mlwinter@gmail.com> - 2012-06-28 04:55 -0700
Re: I need a different approach - suggestions please markspace <-@.> - 2012-06-28 07:33 -0700
[OT] Message IDs (Re: I need a different approach - suggestions please) Mike Winter <mlwinter@gmail.com> - 2012-06-28 08:45 -0700
Re: [OT] Message IDs (Re: I need a different approach - suggestions please) markspace <-@.> - 2012-06-28 09:39 -0700
Re: I need a different approach - suggestions please Gene Wirchenko <genew@ocis.net> - 2012-06-28 09:44 -0700
Re: I need a different approach - suggestions please Joshua Cranmer <Pidgeot18@verizon.invalid> - 2012-06-28 12:51 -0400
Re: I need a different approach - suggestions please markspace <-@.> - 2012-06-28 09:58 -0700
Re: I need a different approach - suggestions please markspace <-@.> - 2012-06-28 07:32 -0700
Re: I need a different approach - suggestions please Roedy Green <see_website@mindprod.com.invalid> - 2012-06-26 03:49 -0700
Re: I need a different approach - suggestions please bilsch <bilsch01@gmail.com> - 2012-06-26 13:59 -0700
Re: I need a different approach - suggestions please Patricia Shanahan <pats@acm.org> - 2012-06-29 08:12 -0700
Re: I need a different approach - suggestions please Gene Wirchenko <genew@ocis.net> - 2012-06-29 10:02 -0700
Re: I need a different approach - suggestions please bilsch <bilsch01@gmail.com> - 2012-06-29 13:07 -0700
Page 3 of 4 — ← Prev page 1 2 [3] 4 Next page →
| From | Gene Wirchenko <genew@ocis.net> |
|---|---|
| Date | 2012-06-27 19:12 -0700 |
| Message-ID | <puenu711fhfl99u02f4pcs7li1gojqtl8f@4ax.com> |
| In reply to | #15693 |
On Wed, 27 Jun 2012 21:40:48 -0400, Arne Vajhøj <arne@vajhoej.dk>
wrote:
>On 6/27/2012 5:09 PM, Gene Wirchenko wrote:
>> On Wed, 27 Jun 2012 11:42:04 -0700 (PDT), Lew <lewbloch@gmail.com>
>> wrote:
>>
>> [snip]
>>
>>> You calling the conventions a "religion" neither invalidates nor diminishes
>>> the value of the official conventions.
>>
>> I do not contest the value of the official conventions. I do say
>> that they are not the only conventions that can be used.
>>
>> The official conventions (or any others for that matter) are a
>> religion when they are shoved on people regardless of the situation.
>>
>> Your disdain for different conventions "neither invalidates nor
>> diminishes the value of" different conventions.
>
>I think you have misunderstood the purpose of a coding convention.
>
>It is not about what is the best way to write certain things.
>
>It is about having everybody writing things the same way to
>make it easier to read other peoples code.
>
>That automatically gives the standard convention more points
>than the alternatives.
>
>So unless one has specific knowledge about the OP's context,
>then the only plausible advice is to go for the standard.
Arguments over indenting styles are rife. Why? Because there
really is no one answer. I understand that. I wish more did.
>>> Your pitch for unconventional conventions violates the spirit and purpose
>>> of the conventions, which is to provide a common basis for the community
>>> to communicate their source code.
>>
>> My conventions are intended for me.
>
>So you use the concept invented to make code more readable for other
>for yourself.
>
>Hmmm.
Yes. Since I write useful programs, they are in use for
considerable time periods. I am usually the one who maintains them so
it is in my interest to use conventions that assist me in program
maintenance.
>>> Your overtly anti-social and self-aggrandizing approach is not suitable
>>> for playing nicely with others. Be less snarky about the choice to go with
>>
>> No, *your* overtly anti-social and self-aggrandising approach is
>> not suitable. I gave up on Java, partly because the language making
>> certain things that I need awkward to do and partly because of the
>> snarking.
>>
>> I remember posting one example of code that I was having trouble
>> with. It was short and simple and I detailed what I was having
>> trouble with. One of you Java religion twits responded that I was not
>> using the standard variable-naming convention and did not reply at all
>> to my problem. This sort of abuse happened too many times for me to
>> care much about the Java community or its standards.
>>
>> I follow this newsgroup still because there are some good
>> technical discussions. I hope to never have to code in Java again.
>
>The assumption is that people that post here are interested in learning.
One hopes.
>That includes naming convention.
That does not mean that I will use such a convention. I do not
expect anyone to use mine either. To each his own.
>If they are not, then I don't know why they are here.
It was for programming help on language features, not to be
snarked for not using the coding convention.
>>> the industry standards, please. I know it makes you feel all important and
>>
>> I state that I have my preferences. If you want to use the
>> official conventions, go ahead. I have never snarked anyone for doing
>> so.
>
>Nobody care how you write your code.
Of course you do. If you did not, you would not be posting in
this thread.
>If you want to write the entire class in a single line then do it.
Straw man!
My convention tends to more lines than most. For example,
variable and parameter declarations are almost always one per line.
That makes putting a class all on one line nearly impossible.
>But do not try to tell other that it is an acceptable way to write code.
It is an acceptable way. It is not the only way.
>>> powerful and all, but it doesn't serve those wishing to learn how best to
>>> be *professional* Java programmers.
>>
>> It does nothing of the sort for me.
>
>No. Because you are not interested in learning.
I am interested in learning. I am not interested in being
dictated to.
>Your choice.
Of course. And my exercising it seems to really get you upset.
>But do not try to lead other that route.
No. There is something called freedom of speech. I like having
it.
Sincerely,
Gene Wirchenko
[toc] | [prev] | [next] | [standalone]
| From | Leif Roar Moldskred <leifm@dimnakorr.com> |
|---|---|
| Date | 2012-06-27 20:47 -0500 |
| Message-ID | <lvGdnYOG_rMAKnbSnZ2dnUVZ8jCdnZ2d@giganews.com> |
| In reply to | #15679 |
Gene Wirchenko <genew@ocis.net> wrote: > > I do not contest the value of the official conventions. I do say > that they are not the only conventions that can be used. > > The official conventions (or any others for that matter) are a > religion when they are shoved on people regardless of the situation. > > Your disdain for different conventions "neither invalidates nor > diminishes the value of" different conventions. > He says, in conventionally spelled and punctuated English. -- Leif Roar Moldskred
[toc] | [prev] | [next] | [standalone]
| From | Gene Wirchenko <genew@ocis.net> |
|---|---|
| Date | 2012-06-27 19:12 -0700 |
| Message-ID | <ncfnu7550tub4om6iegfqv7nn7irjanbn7@4ax.com> |
| In reply to | #15694 |
On Wed, 27 Jun 2012 20:47:09 -0500, Leif Roar Moldskred
<leifm@dimnakorr.com> wrote:
>Gene Wirchenko <genew@ocis.net> wrote:
>>
>> I do not contest the value of the official conventions. I do say
>> that they are not the only conventions that can be used.
>>
>> The official conventions (or any others for that matter) are a
>> religion when they are shoved on people regardless of the situation.
>>
>> Your disdain for different conventions "neither invalidates nor
>> diminishes the value of" different conventions.
>He says, in conventionally spelled and punctuated English.
Quite so, sir!
Sincerely,
Gene Wirchenko
[toc] | [prev] | [next] | [standalone]
| From | Arne Vajhøj <arne@vajhoej.dk> |
|---|---|
| Date | 2012-06-27 21:28 -0400 |
| Message-ID | <4febb350$0$289$14726298@news.sunsite.dk> |
| In reply to | #15649 |
On 6/26/2012 11:06 PM, Gene Wirchenko wrote: > On Tue, 26 Jun 2012 22:18:28 -0400, Arne Vajhøj <arne@vajhoej.dk> > wrote: >> On 6/26/2012 7:26 PM, Gene Wirchenko wrote: >>> On Tue, 26 Jun 2012 14:34:13 -0700 (PDT), Lew <lewbloch@gmail.com> >>> wrote: >>>> Gene Wirchenko wrote: >>>>> bilsch wrote: >>>>>> advise is appreciated and noted. I know my indentation is wrong - it is >>>>>> something I'll have to work on. I hope I can finish this project without >>>>> >>>>> Adopt an indentation style whether it is your own and one that >>>>> you see that you are comfortable with. Consistent indenting can help >>>>> you catch errors. >>>> >>>> It is best to use the Java Coding Conventions or something very close. >>>> >>>> There are a couple of very limited acceptable variations from those >>>> conventions. >>> >>> That is your religion. >> >> It is the recommendation from the inventors of the language. >> >> And it is by far the most widely used coding convention from Java. >> >> Facts not religion. > > So it is the most common religion. Big deal. The most common religion is obvious widely accepted. But that does not make something widely accepted the most common religion or a religion at all. The idea of coding convention has good scientific basis. > My coding conventions are cross-language as much as I can make > them. But since the rest of the world does not then that is a bad choice. Arne
[toc] | [prev] | [next] | [standalone]
| From | Gene Wirchenko <genew@ocis.net> |
|---|---|
| Date | 2012-06-27 19:14 -0700 |
| Message-ID | <2efnu7lk91o43tcm9spk8b9p9u97vi0ggo@4ax.com> |
| In reply to | #15689 |
On Wed, 27 Jun 2012 21:28:48 -0400, Arne Vajhøj <arne@vajhoej.dk>
wrote:
[snip]
>But since the rest of the world does not then that is a bad
>choice.
Or I am on the bleeding edge.
At one point, presumably only one person (or only a few) was
using the Java coding conventions so highly touted here. Therefore,
by your argument, said conventions were a bad choice.
Sincerely,
Gene Wirchenko
[toc] | [prev] | [next] | [standalone]
| From | Hydrangea <hydrangea393@foo.mail.quuzzle.edu> |
|---|---|
| Date | 2012-06-27 22:28 -0400 |
| Message-ID | <jsgfgb$tu8$1@speranza.aioe.org> |
| In reply to | #15702 |
On 27/06/2012 10:14 PM, Gene Wirchenko wrote: > On Wed, 27 Jun 2012 21:28:48 -0400, Arne Vajhøj <arne@vajhoej.dk> > wrote: > > [snip] > >> But since the rest of the world does not then that is a bad >> choice. > > Or I am on the bleeding edge. > > At one point, presumably only one person (or only a few) was > using the Java coding conventions so highly touted here. Therefore, > by your argument, said conventions were a bad choice. "...therefore, all progress depends upon the unreasonable man". :)
[toc] | [prev] | [next] | [standalone]
| From | Gene Wirchenko <genew@ocis.net> |
|---|---|
| Date | 2012-06-27 21:05 -0700 |
| Message-ID | <oqlnu7tgs0l80ie5e8umi1upo15rnabibp@4ax.com> |
| In reply to | #15705 |
On Wed, 27 Jun 2012 22:28:23 -0400, Hydrangea
<hydrangea393@foo.mail.quuzzle.edu> wrote:
>On 27/06/2012 10:14 PM, Gene Wirchenko wrote:
>> On Wed, 27 Jun 2012 21:28:48 -0400, Arne Vajhøj <arne@vajhoej.dk>
>> wrote:
>>
>> [snip]
>>
>>> But since the rest of the world does not then that is a bad
>>> choice.
>>
>> Or I am on the bleeding edge.
>>
>> At one point, presumably only one person (or only a few) was
>> using the Java coding conventions so highly touted here. Therefore,
>> by your argument, said conventions were a bad choice.
>
>"...therefore, all progress depends upon the unreasonable man". :)
I am doing my best.
The assymetry of the situation is interesting to me. I do not
like the standard Java coding conventions for <reasons>, but I would
not dream of telling someone not to use them. The other side is very
insistent that I should and must. I do insist that someone have
coding conventions, but it is less important what they are. I can
adapt if I have to, but of course, I prefer my own conventions as they
match my needs.
Sincerely,
Gene Wirchenko
[toc] | [prev] | [next] | [standalone]
| From | Arne Vajhøj <arne@vajhoej.dk> |
|---|---|
| Date | 2012-06-27 22:32 -0400 |
| Message-ID | <4febc24f$0$295$14726298@news.sunsite.dk> |
| In reply to | #15702 |
On 6/27/2012 10:14 PM, Gene Wirchenko wrote: > On Wed, 27 Jun 2012 21:28:48 -0400, Arne Vajhøj <arne@vajhoej.dk> > wrote: > > [snip] > >> But since the rest of the world does not then that is a bad >> choice. > > Or I am on the bleeding edge. > > At one point, presumably only one person (or only a few) was > using the Java coding conventions so highly touted here. Therefore, > by your argument, said conventions were a bad choice. No. If there are no standard you invent a standard. If there are a standard you follow it. Arne
[toc] | [prev] | [next] | [standalone]
| From | Gene Wirchenko <genew@ocis.net> |
|---|---|
| Date | 2012-06-27 21:08 -0700 |
| Message-ID | <d1mnu7d98ckb6ulfs8eo38t34uou3i7aet@4ax.com> |
| In reply to | #15706 |
On Wed, 27 Jun 2012 22:32:47 -0400, Arne Vajhøj <arne@vajhoej.dk>
wrote:
>On 6/27/2012 10:14 PM, Gene Wirchenko wrote:
>> On Wed, 27 Jun 2012 21:28:48 -0400, Arne Vajhøj <arne@vajhoej.dk>
>> wrote:
>>
>> [snip]
>>
>>> But since the rest of the world does not then that is a bad
>>> choice.
>>
>> Or I am on the bleeding edge.
>>
>> At one point, presumably only one person (or only a few) was
>> using the Java coding conventions so highly touted here. Therefore,
>> by your argument, said conventions were a bad choice.
>
>No.
>
>If there are no standard you invent a standard.
>
>If there are a standard you follow it.
Maybe you do that, but I do not. I evaluate a standard for how
well it fits my needs. I make no bones about disregarding a standard
that does not work for me.
Standards for written English work very well for me. There are a
number of errors in your post. Please submit a corrected post, or
quit whining about standards. Or both.
Sincerely,
Gene Wirchenko
[toc] | [prev] | [next] | [standalone]
| From | markspace <-@.> |
|---|---|
| Date | 2012-06-26 14:10 -0700 |
| Message-ID | <jsd8ga$bs4$1@dont-email.me> |
| In reply to | #15607 |
On 6/26/2012 1:24 PM, bilsch wrote: > > Many things are because I mimic what I see in other programs... I > hope I can finish this project without understanding threads Yeah, that's an issue. When teaching someone, is it better to let them do it the simplest, but wrong, way? Or should you teach them to write code they don't understand, but promise too "explain it later?" I'm actually in the latter camp at the moment. I'd rather see you copy and paste good code, than let you get into the habit of writing bad code that you feel you understand. It a style of learning thing, more than a programming thing, but I think it's better to get you into the habit of looking at correct code now, so it doesn't seem strange when you see the correct version later. OTOH, it's not going to adversely effect your small programs. The chance of you hitting a threading error in such a small program is virtually nil. Just be aware that: 1. the code really is wrong, and 2. you'll have to learn threads eventually.
[toc] | [prev] | [next] | [standalone]
| From | Lew <lewbloch@gmail.com> |
|---|---|
| Date | 2012-06-26 14:35 -0700 |
| Message-ID | <8a5cafca-755d-4ac2-8ea8-c152e39ad511@googlegroups.com> |
| In reply to | #15614 |
markspace wrote: > bilsch wrote: >> Many things are because I mimic what I see in other programs... I >> hope I can finish this project without understanding threads > > > Yeah, that's an issue. When teaching someone, is it better to let them > do it the simplest, but wrong, way? Or should you teach them to write > code they don't understand, but promise too "explain it later?" > > I'm actually in the latter camp at the moment. I'd rather see you copy > and paste good code, than let you get into the habit of writing bad code > that you feel you understand. It a style of learning thing, more than a > programming thing, but I think it's better to get you into the habit of > looking at correct code now, so it doesn't seem strange when you see the > correct version later. > > OTOH, it's not going to adversely effect your small programs. The > chance of you hitting a threading error in such a small program is > virtually nil. Just be aware that: 1. the code really is wrong, and 2. > you'll have to learn threads eventually. They've already hit a threading error. How is that "virtually nil" chance? -- Lew
[toc] | [prev] | [next] | [standalone]
| From | Arne Vajhøj <arne@vajhoej.dk> |
|---|---|
| Date | 2012-06-26 17:51 -0400 |
| Message-ID | <4fea2ed5$0$292$14726298@news.sunsite.dk> |
| In reply to | #15619 |
On 6/26/2012 5:35 PM, Lew wrote: > markspace wrote: >> bilsch wrote: >>> Many things are because I mimic what I see in other programs... I >>> hope I can finish this project without understanding threads >> >> >> Yeah, that's an issue. When teaching someone, is it better to let them >> do it the simplest, but wrong, way? Or should you teach them to write >> code they don't understand, but promise too "explain it later?" >> >> I'm actually in the latter camp at the moment. I'd rather see you copy >> and paste good code, than let you get into the habit of writing bad code >> that you feel you understand. It a style of learning thing, more than a >> programming thing, but I think it's better to get you into the habit of >> looking at correct code now, so it doesn't seem strange when you see the >> correct version later. >> >> OTOH, it's not going to adversely effect your small programs. The >> chance of you hitting a threading error in such a small program is >> virtually nil. Just be aware that: 1. the code really is wrong, and 2. >> you'll have to learn threads eventually. > > They've already hit a threading error. > > How is that "virtually nil" chance? Usually "hit [by] an error" means actually impacted by the error. I did not see any case of such. Arne
[toc] | [prev] | [next] | [standalone]
| From | Lew <lewbloch@gmail.com> |
|---|---|
| Date | 2012-06-26 15:20 -0700 |
| Message-ID | <104e9655-ad13-4aa9-a7d2-76dc5a2c25a1@googlegroups.com> |
| In reply to | #15622 |
Arne Vajhøj wrote: > Lew wrote: >> markspace wrote: >>> bilsch wrote: >>>> Many things are because I mimic what I see in other programs... I >>>> hope I can finish this project without understanding threads >>> >>> >>> Yeah, that's an issue. When teaching someone, is it better to let them >>> do it the simplest, but wrong, way? Or should you teach them to write >>> code they don't understand, but promise too "explain it later?" >>> >>> I'm actually in the latter camp at the moment. I'd rather see you copy >>> and paste good code, than let you get into the habit of writing bad code >>> that you feel you understand. It a style of learning thing, more than a >>> programming thing, but I think it's better to get you into the habit of >>> looking at correct code now, so it doesn't seem strange when you see the >>> correct version later. >>> >>> OTOH, it's not going to adversely effect your small programs. The >>> chance of you hitting a threading error in such a small program is >>> virtually nil. Just be aware that: 1. the code really is wrong, and 2. >>> you'll have to learn threads eventually. >> >> They've already hit a threading error. >> >> How is that "virtually nil" chance? > > Usually "hit [by] an error" means actually impacted by the error. > > I did not see any case of such. Have you run the OP's code? On a multi-processor system? -- Lew
[toc] | [prev] | [next] | [standalone]
| From | Arne Vajhøj <arne@vajhoej.dk> |
|---|---|
| Date | 2012-06-26 19:35 -0400 |
| Message-ID | <4fea4752$0$292$14726298@news.sunsite.dk> |
| In reply to | #15623 |
On 6/26/2012 6:20 PM, Lew wrote: > Arne Vajhøj wrote: >> Lew wrote: >>> markspace wrote: >>>> bilsch wrote: >>>>> Many things are because I mimic what I see in other programs... I >>>>> hope I can finish this project without understanding threads >>>> >>>> >>>> Yeah, that's an issue. When teaching someone, is it better to let them >>>> do it the simplest, but wrong, way? Or should you teach them to write >>>> code they don't understand, but promise too "explain it later?" >>>> >>>> I'm actually in the latter camp at the moment. I'd rather see you copy >>>> and paste good code, than let you get into the habit of writing bad code >>>> that you feel you understand. It a style of learning thing, more than a >>>> programming thing, but I think it's better to get you into the habit of >>>> looking at correct code now, so it doesn't seem strange when you see the >>>> correct version later. >>>> >>>> OTOH, it's not going to adversely effect your small programs. The >>>> chance of you hitting a threading error in such a small program is >>>> virtually nil. Just be aware that: 1. the code really is wrong, and 2. >>>> you'll have to learn threads eventually. >>> >>> They've already hit a threading error. >>> >>> How is that "virtually nil" chance? >> >> Usually "hit [by] an error" means actually impacted by the error. >> >> I did not see any case of such. > > Have you run the OP's code? > > On a multi-processor system? I had not. Now I have. I expect OP to have too. The chance of actually getting a problem by starting the GUI in main thread instead of event thread is pretty small. Otherwise the wrong way of doing it would not have been used for so many years. Arne
[toc] | [prev] | [next] | [standalone]
| From | Lew <lewbloch@gmail.com> |
|---|---|
| Date | 2012-06-26 16:44 -0700 |
| Message-ID | <beb9ea4d-2cef-4c8e-846a-950e0ebf1d8b@googlegroups.com> |
| In reply to | #15628 |
Arne Vajhøj wrote: > Lew wrote: >> Arne Vajhøj wrote: >>> Lew wrote: >>>> markspace wrote: >>>>> bilsch wrote: >>>>>> Many things are because I mimic what I see in other programs... I >>>>>> hope I can finish this project without understanding threads >>>>> >>>>> >>>>> Yeah, that's an issue. When teaching someone, is it better to let them >>>>> do it the simplest, but wrong, way? Or should you teach them to write >>>>> code they don't understand, but promise too "explain it later?" >>>>> >>>>> I'm actually in the latter camp at the moment. I'd rather see you copy >>>>> and paste good code, than let you get into the habit of writing bad code >>>>> that you feel you understand. It a style of learning thing, more than a >>>>> programming thing, but I think it's better to get you into the habit of >>>>> looking at correct code now, so it doesn't seem strange when you see the >>>>> correct version later. >>>>> >>>>> OTOH, it's not going to adversely effect your small programs. The >>>>> chance of you hitting a threading error in such a small program is >>>>> virtually nil. Just be aware that: 1. the code really is wrong, and 2. >>>>> you'll have to learn threads eventually. >>>> >>>> They've already hit a threading error. >>>> >>>> How is that "virtually nil" chance? >>> >>> Usually "hit [by] an error" means actually impacted by the error. >>> >>> I did not see any case of such. >> >> Have you run the OP's code? >> >> On a multi-processor system? > > I had not. > > Now I have. > > I expect OP to have too. > > The chance of actually getting a problem by starting > the GUI in main thread instead of event thread is pretty > small. > > Otherwise the wrong way of doing it would not have > been used for so many years. Not so. Those many years, Swing programs were running on single- processor machines for the most part. Cache coherency and such issues were non-existent. Nowadays many machines are multi-processor and thread bugs are more likely to be visible. If it were so safe, then it wouldn't be "the wrong way of doing it". You are expressing the great bad approach to the concurrency problem: "I don't see a problem in the last two or three times I ran the program, therefore there is no problem." This is the attitude that foments so many concurrency bugs. Concurrency bugs by nature are intermittent, unpredictable and inconsistent. Your test proves nothing except that you have fallen into a classic trap. OP: Don't learn the wrong way. Learn the right way. The fact you don't see a bug in the first two or dozen times you run the program means nothing with concurrency issues. Rule for Swing: DO GUI ACTIONS ONLY ON THE EDT! That's that. -- Lew
[toc] | [prev] | [next] | [standalone]
| From | Arne Vajhøj <arne@vajhoej.dk> |
|---|---|
| Date | 2012-06-26 22:06 -0400 |
| Message-ID | <4fea6ac4$0$281$14726298@news.sunsite.dk> |
| In reply to | #15635 |
On 6/26/2012 7:44 PM, Lew wrote: > Arne Vajhøj wrote: >> Lew wrote: >>> Arne Vajhøj wrote: >>>> Lew wrote: >>>>> markspace wrote: >>>>>> bilsch wrote: >>>>>>> Many things are because I mimic what I see in other programs... I >>>>>>> hope I can finish this project without understanding threads >>>>>> >>>>>> >>>>>> Yeah, that's an issue. When teaching someone, is it better to let them >>>>>> do it the simplest, but wrong, way? Or should you teach them to write >>>>>> code they don't understand, but promise too "explain it later?" >>>>>> >>>>>> I'm actually in the latter camp at the moment. I'd rather see you copy >>>>>> and paste good code, than let you get into the habit of writing bad code >>>>>> that you feel you understand. It a style of learning thing, more than a >>>>>> programming thing, but I think it's better to get you into the habit of >>>>>> looking at correct code now, so it doesn't seem strange when you see the >>>>>> correct version later. >>>>>> >>>>>> OTOH, it's not going to adversely effect your small programs. The >>>>>> chance of you hitting a threading error in such a small program is >>>>>> virtually nil. Just be aware that: 1. the code really is wrong, and 2. >>>>>> you'll have to learn threads eventually. >>>>> >>>>> They've already hit a threading error. >>>>> >>>>> How is that "virtually nil" chance? >>>> >>>> Usually "hit [by] an error" means actually impacted by the error. >>>> >>>> I did not see any case of such. >>> >>> Have you run the OP's code? >>> >>> On a multi-processor system? >> >> I had not. >> >> Now I have. >> >> I expect OP to have too. >> >> The chance of actually getting a problem by starting >> the GUI in main thread instead of event thread is pretty >> small. >> >> Otherwise the wrong way of doing it would not have >> been used for so many years. > > Not so. Those many years, Swing programs were running on single- > processor machines for the most part. Cache coherency and such > issues were non-existent. Nowadays many machines are multi-processor > and thread bugs are more likely to be visible. > > If it were so safe, then it wouldn't be "the wrong way of doing it". > > You are expressing the great bad approach to the concurrency problem: > "I don't see a problem in the last two or three times I ran the program, > therefore there is no problem." > > This is the attitude that foments so many concurrency bugs. > > Concurrency bugs by nature are intermittent, unpredictable and > inconsistent. Your test proves nothing except that you have fallen into > a classic trap. ???? I pointed out that you were wrong in claiming that OP had already been hit by the error. There were no indication that he had in host post. And in fact the likelihood of being hit by problem even on multi core is pretty slim. I did not suggest that OP should ignore the problem. I did not suggest that running the code with no problem meant that the code was OK. In fact it was you that suggested running the code. So if there is somebody here that believes running the code without problems indicates something then it must be you. Arne
[toc] | [prev] | [next] | [standalone]
| From | Patricia Shanahan <pats@acm.org> |
|---|---|
| Date | 2012-06-27 08:15 -0700 |
| Message-ID | <4dGdnVGyxYEtvnbSnZ2dnUVZ_gidnZ2d@earthlink.com> |
| In reply to | #15607 |
On 6/26/2012 1:24 PM, bilsch wrote: ... > Many things are because I mimic what I see in other programs. Your > advise is appreciated and noted. I know my indentation is wrong - it is > something I'll have to work on. I hope I can finish this project without > understanding threads because I read about them and I don't see that > they apply here. I don't really understand them. Threads really do apply to any Java GUI application, and not seeing or understanding them won't make them go away. Specifically, your main method and the things it calls directly run in one thread. The GUI event handling runs in a different thread. Every time you start your program there is a risk that the GUI thread will see out-of-date values for some of the fields you initialized in the main thread. The alternative main program that Lew posted gets rid of that risk, by asking the GUI thread to run the initialization code instead of calling it directly. Patricia
[toc] | [prev] | [next] | [standalone]
| From | bilsch <bilsch01@gmail.com> |
|---|---|
| Date | 2012-06-27 18:36 -0700 |
| Message-ID | <jsgce5$sr6$1@dont-email.me> |
| In reply to | #15593 |
On 6/25/2012 6:36 PM, Lew wrote:
> bilsch wrote:
>> markspace wrote:
>>> bilsch wrote:
>>>> I'm trying to make a program that works like the calculator in Windows
>>>> Accessories - all input is from button clicks. ...
>>>> Everytime the method is called the string is reinitialized
>>>> with the result that my sequence of digits is only ever one digit long.
>>>> My plan would work if I could initialize the string outside the method,
>>>> however variable scope in Java doesn't allow it.
>>>
>>> First, good job on making a very reasonable SSCCE.
>>>
>>> Second, the trick to Java's scoping rules is to change the rules!
>>>
>>> Move the string strng1 from inside the actionPerformed to outside, right
>>> below the CalcGUIQ1 gui; line. Now Java's scoping rules help you rather
>>> than hinder you.
>>>
>>> BTW, this looks like a homework problem, and it looks like you've been
>>> getting help on it. Some if it is a bit sophisticated for someone who
>>> doesn't understand scoping. Please try to talk to your instructor or a
>>> TA, they need to understand when you're having problems with your lessons.
>>>
>> Thanks for the help. I could swear I tried that first but got error
>> messages about static and non-static conflict problem. i will be taking
>> Java in fall quarter. Right now I'm working from "Learn Java in 24
>> Hours" I thought up the calculator project myself. Thanks again.
>
> There are a few mistakes in your code.
>
> You don't need to call 'super()' in the constructor explicitly.
> That's what happens by default anyway.
>
> You called the constructor directly from the 'main()' routine. That means
> you called it from the primary thread of the program. You don't know this
> yet, probably, unless you've already studied concurrency in Java a little bit.
>
> The problem is that the GUI won't work right if you do that. You have to
> move GUI actions onto the "Event Dispatch Thread" (EDT), a background
> thread that the system creates to handle all GUI actions.
>
> Also, you start all the action from the constructor. That's bad. As its name
> implies, a constructor's purpose is to _construct_ an object, not run its logic.
> Run the logic after construction completes and the instance is no longer in a
> partially-built state.
>
> And make your indentation consistent with the Java coding conventions (available
> on line).
>
> So all together, you'd do something like:
>
> public static void main(String[] arguments) {
> java.awt.EventQueue.invokeAndWait( new Runnable() {
> @Override public void run() {
> CalcGUIQ1 calculator = new CalcGUIQ1();
> calculator.setVisible(true);
> }
> });
> }
Hello Lew,
With help I've gotten some errors out of the program but I have reached
a point where something just won't work how it should. Your comments
here lead me to believe the reason is the basic way I have things laid
out. But I don't know how to:
> move GUI actions onto the "Event Dispatch Thread" (EDT), further I
dont know how to write an EDT, or what specifically are 'GUI actions' as
opposed to other lines that relate to the GUI.
Also, I thought the stuff I have in the constructor belonged there.
I dont know where to call the constructor from if not from 'main'.
I did some reading about threads being unsafe.
It would be very helpful to me if you could show how to rearrange the
code like you say would be better. If you have the time, it would be
very helpful. Thanks.
Bill S.
[toc] | [prev] | [next] | [standalone]
| From | Lew <lewbloch@gmail.com> |
|---|---|
| Date | 2012-06-27 18:54 -0700 |
| Message-ID | <ac81b049-9f64-47c5-b5d9-e2db69cc69d4@googlegroups.com> |
| In reply to | #15692 |
bilsch wrote:
> Lew wrote:
>> There are a few mistakes in your code.
>>
>> You don't need to call 'super()' in the constructor explicitly.
>> That's what happens by default anyway.
>>
>> You called the constructor directly from the 'main()' routine. That means
>> you called it from the primary thread of the program. You don't know this
>> yet, probably, unless you've already studied concurrency in Java a little bit.
>>
>> The problem is that the GUI won't work right if you do that. You have to
>> move GUI actions onto the "Event Dispatch Thread" (EDT), a background
>> thread that the system creates to handle all GUI actions.
>>
>> Also, you start all the action from the constructor. That's bad. As its name
>> implies, a constructor's purpose is to _construct_ an object, not run its logic.
>> Run the logic after construction completes and the instance is no longer in a
>> partially-built state.
>>
>> And make your indentation consistent with the Java coding conventions (available
>> on line).
>>
>> So all together, you'd do something like:
>>
>> public static void main(String[] arguments) {
>> java.awt.EventQueue.invokeAndWait( new Runnable() {
>> @Override public void run() {
>> CalcGUIQ1 calculator = new CalcGUIQ1();
>> calculator.setVisible(true);
>> }
>> });
>> }
>
> With help I've gotten some errors out of the program but I have reached
> a point where something just won't work how it should. Your comments
What doesn't work, and how should it?
> here lead me to believe the reason is the basic way I have things laid
> out. But I don't know how to:
>
> > move GUI actions onto the "Event Dispatch Thread" (EDT), further I
> dont know how to write an EDT, or what specifically are 'GUI actions' as
> opposed to other lines that relate to the GUI.
You don't write the EDT. Did you read the tutorial link I provided?
<http://docs.oracle.com/javase/tutorial/uiswing/concurrency/index.html>
GUI actions are all things that happen on the GUI, such as creating
a 'JFrame', calling 'pack()', playing with 'Graphics', or anything else that
is part of the GUI. Non-GUI actions are things like writing files, calculating
values, updating the logical model, or anything else that is not part of
the GUI.
Do please read the tutorial to which I linked. There's a reason I provided
that link.
> Also, I thought the stuff I have in the constructor belonged there.
Not all of it. The program itself must run from a *completely*
constructed object. You start the program from inside the
constructor, therefore it is running on an *incompletely*
constructed object.
> I dont know where to call the constructor from if not from 'main'.
You should call the constructor from 'main()', provided you properly
guard it inside the 'invokeAndWait()' call.
Why did you think I recommended otherwise?
> I did some reading about threads being unsafe.
>
> It would be very helpful to me if you could show how to rearrange the
> code like you say would be better. If you have the time, it would be
> very helpful. Thanks.
What was wrong with what I already showed you (and you quoted)?
--
Lew
[toc] | [prev] | [next] | [standalone]
| From | B1ll G4tes <wm.gat3s@micro5oft.quux> |
|---|---|
| Date | 2012-06-27 22:23 -0400 |
| Message-ID | <jsgf66$tb4$1@speranza.aioe.org> |
| In reply to | #15696 |
On 27/06/2012 9:54 PM, Lew wrote: > GUI actions are all things that happen on the GUI, such as creating > a 'JFrame', calling 'pack()', playing with 'Graphics', or anything else that > is part of the GUI. Not all Graphics objects are created equal in that regard. Some are associated with GUI things, e.g. the one you get calling getGraphics on a JComponent. Some are not, e.g. if you get one to draw on a BufferedImage. -- A fatal exception 0E has occurred at 0028:C0011E36 in VXD VMM(01) 00010E36. The current application will be terminated. * Press any key to terminate the current application.
[toc] | [prev] | [next] | [standalone]
Page 3 of 4 — ← Prev page 1 2 [3] 4 Next page →
Back to top | Article view | comp.lang.java.programmer
csiph-web