|
2 columns and use tabs all applications, including TSQL.
ctrl e d will reformat the current file in c#.
Red-Gate has an excellent formatter for stored procs.
As the lead developer I set the standards and if I find someone has reformatted my code I get quite grumpy.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Mycroft Holmes wrote: As the lead developer I set the standards and if I find someone has reformatted my code I get quite grumpy That's the biggest thing... everyone being on the same page. I'll never get you two column folks. But I do think the project will suffer if the team can't agree on one.
Jeremy Falcon
|
|
|
|
|
Now with wide displays is not as important, but 2 spaces (using tab) is good as it is not very space consuming but at the same time is clear enough to see the desired effect.
And of course this doesn't allow any debate. I'm right. Anyone thinking a different thing must be burnt in fire.
|
|
|
|
|
Joan M wrote: And of course this doesn't allow any debate. I'm right. Anyone thinking a different thing must be burnt in fire.
That's a good point Joan. I'm not sure why I didn't think of that before.
Jeremy Falcon
|
|
|
|
|
I've used so many differing styles (usually mandated by anal-retentive bosses) that today I just go with whatever (a) the company requires, or (b) the IDE inserts as a default.
The only problem with using tabs as a formatting mechanism is when reading code in a different editor, whose tab setting differs. Your nicely (and carefully) formatted code then looks like a formatting disaster.
If you have an important point to make, don't try to be subtle or clever. Use a pile driver. Hit the point once. Then come back and hit it again. Then hit it a third time - a tremendous whack.
--Winston Churchill
|
|
|
|
|
Daniel Pfeffer wrote: usually mandated by anal-retentive bosses
Amen to that brother.
Daniel Pfeffer wrote: The only problem with using tabs as a formatting mechanism is when reading code in a different editor, whose tab setting differs. Your nicely (and carefully) formatted code then looks like a formatting disaster.
That's the same exact reason I swapped to spaces. Especially in web development where you just know your code will be different machines that don't always have VS installed, etc.
Jeremy Falcon
|
|
|
|
|
Always used 3 spaces for punch cards. Reasonable compromise for easy resorting when the deck was dropped v maximising levels of indentation given that the width of a card was 80 cols, and the last 8 of then were for sequence numbers. (Also useful for old versions of FORTRAN where statements started in col 7 - 2 * 3 spaces).
Now we have screens, I use TAB (only 1 key stroke) and accept whatever the editor of the day displays it at. I still try to limit lines to 80 chars.
|
|
|
|
|
3 Empty spaces here
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
Rating helpful answers is nice, but saying thanks can be even nicer.
|
|
|
|
|
I prefer the length of two dried elephant ear hairs plucked by 24 year virgin males, and must be the 2nd child.
|
|
|
|
|
One space is too short. Other than that, whatever the environment provides for a tab is fine.
The point is to quickly see nesting, not to conform to the whims of some mad god.
"There are three kinds of lies: lies, damned lies and statistics."
- Benjamin Disraeli
|
|
|
|
|
Three column tabs? Now that really is odd.
Ravings en masse^ |
---|
"The difference between genius and stupidity is that genius has its limits." - Albert Einstein | "If you are searching for perfection in others, then you seek disappointment. If you are seek perfection in yourself, then you will find failure." - Balboos HaGadol Mar 2010 |
|
|
|
|
|
Jeremy Falcon wrote: So, I'm curious to know, what do y'all use still and why?
Whether spaces or tabs, 2, 3, 4, or 5 (I loved 5 when I was doing C++ work years ago), I don't particularly care, as long as:
- The IDE creates appropriate indentation when I hit the tab key
- The IDE is smart enough to un-indent the entire group of spaces when I hit the delete key anywhere in the indented region (this is extremely rare, which is why I prefer tabs over spaces)
- The IDE supports block indent \ un-indent
- The IDE supports a "format" which will format the entire code block/file to however I've set up my IDE. 95% of the time I love how pressing '}' will reformat the C# / Javascript code.
But what I really grouse about is vertical spacing. I am anal about that. Here are the rules not all dealing with vertical spacing:
- C# using (and other language equivalents) should be in alphabetic order, unless, like in some other languages, they are imports that have dependencies on prior imports
- .NET framework using's come first.
- Third party using's are alphabetically grouped next, with a blank line between them and the .NET using's above.
- Internal library using's next, grouped and separated as #2
- Application specific using's next, same
- One class per file
- Methods separated by a single blank line
- Public events first, one per line, the group "guarded" by a blank line.
- Public properties next, one per line, the group "guarded" by a blank line.
- Protected/private properties next, one per line, the group "guarded" by a blank line.
- Internal fields next, one per line, the group "guarded" by a blank line.
- Public constructors next, each constructor method separated by a single blank line.
- Protected/private constructors next, each constructor method separated by a single blank line.
- Public methods next, each constructor method separated by a single blank line.
- Protected/private methods next, each constructor method separated by a single blank line.
OK, I must be really bored at work to have just written all that down.
Marc
Latest Article - Create a Dockerized Python Fiddle Web App
Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventually drown you. - DangerBunny
Artificial intelligence is the only remedy for natural stupidity. - CDP1802
|
|
|
|
|
4
Did you ever see history portrayed as an old man with a wise brow and pulseless heart, weighing all things in the balance of reason?
Is not rather the genius of history like an eternal, imploring maiden, full of fire, with a burning heart and flaming soul, humanly warm and humanly beautiful?
--Zachris Topelius
Training a telescope on one’s own belly button will only reveal lint. You like that? You go right on staring at it. I prefer looking at galaxies.
-- Sarah Hoyt
|
|
|
|
|
4, with Visual Studio set to insert spaces.
VS has been broken since VC6 when it comes to block indent/undent when you use a mix of tabs and spaces at the beginning of a line. If VS is set to insert tabs, on a block operation they convert leading spaces to tabs, and screw up the alignment .
Software Zen: delete this;
|
|
|
|
|
It'll be ok Gary... just think about fluffy kittens.
Jeremy Falcon
|
|
|
|
|
My fluffy kitten (ok, she's 15 years old and surly) could do a better job than MS on this.
Software Zen: delete this;
|
|
|
|
|
But then again...
Here's how I indent DCL (Digital Command Language) on OpenVMS.
The VT100 emulator I use doesn't allow control over the TAB stops, so it's always eight columns and that's far too many.
So I use one TAB after the leading dollar sign ($) to make a nice margin so my comments and labels stand out.
Then it's a one-SPACE indent for THEN, ELSE, and ENDIF and a two-SPACE indent for statements inside those.
A snippet from my DCL implementation of a Turing Machine:
$! Run the Machine
$
$ offset = 0
$loop2:
$ input = f$extract(offset,1,p2)
$ if f$type(TM_'state'_'input') .eqs. "" then goto eoloop2
$
$ output = f$element(2,",",TM_'state'_'input')
$ move = f$element(3,",",TM_'state'_'input')
$ state = f$element(4,",",TM_'state'_'input')
$
$ p2['offset',1] := 'output'
$
$ if move .eqs. "-"
$ then
$ if offset .eq. 0
$ then p2 = "_" + p2
$ else offset = offset - 1
$ endif
$ else
$ offset = offset + 1
$ if offset .eq. f$length(p2) then p2 = p2 + "_"
$ endif
$
$ goto loop2
$eoloop2:
$
$ write sys$output p2
$
$ goto end
|
|
|
|
|
I also use 3 columns, and have done forever (well, since I first programmed in Ada in the 90s!) The company I work for still has a standard of 3 columns for indentation...
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Heard a nice one today: Explicitly Configured (hard-coded)
|
|
|
|
|
Almost as good as 'stringly typed' (when string is used as universal datatype for everything).
I need a perfect, to the point answer as I am not aware of this.
Please don't reply explaining what method overloading is
|
|
|
|
|
Clearly, we've both seen the same kinda databases before.
Jeremy Falcon
|
|
|
|
|
Not only databases. It gets really sick when something like this appears in the code:
(somecontrol.text = float.Parse(x) * float.Parse(y)).ToString();
x and y are strings, of course. Th use of float.parse() can fail any time when the strings can't be parsed, no checks or a try/catch block. The text property of the control of course also serves as stringly typed storage for the calclated value. And that's only the beginning of the horrors in that ASP.Net web form.
I need a perfect, to the point answer as I am not aware of this.
Please don't reply explaining what method overloading is
|
|
|
|
|
About the only logical explanation I can come up with is if they're using like a web service that only has strings for data. Outside of that...
Jeremy Falcon
|
|
|
|
|
Some people never really get what types are all about. This particular guy would have been insulted after such unwarranted criticism. He was one of those who could recite every rule and convention there may be and believes that everything is well as long as these rules are observed. Who needs to think when some guru already has done that and packaged his wisdom in rules and conventions?
I need a perfect, to the point answer as I am not aware of this.
Please don't reply explaining what method overloading is
|
|
|
|
|
Common sense ain't so common man.
Jeremy Falcon
|
|
|
|