Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (517)
Games in Android Showcase (123)
games submitted by our members
Games in WIP (577)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: 1 2 [3]
  ignore  |  Print  
  Brace styles  (Read 10688 times)
0 Members and 1 Guest are viewing this topic.
Offline kemalenver

Senior Newbie




null pointer exception


« Reply #60 - Posted 2003-08-13 21:41:33 »

Its got to be number 2 Smiley  I really find number 1 to be confusing to read.  I dont really care about saving vertical space I've got a scroll wheel on my mouse!

I think I probably prefer #2 because of my old Pascal days, and now I subconsciously read { as BEGIN,  and  } as END lol
Offline GergisKhan

Junior Duke




"C8 H10 N4 O2"


« Reply #61 - Posted 2003-08-14 00:42:44 »

swpalmer,

Your last post is EXACTLY the reason I have won the brace style argument at any company I have been at.

It breaks the symmetry.  You can't easily identify a block of code.

Between that, forcing no single-line unbraced ifs, fors, and whiles, I feel I have made a signifcant contribution to the coding style of various companies.  Grin

Seriously, though, I think that any argument towards compressing code to "save space" is seriously pushing towards nonreadability.  I prefer very open, very well spaced (I'm a maniac when it comes to this) source code that is easily navigable.

I use IDEA as my development environment, and there's two things about it that totally make life simple for me.  One, built in is the concept of code folding.  I'm told that there are other IDEs that have this now also.  You can selectively fold a block of code so that a little "+" sign in the left gutter appears, and you can unfold it if you wish.  Second, I use a plug in called Tabifier, and yes, as I said I am a maniac when it comes to this.  I align all my important declarations and definitions to a ridiculous nature:

1  
2  
3  
boolean b    = false;
int     i    = 3;
String  name = 2;

Why?  So I can read it!

gK

"Go.  Teach them not to mess with us."
          -- Cao Cao, Dynasty Warriors 3
Offline nickdotjava

Junior Duke




I have fallen to the dark side.  I'm using DX9


« Reply #62 - Posted 2003-08-19 02:51:31 »

Quote
come on people, #1 is the way to go....#2 reminds me of a double negative.

public void foo()
{
    //blah
}

is readable, but the braces do not have to be lined up because in

public void foo(){
    //blah
}

the exact start of the function already lines up with the exact end, and doesnt this just make sense? i'm sure you all realize this but it's more symmetrical to have ONE start line and ONE end line.


symbols such as { && ||, etc really shouldnt start their own lines, just as the words "including", "and", and "or" do not properly begin sentences in English.

thats why I prefer

public void foo(args){
    if(long boolean statement one &&
         long boolean statement two){
    }
    else if(boolean){
    }
}

over this monstrosity:

public void foo(args)
{
    if(long boolean statement one
    &&  long boolean statement two)
    {
    }
    else if(boolean)
    {
    }
}



Quiet!  Nexus is one of the guys working on the project.   :P

-Nick

"Oh ya, that's trivial.  I should have it done in an hour."
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline swpalmer

JGO Coder


Exp: 12 years


Where's the Kaboom?


« Reply #63 - Posted 2003-08-19 03:03:16 »

What project?

Offline nech_neb

Junior Duke




Java for LIFE !!!


« Reply #64 - Posted 2003-08-19 18:45:27 »

Arg!!
This topic just never dies....

#2 !!! ALL THE WAY !!!
In the end, like someone previously mentioned,
its just personal preference....

Personally, I find #2 looks better....
and seems to make more sense if you look
at your code as a picture.

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
public void foo(args){ 
     if(true){
     }
     else if(boolean){
     }
}
 
public void foo(args)
{
     if(true)
     {
     }
     else if(boolean)
     {
     }
}


To me, its visually more balanced ,
Imagine rotating your code 90 degrees
counter clockwise, doesn't #2 look
alot better then #1 ^_^

Anyways, the above rambling is just
for rambling's sake. I find it interesting
how many people have extremly strong
opinions on something relatively trivial.
Myself included.

8: Undefined index: online
File: /home/jgo/public_html/Themes/default/Display.template.php (main sub template - eval?)
Line: 161