|
I am forever reformatting other peoples SQL code (or generated SQL).
I have may own format rules, and once I get it in that format I can read it easy.
Unformatted, I can't make nor tail of it.
|
|
|
|
|
During my first year as a CompSci student, I got hold of a 'large' program: The 'Open Source' Pascal compiler, written in itself (yes, open source did exist before Linux! What Linux did was introducing the term) from ETH. In those days, a Pascal program couldn't be broken into modules: Everything had to be put into a single source file, even if it was a 20-30 kloc compiler.
This compiler source code was very consistent in the coding style of the tokenizer and parser. It was also very consistent in the semantic analysis. And it was highly consistent in the code generating functions. Three quite different, but very consistent coding styles, within a single source file. Even today I am surprised that they managed to keep it that way, without messing up each other's coding style. (I assume that there must have been three guys resposible for one part each.)
|
|
|
|
|
That story arc gets quite interesting...
veni bibi saltavi
|
|
|
|
|
I wouldn't convict him, might even help hold her down.
|
|
|
|
|
Here we go....
On a more serious note, I've seen both coding styles, and I despise #2. It just makes the code harder to read - to me. Am I just an old fart? I read an actual flaming rant about CamelCase (this is not) vs. camelCase (camels have humps in the middle). So, I finally get that.
But the curlies?
jumping into fox hole now.
Charlie Gilley
<italic>Stuck in a dysfunctional matrix from which I must escape...
"Where liberty dwells, there is my country." B. Franklin, 1783
“They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759
|
|
|
|
|
I would have to agree. When you are looking at code you have never seen before, anything that makes it easier to understand what the code is doing is helpful. Separating out sections of code visually does help conceptualize program flow and structure.
if (Object.DividedByZero == true) { Universe.Implode(); }
Meus ratio ex fortis machina. Simplicitatis de formae ac munus. -Foothill, 2016
|
|
|
|
|
I am like you, love style #1, just can't stand style #2.
|
|
|
|
|
Yeah - I hate reading 1TB because it does it's damnedest to hide the open bracket.
I'm not fond of Allman either - I use Whitesmiths as it just feels more "together" to indent the brackets to the same level as the code block it's enclosing:
if (a == b)
{
c();
}
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
if (a == b)
{
c();
}
UGH! I really don't like that one at all.
I used to do things K&R style:
if (a == b) {
c();
}
but then I realised that that's a little bit ghastly, too. So for a long time I've been doing it this way ...
if (a == b)
{
c();
}
... and getting a little bit miffed with anyone that doesn't. It really makes code flow much more visible.
|
|
|
|
|
I like it because it's consistent - it's treating the indentation of the compound statement and the single statement in the same way.
But it's horses for courses!
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
I can see the logic behind it and I've worked with a couple of people that have used it but I find it murder on the eyeballs.
Needless to say, if that was the one that I used, I'd probably say the same about my way (i.e. the proper way ).
|
|
|
|
|
I guess it depends on whether you consider the brackets part of the enclosing code block or the enclosed code block.
|
|
|
|
|
This!
Stroustrup K&R is what I learned, and seems more logical to me (and easier on my eyes). Brackets separate a block of code that is performed as part of a command, so to my mind the opening bracket belongs on the same line as the command.
if (true) {
DoThis();
}
VB adopts K&R in its own way. Note the keywords and closing keywords:
If True Then
DoThis()
End If
But now I've probably hurt my case.
(edited to clarify the Stroustrup version of K&R)
If you think 'goto' is evil, try writing an Assembly program without JMP.
|
|
|
|
|
|
I'm weird. for me it depends on the language, because I let my style be dictated by the larger community choice. I suppose that means I'm either indecisive, or I don't really care one way or the other.
C/C++/C# - Style 1, and I can't abide code written in style 2.
Javascript - Style 2. To the point that if I see javascript written in Style 1, I don't even recognize it as valid javascript.
Java? By the time I've reached my first curly, I've already written too much Java, so I just delete the project and start over in a better language.
|
|
|
|
|
Interesting, since I don't recognize javascript as a valid language.
(My "favorite" part about Python: scratching your head why something is failing only to realize that one line is indented using spaces and the next tabs.)
|
|
|
|
|
|
Dan Neely wrote: The javascript engine's semicolon injector behaves in ways that make it clear it doesn't regard opening braces on the next line as valid js either.
Yeah, I really wish there was a way to turn off ASI in my js files (like a 'use strict' kind of thing).
|
|
|
|
|
I think on the one of the Microsoft Guide lines for Capitalisation they call it PascalCasing instead of CamelCasing and then use camelCase also.
|
|
|
|
|
Yes you are an old fart, who cares what other people source looks like...
Using a decent editor (even the Visual Studio editor does this):
just go to the last close curly
delete it, then put it back
(or just highlight it and type close curly)
the code gets reformatted to your default style set in your editor.
a lot simpler then posting messages complaining and insisting 'your way is better for everybody'
I can tell you, without even seeing it: your way is crap, that is it's crap to everybody except yourself, just as mine is crap for anybody but me. And yes, your company guidelines are crap too, to anyone except the pillock who created the 'guidelines'; AKA 'somebody with way too much free time' - and you should tell him that - do some bloody real/proper work instead of wasting time making other peoples lives miserable.
Help make the world a better place: Stop bitching about other peoples ways, particularly when there's simple tools that in seconds let you 'fix it' and carry on your own way - these things matter not at all.
And for sure, one day, when you get promoted: just DON'T become that jerk-off that creates "company coding standards" and other such nonsense; leave it, get a life, and let other people have theirs too.
|
|
|
|
|
ffs, all I did was solicit opinions....
Robert, please take your meds and go to your quiet place...
Charlie Gilley
<italic>Stuck in a dysfunctional matrix from which I must escape...
"Where liberty dwells, there is my country." B. Franklin, 1783
“They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759
|
|
|
|
|
To be sure, I can't read Melody's style at all.
I associate that code style with idiots who just keep jamming random code in until something happens ...
|
|
|
|
|
I like #1 but actually use #2 in practice.
{To-do: fill section with wit}
|
|
|
|
|
For me K&R. CamelCase when public members, camelCase when private.
GCS d--- s-/++ a- C++++ U+++ P- L- E-- W++ N++ o+ K- w+++ O? M-- V? PS+ PE- Y+ PGP t++ 5? X R++ tv-- b+ DI+++ D++ G e++>+++ h--- ++>+++ y+++* Weapons extension: ma- k++ F+2 X
If you think 'goto' is evil, try writing an Assembly program without JMP. -- TNCaver
When I was six, there were no ones and zeroes - only zeroes. And not all of them worked. -- Ravi Bhavnani
|
|
|
|
|
BEFORE - for C# style and NOW - Java.
|
|
|
|