Hello There, Guest! Login or Register


Clean up;
#1
I think if we are to clean up the code, it might be a better idea to set out some guidelines?

I've seen some of your comments Jay, and personally I dislike this format:

Code:
//comment lala

I don't like too much spacing, but it can be a little harder to read. The // should be seperated from the comment itself as follows in my opinion:

Code:
// Comment lala

.. cleaner. Another thing I haven't quite picked up on with you, but I think we should have some kind of syntax we use..

Personally I like the following:

Code:
if(expression) {
    statements;
}

There's a space between the ) and {, but the last } is not indented with the code (as I have seen in some old chunks of LVP), meaning it's easy to see where things start and end.

Any suggestions?
Reply
#2
It's much easier to read if a { is on the next line. Also a space between if and ( and spaces around 'expression' will be cleaner imo. Result:

Code:
if ( expression )
{
    statements;
}
Reply
#3
psh of course, I always try to upload my code as neat as possible on svn. :>

On another note, the whole { on its own line is argued by programmers all over the world :>
I personally like having it on the line of the statement. As tomozj displayed.

[me=dab]looks at Badeend[/me]
Reply
#4
(09-16-2008, 03:02 AM)Badeend link Wrote: Also a space between if and ( and spaces around 'expression' will be cleaner imo.
For me it all depends on what the condition looks like. For example:
Code:
if (number >= 6)
{
    // Stuff
}
Which looks perfectly clean. On the other hand, I prefer to write something like...
Code:
if (number >= aNumbers[index])
{
...as:
Code:
if ( number >= aNumbers[ index ] )
{
But I guess there is no right or wrong here, it all depends on the programmer's personal taste. ;)
Reply
#5
I find too much spacing frustrating - I want to be able to get right at the code without a bunch of spaces in the way. Personal taste here as pointed out, but I find spacing at array indexes quite annoying, and I usually strip them from my code.

I tend to like adding the opening bracket on a new line if it's a function header, but otherwise it's a meh.

Whatever works, I've just seen some awful stuff in old code recently like this:

Code:
if(expression){
    statements;
    }

Really confusing to read, meh.

Apart from the spacing at the array positions, I don't mind other syntaxes mentioned. Meh.
Reply