123
-=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- (c) WidthPadding Industries 1987 0|446|0 -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=-
Socoder -> Off Topic -> Aw, geeze, Flamewar...

Page : 1 2 Next
Prev
Tue, 06 Jul 2010, 10:49
Jayenkai
I'm about to start a flamewar, and I apologise beforehand..

From here (a good read)



Here's the thing..

I prefer the first one.

The lines don't have giant spaces between them, and the text doesn't have huge inexplicable spaces.

My eyes can very easily see VariableName and Value TOGETHER, AT ONCE. I've never once thought to myself "OMG! I need a list of values, without reading the variables!"
I want both bits of data together.

Having giant tabs like that?
That's horrible..

It's like reading a book, and having all the names lined up on one side of the page, no matter wtf's going on in the rest of the line.

Nasty!
eeuuggh..

...
I agree with most of the other stuff, especially the parenthesis.. DS coding made me do that. You never quite knew what the damn thing was going to start adding up, next!


.. oh except the ">>" bit he mentions near the end. Trying to do division on a crappy processor made me switch to >>'s for a while.. Might be ok now, but if you're under pressure, go >>!

-=-=-
''Load, Next List!''
Tue, 06 Jul 2010, 11:11
Stealth
I prefer the first one as well (even though the second one is easier to read). It feels more right.

However, the first one needs more white-spaces. He exaggerated his point by making the first one terribly smashed together. He also used a lot of variables which work great for what he is suggesting, but real code has more if statements and functions twined in.

-=-=-
Quit posting and try Google.
Tue, 06 Jul 2010, 12:10
Mog
Personally, If he had used the braces format from the first block, in the second one, i'd be all for it. But each one has it's flaws.

First one is too smashed together.
Second one is too spread out.

I don't do the whole 'lets space our variables waaay out', that's stupid, but when i have a new block of calls or iterations or whatnot, i put a blank line just before it.

I'm going with #1 as well.



-=-=-
I am Busy Mongoose - My Website

Dev PC: AMD 8150-FX, 16gb Ram, GeForce GTX 680 2gb

Current Project: Pyroxene
Tue, 06 Jul 2010, 12:25
HoboBen
I like the second one. I *love* whitespace.

Partly, I find that despite my memory being terrible usually, I've got very good *visual* memory for code (which is strange, because I have terrible memory for faces and anything else visual).

But the layout, spacing, shape and syntax highlighting of the code lets me easily pick out the exact section that I'm after. I can't do that with a solid wall.

-=-=-
blog | work | code | more code
Tue, 06 Jul 2010, 13:29
Cower
I demand a third option.

Also, aside from control structures, I think the majority of statements (or otherwise the bits of code that do things, as opposed to structures and such) is either going to be some form of assignment or a function call. If you're having a hard time finding one of two things, you've probably got a bigger problem with your code than formatting.
Tue, 06 Jul 2010, 14:31
Mog
I demand a third option.


I second the demand for a third option!

-=-=-
I am Busy Mongoose - My Website

Dev PC: AMD 8150-FX, 16gb Ram, GeForce GTX 680 2gb

Current Project: Pyroxene
Tue, 06 Jul 2010, 14:46
CodersRule
I use the second one in CSS, but mostly I prefer the first.
Tue, 06 Jul 2010, 15:00
Stealth
Here's how I prefer:



-=-=-
Quit posting and try Google.
Tue, 06 Jul 2010, 15:17
Mog
Stealth did it right. All hail stealth.
Tue, 06 Jul 2010, 15:35
Jayenkai
Much better...

Tue, 06 Jul 2010, 16:24
Stealth
While we are on this topic, does anyone else hate this:



-=-=-
Quit posting and try Google.
Tue, 06 Jul 2010, 16:34
CodersRule
I prefer

actually
Tue, 06 Jul 2010, 18:53
mindstorm8191
I'm sort of caught in the middle between the first and second options. In the second option, while I do like how the variables are listed, with the white space between variable name and assignment, I don't like the space with the control flow. But I guess that's just me.

As for the function layout, I like CodersRule's method best.

-=-=-
Vesuvius web game
Tue, 06 Jul 2010, 21:12
JL235
I prefer the second one in every way, except that braces for minor statements (namely ifs and loops) should start on the same line.

Extra whitespace is not for making code easy to read, but to be easy to read at a glance!

I now also do...
in all my coding.
Wed, 07 Jul 2010, 02:28
Jayenkai
I'd take "Human Readability" for the function stuff..

See how you wrote (namely ifs and loops), and not ( namely ifs and loops )

That..
2nd one just looks weird!

-=-=-
''Load, Next List!''
Wed, 07 Jul 2010, 05:49
Spare

feels the most right for me
Wed, 07 Jul 2010, 09:04
Erebel55
I agree with Spare, nice and clean.
Wed, 07 Jul 2010, 10:00
9572AD
I like the blank lines and the bracketing in the second one, but that lining-up all the equals signs can get right out.

-=-=-
All the raw, animal magnetism of a rutabaga.
Fri, 09 Jul 2010, 12:02
Stealth
I do this a lot:



I do it so the comments look prettier and everything is spaced up better. Should this be a programmer sin?

-=-=-
Quit posting and try Google.
Fri, 09 Jul 2010, 12:26
JL235
Stealth I do it so the comments look prettier and everything is spaced up better. Should this be a programmer sin?

Yes, it's too spaced out. This is better...

Fri, 09 Jul 2010, 12:59
Stealth
@JL235

That's what drives me crazy. The comment is technically inside the first statement in your example. It doesn't visually make sense.

-=-=-
Quit posting and try Google.
Fri, 09 Jul 2010, 13:21
Jayenkai
Comments are comments! They don't matter!
(although, everyone knows they go after the {, so they stick out after the end of the line.)

As far as the 'else' linebreak goes, I'm not too fussed, depends on how complicated the middle bits are..

-=-=-
''Load, Next List!''
Fri, 09 Jul 2010, 13:27
spinal
I do it thiswize -


-=-=-
Check out my excellent homepage!
Fri, 09 Jul 2010, 13:41
JL235
Stealth That's what drives me crazy. The comment is technically inside the first statement in your example. It doesn't visually make sense.

I disagree. If it was inside then it would be indented.



I also comment differently according to what type of comment it is. i.e.

Code that is commented out has it's comment mark flush with the left hand side. Normal comments aren't (unless they are at the top level of indentation, which is very rare in Java for a one line comment). The reason why is because if you comment out code then you should either remove it or undo the commenting very soon. You shouldn't have code commented out for long periods of time, so the comment is purely temporary and I place all temporary code flush with the left hand side.

For example with code...

Temporary debugging code is again flush with the left side so it's easier to spot and delete later.
Fri, 09 Jul 2010, 16:25
steve_ancell
I like using whitespace and plenty of indents, so I guess it's the second one for me Jay.
Fri, 09 Jul 2010, 21:51
Scherererer
I always put braces on separate lines. I don't care that it takes more space. Spare's hit it right on the nose for me.

The bottom line is though, that when/if you work on a team, you need to all agree to something. Whatever it is dosesn't really matter, but as long as everyone uses the same conventions then it's okay.

-=-=-
YouTube Twitter
Computer Science Series: Logic (pt1) (part 2) (part 3) 2's Complement Mathematics: Basic Differential Calculus
Page : 1 2 Next
Prev