Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #15589 > unrolled thread

I need a different approach - suggestions please

Started bybilsch <bilsch01@gmail.com>
First post2012-06-25 15:31 -0700
Last post2012-06-29 13:07 -0700
Articles 20 on this page of 75 — 16 participants

Back to article view | Back to comp.lang.java.programmer


Contents

  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 2 of 4 — ← Prev page 1 [2] 3 4  Next page →


#15593

FromLew <lewbloch@gmail.com>
Date2012-06-25 18:36 -0700
Message-ID<f5a21759-b102-4a8a-b701-c84e52855962@googlegroups.com>
In reply to#15591
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);
         }
     });
 } 

[toc] | [prev] | [next] | [standalone]


#15607

Frombilsch <bilsch01@gmail.com>
Date2012-06-26 13:24 -0700
Message-ID<jsd5p9$pu5$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);
>           }
>       });
>   }

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.

[toc] | [prev] | [next] | [standalone]


#15609

FromLew <lewbloch@gmail.com>
Date2012-06-26 13:49 -0700
Message-ID<4663ccdc-7b86-402b-a49c-0f89a6e2033f@googlegroups.com>
In reply to#15607
bilsch wrote:
> Lew wrote:
>> 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);
>>           }
>>       });
>>   }
> 
> 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.

Thread issues do apply here, as I explained and you quoted:
>> The problem is that the GUI won't work right if you do that [make GUI calls
>> from the main thread]. You have to
>> move GUI actions onto the "Event Dispatch Thread" (EDT), a background
>> thread that the system creates to handle all GUI actions.

Mimicking bad code is not good practice.

More recent references, including particularly the (gasp!) Java Swing tutorial
give better examples.

Try
<http://docs.oracle.com/javase/tutorial/uiswing/concurrency/index.html>

-- 
Lew

[toc] | [prev] | [next] | [standalone]


#15613

FromGene Wirchenko <genew@ocis.net>
Date2012-06-26 14:04 -0700
Message-ID<1p8ku7t6niu12h4amqpacvqvd9nv659opq@4ax.com>
In reply to#15607
On Tue, 26 Jun 2012 13:24:09 -0700, bilsch <bilsch01@gmail.com> wrote:

[snip]

>Many things are because I mimic what I see in other programs. Your 

     Bear in mind that there is a lot of not-so-good code out there.
There is also some very good code.

>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.

>understanding threads because I read about them and I don't see that 
>they apply here.  I don't really understand them.

     Since this is your own problem, make that part of the spec.
Threads are where you have more than one path of execution.  For a
calculator, you do not need that for the basic functionality.  Once
you do get your calculator working, then you can add to it or start
another project in order to learn threads.

Sincerely,

Gene Wirchenko
     

[toc] | [prev] | [next] | [standalone]


#15618

FromLew <lewbloch@gmail.com>
Date2012-06-26 14:34 -0700
Message-ID<038a5966-8619-470d-9a65-c15f214c5a0f@googlegroups.com>
In reply to#15613
Gene Wirchenko wrote:
> bilsch wrote:
> 
> [snip]
> 
>> Many things are because I mimic what I see in other programs. Your 
> 
>      Bear in mind that there is a lot of not-so-good code out there.
> There is also some very good code.
> 
>> 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.

>> understanding threads because I read about them and I don't see that 
>> they apply here.  I don't really understand them.
> 
>      Since this is your own problem, make that part of the spec.
> Threads are where you have more than one path of execution.  For a
> calculator, you do not need that for the basic functionality.  Once

For a Swing program you always need them.

> you do get your calculator working, then you can add to it or start
> another project in order to learn threads.

They're already using Swing, requiring that at least they know how to 
push GUI actions onto the EDT.

-- 
Lew

[toc] | [prev] | [next] | [standalone]


#15627

FromGene Wirchenko <genew@ocis.net>
Date2012-06-26 16:26 -0700
Message-ID<53hku7dsa5dqi7nru47qemqg75hnuuv7bs@4ax.com>
In reply to#15618
On Tue, 26 Jun 2012 14:34:13 -0700 (PDT), Lew <lewbloch@gmail.com>
wrote:

>Gene Wirchenko wrote:
>> bilsch wrote:
>> 
>> [snip]
>> 
>>> Many things are because I mimic what I see in other programs. Your 
>> 
>>      Bear in mind that there is a lot of not-so-good code out there.
>> There is also some very good code.
>> 
>>> 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.

>>> understanding threads because I read about them and I don't see that 
>>> they apply here.  I don't really understand them.
>> 
>>      Since this is your own problem, make that part of the spec.
>> Threads are where you have more than one path of execution.  For a
>> calculator, you do not need that for the basic functionality.  Once
>
>For a Swing program you always need them.

     Ah, then my advice is to use it minimally for this project then
...

>> you do get your calculator working, then you can add to it or start
>> another project in order to learn threads.
>
>They're already using Swing, requiring that at least they know how to 
>push GUI actions onto the EDT.

     KIS for now.

Sincerely,

Gene Wirchenko

[toc] | [prev] | [next] | [standalone]


#15632

FromLew <lewbloch@gmail.com>
Date2012-06-26 16:47 -0700
Message-ID<2445429c-c5b9-4e3b-a2ea-5a7836aa4806@googlegroups.com>
In reply to#15627
Gene Wirchenko wrote:
> Lew wrote:
>> 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.

Bullshit. That is my observation.

The Java Coding Conventions have been in play since 1999. I have 
worked in many Java shops. All had coding standards. Mostly they 
adhere to the official conventions, but all accepted or required certain 
slight variations, pretty much consistently from one to the next.

Why would you say such a thing?

-- 
Lew

[toc] | [prev] | [next] | [standalone]


#15648

FromGene Wirchenko <genew@ocis.net>
Date2012-06-26 20:04 -0700
Message-ID<01uku7tno95tidf22nn9m9pukolo8hs6ru@4ax.com>
In reply to#15632
On Tue, 26 Jun 2012 16:47:37 -0700 (PDT), Lew <lewbloch@gmail.com>
wrote:

>Gene Wirchenko wrote:
>> Lew wrote:
>>> 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.
>
>Bullshit. That is my observation.
>
>The Java Coding Conventions have been in play since 1999. I have 
>worked in many Java shops. All had coding standards. Mostly they 
>adhere to the official conventions, but all accepted or required certain 
>slight variations, pretty much consistently from one to the next.
>
>Why would you say such a thing?

     Because you keep harping about it.  Perish the thought that
someone use something else workable.

Sincerely,

Gene Wirchenko

[toc] | [prev] | [next] | [standalone]


#15644

FromArne Vajhøj <arne@vajhoej.dk>
Date2012-06-26 22:18 -0400
Message-ID<4fea6d75$0$293$14726298@news.sunsite.dk>
In reply to#15627
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.

Arne

[toc] | [prev] | [next] | [standalone]


#15646

FromJoshua Cranmer <Pidgeot18@verizon.invalid>
Date2012-06-26 22:59 -0400
Message-ID<jsdsub$or8$1@dont-email.me>
In reply to#15644
On 6/26/2012 10:18 PM, Arne Vajhøj 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.

State-sponsored religion is still religion :-P

All things said and done, though, it's a very good idea to follow those 
guidelines unless you have extremely compelling reasons not to.

-- 
Beware of bugs in the above code; I have only proved it correct, not 
tried it. -- Donald E. Knuth

[toc] | [prev] | [next] | [standalone]


#15690

FromArne Vajhøj <arne@vajhoej.dk>
Date2012-06-27 21:30 -0400
Message-ID<4febb3be$0$289$14726298@news.sunsite.dk>
In reply to#15646
On 6/26/2012 10:59 PM, Joshua Cranmer wrote:
> On 6/26/2012 10:18 PM, Arne Vajhøj 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.
>
> State-sponsored religion is still religion :-P

Yes.

But for coding conventions there are a good logical
scientific reason why it is better to use the same
convention as other.

In fact that is the main purpose of a coding convention.

Religion is a bit more let us call it "fuzzy".

> All things said and done, though, it's a very good idea to follow those
> guidelines unless you have extremely compelling reasons not to.

Yes.

Arne


[toc] | [prev] | [next] | [standalone]


#15784

FromWanja Gayk <brixomatic@yahoo.com>
Date2012-07-02 11:32 +0200
Message-ID<MPG.2a5b89067b871e65989713@202.177.16.121>
In reply to#15646
In article <jsdsub$or8$1@dont-email.me>, Pidgeot18@verizon.invalid 
says...

> >>> It is best to use the Java Coding Conventions or something very close.

> >>       That is your religion.

> > Facts not religion.
> 
> State-sponsored religion is still religion :-P

So what? If this religion is something that enough people agree on, 
enough people have some sort of common baseline that aids their 
communication.

"Go to hell" 
"Thank you Sir, could you tell me which bus line I need to take to get 
there?"

Kind regards,
Wanja

-- 
..Alesi's problem was that the back of the car was jumping up and down 
dangerously - and I can assure you from having been teammate to 
Jean Alesi and knowing what kind of cars that he can pull up with, 
when Jean Alesi says that a car is dangerous - it is. [Jonathan Palmer]

--- Posted via news://freenews.netfront.net/ - Complaints to news@netfront.net ---

[toc] | [prev] | [next] | [standalone]


#15786

FromGene Wirchenko <genew@ocis.net>
Date2012-07-02 09:47 -0700
Message-ID<40k3v7lpge3b787se0gvj6cl6rr1kfm4on@4ax.com>
In reply to#15784
On Mon, 2 Jul 2012 11:32:34 +0200, Wanja Gayk <brixomatic@yahoo.com>
wrote:

>In article <jsdsub$or8$1@dont-email.me>, Pidgeot18@verizon.invalid 
>says...
>
>> >>> It is best to use the Java Coding Conventions or something very close.
>
>> >>       That is your religion.
>
>> > Facts not religion.
>> 
>> State-sponsored religion is still religion :-P
>
>So what? If this religion is something that enough people agree on, 
>enough people have some sort of common baseline that aids their 
>communication.

     Yup.  Unfortunately, this common baseline of communication is
sometimes "Death to the heretics!" or a variation thereof.  This
baseline of communication also all too often appears to sabotage
communication with others not of that ilk.

>"Go to hell" 
>"Thank you Sir, could you tell me which bus line I need to take to get 
>there?"

     I just checked Greyhound, and they do not appear to go there.
(Hell, MI, that is.)

Sincerely,

Gene Wirchenko

[toc] | [prev] | [next] | [standalone]


#15649

FromGene Wirchenko <genew@ocis.net>
Date2012-06-26 20:06 -0700
Message-ID<63uku71ckap2t9ekhq8e7l10sp08q56tn0@4ax.com>
In reply to#15644
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.

     My coding conventions are cross-language as much as I can make
them.

Sincerely,

Gene Wirchenko

[toc] | [prev] | [next] | [standalone]


#15671

FromLew <lewbloch@gmail.com>
Date2012-06-27 11:42 -0700
Message-ID<2a9d3151-c8a9-49fb-b80f-268233993dce@googlegroups.com>
In reply to#15649
Gene Wirchenko wrote:
> Arne Vajhøj wrote:
> 
> > Gene Wirchenko wrote:
> >> Lew 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.
> 
>      My coding conventions are cross-language as much as I can make
> them.

You calling the conventions a "religion" neither invalidates nor diminishes
the value of the official conventions.

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.

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 
the industry standards, please. I know it makes you feel all important and 
powerful and all, but it doesn't serve those wishing to learn how best to 
be *professional* Java programmers.

-- 
Lew

[toc] | [prev] | [next] | [standalone]


#15679

FromGene Wirchenko <genew@ocis.net>
Date2012-06-27 14:09 -0700
Message-ID<0osmu7lj6kirqc51brrjabebhn2om2mn3a@4ax.com>
In reply to#15671
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.

>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.  Since I do not use only one
language, I want conventions that work across many languages.  If I
work in a different environment, I will code according to what
conventions there are insofar as it does not endanger the quality of
my code.

     Anyone who has difficulty reading my code is invited to learn
programming.

>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 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.

>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.  Making up things about me
may help you snark me yet again, but it does little for your point. If
learning how to best use Java depends so heavily on the official
conventions, Java is in horrible danger.  An example of this is the
official documentation which is very poor and rates a D for its
incompleteness.

Sincerely,

Gene Wirchenko

[toc] | [prev] | [next] | [standalone]


#15682

FromPatricia Shanahan <pats@acm.org>
Date2012-06-27 15:11 -0700
Message-ID<xd2dne531YmDGHbSnZ2dnUVZ_umdnZ2d@earthlink.com>
In reply to#15679
On 6/27/2012 2:09 PM, Gene Wirchenko wrote:
...
>       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 have largely given up on this newsgroup, and only drop in
occasionally, because of the tone of the discussion. In any case, this
newsgroup is dying from lack of new regulars, and I think that is a key
reason. If you get jumped on the first time you ask a question, why come
back? When I first showed up in comp.lang.java as a very experienced
programmer but new to Java, my questions were answered politely and my
mistakes were handled gently.

The failures of this newsgroup have not made me give up on Java, for
anything for which Java seems to me to be the most suitable of the
languages I know.

Of course, a language making things you need to do awkward is an
extremely good reason for using a different language. With so many
languages to choose from, there is no point fighting a language that is
not a good fit for what you are doing.

Patricia

[toc] | [prev] | [next] | [standalone]


#15697

FromArne Vajhøj <arne@vajhoej.dk>
Date2012-06-27 21:59 -0400
Message-ID<4febba9f$0$283$14726298@news.sunsite.dk>
In reply to#15682
On 6/27/2012 6:11 PM, Patricia Shanahan wrote:
> On 6/27/2012 2:09 PM, Gene Wirchenko wrote:
> ...
>>       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 have largely given up on this newsgroup, and only drop in
> occasionally, because of the tone of the discussion. In any case, this
> newsgroup is dying from lack of new regulars, and I think that is a key
> reason. If you get jumped on the first time you ask a question, why come
> back? When I first showed up in comp.lang.java as a very experienced
> programmer but new to Java, my questions were answered politely and my
> mistakes were handled gently.

I don't see it that way.

First.

The participation in most usenet groups is dropping. It is not
specific to cljp.

ISP's are dropping NNTP servers. Most people use various web
fora like stackoverflow.com etc..

Second.

I think newbies that are interested in learning usually get
an acceptable treatment. There may be exceptions. And maybe
it could be improved. But overall I think rudeness against
that group is the exception not the rule.

Who collects plenty of flaming is really another group. It is
the "OOP is just overhead", "patterns are useless", "I don't
want to follow the standard coding convention", "I don't want
to use the Java library because my own is better", "unit tests
are useless", "ORM's are useless", "make is the rigth build
toll for Java" etc. that gets the heat. And
it is not when they first state their opinion they get flamed,
but when they get explained why it is bad often with references
to well known sources and turn out not to be interested in
listening then the flame throwers get turned on.

And I believe that is warranted. cljp should be a group that
steer newbies towards becoming programmers suitable for the
job market with a healthy understanding of what is considered
best practice. cljp should not throw out the last 20 or 30
years of experiences gained often at huge costs.

It is probably not good for cljp's reputation that a huge
portion of posts are really long flame wars between
best practices and excentric ideas.

But I don't think it would be good for cljp's reputation if
half the recommendations was to write Java like poorly written
Cobol and nobody objected against it.

The problem is probably unsolvable.

I don't think we could get that certain group to migrate
to a new c.l.j.excentric group where unusual not recommended
ways of doing things should be the main topic.

Arne


[toc] | [prev] | [next] | [standalone]


#15703

FromDevil's Advocate <legal@hell.org>
Date2012-06-27 22:17 -0400
Message-ID<jsgerb$s7q$1@speranza.aioe.org>
In reply to#15697
On 27/06/2012 9:59 PM, Arne Vajhøj wrote:
> But I don't think it would be good for cljp's reputation if
> half the recommendations was to write Java like poorly written
> Cobol and nobody objected against it.

But, but, but ... but I thought you were *for* coding Java with the 
usual coding conventions!

;)

[toc] | [prev] | [next] | [standalone]


#15693

FromArne Vajhøj <arne@vajhoej.dk>
Date2012-06-27 21:40 -0400
Message-ID<4febb620$0$289$14726298@news.sunsite.dk>
In reply to#15679
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.

>> 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.

>> 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.

That includes naming convention.

If they are not, then I don't know why they are here.

>> 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.

If you want to write the entire class in a single line then do it.

But do not try to tell other that it is an acceptable way to write code.

>> 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.

Your choice.

But do not try to lead other that route.

Arne

[toc] | [prev] | [next] | [standalone]


Page 2 of 4 — ← Prev page 1 [2] 3 4  Next page →

Back to top | Article view | comp.lang.java.programmer


csiph-web