Click here to Skip to main content
15,901,505 members

Survey Results

Where should the braces go?   [Edit]

Survey period: 25 Feb 2001 to 3 Mar 2001

What is your preference for placing braces. See the braces page for a list of options.

OptionVotes% 
Braces starting on control line12215.60
Braces starting on line under control line, non-indented56472.12
Braces starting on line under control line, indented729.21
Braces starting on control line, closeing brace indented162.05
Other (please demonstrate!)81.02



 
GeneralRe: ... followup question: do you use the same format that your tutor did (incl favourate book) Pin
James R. Twine28-Feb-01 8:53
James R. Twine28-Feb-01 8:53 
GeneralRe: ... followup question: do you use the same format that your tutor did (incl favourate book) Pin
Chris Losinger28-Feb-01 9:02
professionalChris Losinger28-Feb-01 9:02 
GeneralRe: ... followup question: do you use the same format that your tutor did (incl favourate book) Pin
Gavin Greig28-Feb-01 22:56
Gavin Greig28-Feb-01 22:56 
GeneralRe: ... followup question: do you use the same format that your tutor did (incl favourate book) Pin
Chris Losinger1-Mar-01 4:17
professionalChris Losinger1-Mar-01 4:17 
GeneralRE: uncomfortable standards Pin
Sir Gras of Berger1-Mar-01 7:21
Sir Gras of Berger1-Mar-01 7:21 
GeneralRe: RE: uncomfortable standards Pin
James R. Twine1-Mar-01 14:24
James R. Twine1-Mar-01 14:24 
GeneralRe: ... followup question: do you use the same format that your tutor did (incl favourate book) Pin
2-Mar-01 16:51
suss2-Mar-01 16:51 
GeneralRe: ... followup question: do you use the same format that your tutor did (incl favourate book) Pin
GeVanCo3-Mar-01 8:13
GeVanCo3-Mar-01 8:13 
Following the same 'convention' a professor is teaching you a language is certainly not always a good idea. I myself just finished a basic course about the Java language in an inter-university course and what the prof has given to us as code example, is really awfull (although the prof himself is a very capable and intelligent person). To give you some examples, look to the code snippet below:
private class MyHandler implements Handler
  { public void process(int position, String string)
      { printPosition(position, '>');
        printString(string); }}

private String readString()
  { try
      { return in.readLine(); }
    catch (IOException io)
      { return " "; }}

private void readCommand()
  { position = 0;
    command = ' ';
    System.out.print("command>");
    try
      { String str = in.readLine();
        for (int pos = 1; pos < str.length(); pos++)
          { char ch =  str.charAt(pos);
            if ((ch < '0') | (ch > '9'))
              return;
            position = 10*position + ch - '0'; }
        command = str.charAt(0); }
    catch (IOException io)
      { return; }}

private void printNumber(int pos, int wdt)
  { if (pos > 9)
      printNumber(pos/10, wdt-1);
    else
      while (wdt-- > 0)
        System.out.print(' ');
    System.out.print(pos % 10); }

private void printPosition(int pos, char chr)
  { printNumber(pos, 6);
    System.out.print(chr); }

Pls. feel free to see in an instant the 'structure' of the Java methods. I'm hardly able to read this piece of code.

So, taking this as an example is very bad, but that's my personal opinion.

Therefore, I'm not sharing the idea you have to follow the styling of professors or even some books, like Bruce Eckel's book: 'Thinking in Java'. It's a tremendously useful book for those who want to learn Java, but the coding style is also not 'the ultimate'. This is the only 'weak' point in this book.

Just to give you some examples of why you should NOT always follow books and/or people... Smile | :)
GeneralRe: ... followup question: do you use the same format that your tutor did (incl favourate book) Pin
James R. Twine3-Mar-01 9:11
James R. Twine3-Mar-01 9:11 
GeneralRe: ... followup question: do you use the same format that your tutor did (incl favourate book) Pin
3-Mar-01 21:32
suss3-Mar-01 21:32 
General"Fun" coding standards ;) Pin
George27-Feb-01 6:45
George27-Feb-01 6:45 
GeneralRe: Pin
Chris Losinger27-Feb-01 7:10
professionalChris Losinger27-Feb-01 7:10 
GeneralRe: Pin
James R. Twine27-Feb-01 8:01
James R. Twine27-Feb-01 8:01 
GeneralWhy not? Pin
George27-Feb-01 8:49
George27-Feb-01 8:49 
GeneralRe: Why not? Pin
James R. Twine27-Feb-01 15:12
James R. Twine27-Feb-01 15:12 
GeneralRe: Why not? Pin
George1-Mar-01 2:03
George1-Mar-01 2:03 
GeneralRe: Why not? Pin
James R. Twine1-Mar-01 13:00
James R. Twine1-Mar-01 13:00 
GeneralRe: Why not? Pin
George2-Mar-01 5:13
George2-Mar-01 5:13 
GeneralAwwww, Geeze... Pin
James R. Twine2-Mar-01 13:13
James R. Twine2-Mar-01 13:13 
GeneralRe: Why not? Pin
Chris Losinger2-Mar-01 5:25
professionalChris Losinger2-Mar-01 5:25 
GeneralRe: Why not? Pin
James R. Twine2-Mar-01 13:18
James R. Twine2-Mar-01 13:18 
GeneralRe: Why not? Pin
Chris Losinger3-Mar-01 7:48
professionalChris Losinger3-Mar-01 7:48 
General*I* will determine what I was trying to imply, if anything. Pin
James R. Twine3-Mar-01 9:07
James R. Twine3-Mar-01 9:07 
GeneralRe: *I* will determine what I was trying to imply, if anything. Pin
Chris Losinger3-Mar-01 11:07
professionalChris Losinger3-Mar-01 11:07 
GeneralPascal and Option 2 Pin
27-Feb-01 5:52
suss27-Feb-01 5:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.