Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I noticed that I have a peculiar habit of finishing every line with a space. It carries over from my prose writing where a paragraph can have multiple sentences and so it is very common to follow a period with a space, and I end up doing that automatically for every period (or when it comes to programming- semicolon). It started out as something automatic, but I'm so used to this by now that if I miss the space it actually bothers me and I end up returning to that line to input it.

What are some of your programming idiosyncrasies?

EDIT: When I wrote this I was as student. After going through code reviews at work I no longer do this.

share|improve this question

closed as not constructive by Mark Trapp Jul 22 '11 at 10:15

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.If this question can be reworded to fit the rules in the help center, please edit the question.

Due to markdown, I insert two spaces everywhere to prevent two statements on one line. –  Tom Wijsman Sep 11 '10 at 9:25
That would drive me nuts. End of line whitespace is a sin! –  Daenyth Sep 16 '10 at 21:00
Empty-line whitespace is worse... Highlighting an apparently empty line to see it completely filled with spaces gives me the creeps - if I scroll, what will I find at the end? –  Shog9 Sep 27 '10 at 3:27
@mojuba: Many IDEs also have an option to remove trailing whitespace. Like @Daenyth, I abhor extra spaces, so I always make sure I have this turned on. –  TMN Nov 12 '10 at 13:16

21 Answers 21

up vote 38 down vote accepted
  • Removing unnecessary white space - usually extra blank lines people leave in code
  • Removing commented out code - that's what source control is for (though I am a hypocrite on this sometimes)
  • "Tidying" if statements - I prefer if (expression) over if( expression ) etc.

The problem with all this is that my actual edit can get lost in all the "noise". I try to keep this to a minimum.

share|improve this answer
I also get annoyed by commented out code being left in. –  jschoen Sep 11 '10 at 14:03
It can be hard sometimes to find old removed code, especially if the file is heavily worked on. I comment out code when something non-vital but heavily revised is broken, just so I can scroll, remove the `\`, and fix it. This way I don't have to spend half an hour searching for that right revision. –  TheLQ Sep 11 '10 at 17:03
I hope you don't remove ALL blank lines. We have a couple of programmers who NEVER leave ANY blank lines. It's a bit like reading a book without paragraphs. –  MetalMikester Nov 12 '10 at 13:11
@MetalMikester - oh no, I do leave some ;) It's when there are two or more blank lines together, or blank lines between open/close brackets and the code etc. –  ChrisF Nov 12 '10 at 13:17
@sp0rus, I prefer "if<blank>(expression)" over "if(expression)" to make a distinction between: (1) executing a procedure or function. (2) evaluating a grouped, conditional statement –  umlcat Mar 15 '11 at 22:46

Atleast two Ctrl+S's to make sure it's saved.

share|improve this answer
Or... two :wq ? –  Xepoch Sep 27 '10 at 5:08
@Xepoch - I think you mean two :w... –  Jason Baker Nov 12 '10 at 17:18
@Jon Purdy: why don't you program C-x C-s to save twice (and show a message with a confirmation number)? –  Codism Mar 15 '11 at 17:52

When other people give me code, if it's just short snippets, I have to go through and do a little reformatting to fit my personal style preferences before I'm able to look at what they're doing.

It also irks me when I'm helping people with something and their style is almost nonexistent.

share|improve this answer
+1 I often do this with code example that I copy from the web. Totally unnecessary for some people, but it helps me understand that code a bit better. –  Jason Evans Sep 26 '10 at 17:07
@Jason: that's exactly why I do it. Just having it be exactly in my style allows me to look at it as if it were my own code, and understand it that much better. –  sp0rus Sep 27 '10 at 22:00
There is nothing worse getting code from other people that you are asked to look into, and then it is not even indented correctly. –  Bjarke Freund-Hansen Nov 12 '10 at 12:24
That's horrible. The problem with that is that when you check it into source control the whole things shows up as having changed when you diff it when you've made no substantive alteration which makes tracing genuine changes a nightmare. We actually have a rule against doing this in our office for this reason. Your preference for your own personal style over someone elses is not a good reason to do this. –  Jon Hopkins Nov 12 '10 at 14:04

I can't stand 'backwards' comparisons to constants:




I realize both are fine but the latter just feels right and the former makes me angry.

I also can't stand overly obvious commenting as well as worthless variable names.

//Set the flag
myFlag = true;
share|improve this answer
Those two statements are not equivalent. Most static analysis tools will tell you colorName.isEqual("blue"); should be switched to "blue".isEqual(colorName); –  Ray Mar 15 '11 at 11:17
Still a lot you must learn, young padawan: tinyurl.com/3y66hd2 –  back2dos Mar 15 '11 at 11:23
@Jeff Swensen: Your sense of humour outrivals your ability to perceive similarities :P Firstly, this was a joke, and secondly in both cases putting the constant first has benefits (for completely different reasons) although it does arguably feel a little odd. –  back2dos Mar 15 '11 at 14:01

I am quite OCD about needing to remove any white spaces at the ends of lines. The worst is if a blank line has been left made up of spaces to match the current indentation. I always turn on the 'show white spaces' option on my IDE so that I can see them easily. I know that they have no impact on the code but I just need to get rid of them all.

share|improve this answer
My editor automatically strips trailing white space from all lines in the file. A very useful function. –  Ian Nov 12 '10 at 11:58
@Scott - most IDE's will automatically indent to match your current line's indentation. –  Piers Myers Mar 15 '11 at 15:00

My biggest idiosyncrasy is probably descriptive (and perhaps overly so to some) variable names. I would much rather see/read customerName in lieu of c_name, etc.

share|improve this answer
Amen to that brother! –  kirk.burleson Nov 12 '10 at 18:27

I may sound like a house wife, but I want documentation and code to be as clean as possible.

share|improve this answer
No, I won't marry you... –  Tom Wijsman Sep 26 '10 at 11:08
Codewife? –  mojuba Nov 12 '10 at 12:54

A friend of mine has a habit of putting Here be dragons! in a method's comments block if the code is a bit of a hack.

It seems he is not alone.

Have a look at a google code search for be dragons.

Just found this in thrunderbird.

To pop it up: Tools -> Options -> Advanced tab -> General tab -> Config Editor

Dragons Found!


"Here be dragons" is a phrase used to denote dangerous or unexplored territories, in imitation of the medieval practice of putting sea serpents and other mythological creatures in blank areas of maps.

The only known historical use of this phrase is in the Latin form "HC SVNT DRACONES" on the Lenox Globe (ca. 1503-07). Earlier maps contain a variety of references to mythical and real creatures, but the Lenox Globe is the only known surviving map to bear this phrase.

share|improve this answer
"A friend of yours?" Right, we believe you! –  Paddyslacker Sep 13 '10 at 7:29
@Cristian I added the origin of the phrase to my answer. –  Gordon Sep 26 '10 at 8:33

Everywhere I see conditional or looping constructs not enclosed in curly braces (or the VB or Delphi equivalents), I gotta put them in, as such:

if (someCondition) continue;


if (someCondition)

Sure, I've burned approximately 11 more characters, but I feel I've saved some time/grief in the future when an enhancement calls for something to happen before the continue;.

share|improve this answer
Have faith that your brethren know the syntax. :) –  kirk.burleson Nov 12 '10 at 18:32
I love these short one-liners. –  Htbaa Mar 15 '11 at 10:17

I have a few I guess...

Similar to TomWij's, I write pseudocode out for non-trivial steps out as comments. I keep it short, clean, simple, and generally numbered (starting from 1 to x). It also tends to serve as documentation. Then I write the actual code to follow under each step. The more non-trivial it is, the more likely I'll keep it to help myself and future developers know what it's supposed to do.

I also tend to use foo and bar as dummy naming variables for quick programming proof of concepts. If both are already used within the scope, I get creative and go with foofoo and barbar, or foo1 and bar2 etc. The bad part is I sometimes forget to rename properly them and it gets checked into version control.

share|improve this answer

In SQL I write columns out like:

SELECT    Column1
     ,    Column2
     ,    Column3
     ,    Column4

It's carried over into how I call/define methods with lots of parameters:

function( param1
        , param2
        , param3
        , ... )
share|improve this answer
Eww... multiline parameter blocks. Parameters are probably the exception to the 120 character rule since they are rarely looked at –  TheLQ Sep 11 '10 at 17:05
SQL select lists tend to be long - I find multiline column lists extremely helpful. In general, set-based SQL tends to be dense - use more lines to break it up! –  Michael Petrotta Sep 11 '10 at 21:24
That's a weird place for commas. –  Anna Lear Sep 16 '10 at 12:36
@Anna: It's actually pretty useful to do multiline lists like that, especially if the closing paren is on its own line. That way, when you're modifying the list, you don't have to worry about inserting or deleting commas at the end of other lines that you aren't actually modifying. –  Mason Wheeler Sep 16 '10 at 19:07
@Anna: When I first encountered it I thought that too. But after trying it, I find it makes my SQL a lot more readable. I'm finding the same with functions too. –  Matt Ellen Sep 17 '10 at 7:27

I can't force myselt to start writing in a new block if it is not surrounded with braces (or end keyword is missing if I'm coding in Ruby). For example:

def foo(bar)
  # I'm feeling "insecure" here


def foo(bar)
  # Now everything is OK!
share|improve this answer
It's funny, this never bothered me but when Eclipse added this feature (enter a '{' and it opens a new block with the '}' already in place) I really liked it! –  TMN Nov 12 '10 at 13:25

I tend to put some funny commented lines into my code as an easter egg like the one you can find if you search through the wordpress source code. In one file you find:

// Silence is golden.
share|improve this answer
Read the Mojolicious source code (github.com/kraih/mojo). It's full with Futurama and The Simpsons quotes. –  Htbaa Mar 15 '11 at 13:09

By convention, most Delphi code is indented 2 spaces per level. I tend to indent mine by 3 spaces because I find that easier to line up with my eyes.

share|improve this answer

I have a few that rank right up there with others.

  • I always make sure that I have comments on code blocks, and I'm not afraid to write inline comments and get frustrated when complicated pieces of maintenance code doesn't have comments
  • Commented out code needs to leave, quickly, and not leave a forwarding address. (That's what source control is for)
  • I hate inconsistent spacing between regions and blocks of code, there must be a single line space so that if collapsed within Visual Studio the little Region boxes do not run into each other.
  • I cannot stand variables named i, x, y, z, foo, bar, etc unless used for a counter, any other use gets changed.
share|improve this answer

I REALLY like parentheses.

{ :( } ( :) )

share|improve this answer

Despite having a monitor that has a 1680x1050 resolution (yay!) and a coding standard that states we must have line widths of less than 100 characters, I still code to 78 characters where I can.

Hey, 78 is less than 100, so technically it's allowed...

share|improve this answer
@kirk: "It's slightly under 80." It's a leftover from when I used to be an avid USENet user. Many people were still on 80-character fixed width consoles, so the idea was that at 78 characters, you could be quoted at least once (marked with "> ") without having to be reformatted. Narrower columns are also easier to read -- that's why newspapers do it -- and I think the ideal is in the high 60's, although while that's fine with prose, it becomes impractical in program code. –  Kaz Dragon Nov 12 '10 at 20:49

When writing long strings or cases for switch() statements and in various languages:

stream <<"Text is delicious. "<< varA <<" Indeed, oh so delicious. " << varB
           <<"Text is delicious. "<< varC <<" Indeed, oh so delicious. " << varD
           <<"Text is delicious. "<< varE <<" Indeed, oh so delicious. " << varF;

string = "Text is delicious. "+ varA +" Indeed, oh so delicious. "+ varB
           +"Text is delicious. "+ varC +" Indeed, oh so delicious. " + varD
           +"Text is delicious. "+ varE +" Indeed, oh so delicious. " + varF;

string = "Text is delicious. ". varA ." Indeed, oh so delicious. ". varB
           ."Text is delicious. ". varC ." Indeed, oh so delicious. " . varD
           ."Text is delicious. ". varE ." Indeed, oh so delicious. " . varF;

The same style applies to any other long 'one-liners'. I also especially have a habit of condensing some function calls when they are very short usually.

/* Formula Description */
int soFunctional(int a, int b){ int c=a; a+=b*b/2; b=c*b; return a+b; }

Whether nested or not

if or loop(condition)

Unless it is one statement, then usually

if(condition) statement();
    var= statement + many * operations / with +(long % lines());

Finally I often will create classes like:

class _object_

_object_ OBJECT;
typedef _object_ object; //sometimes

Where OBJECT is a special case of _object_ sometimes I'll use main, root or default instead of the object's name and sometimes I'll use all of them.

When I skip two, three or four lines, I feel like I'm setting a narrative. Very compulsive.

Naming scheme is somewhat crazy. Temporary variables of sufficient "obviousness" will often be named such things as "taco" "dumb" "monkey" during alpha phase. Most of my code is made so that I can easily do a search and replace on the whole file without worries, for when I'm actually sharing the code later!

At that point the naming takes on a life of it's own. One thing I notice is that usually I will say VariableName whereas I usually see variableName.

If VariableName looks wrong I'll go to Overly_Descriptive_Variable_Name. Usually all my variables except for ones like x,y,z,i and sometimes num will be fairly long. About,... 7-12 characters.

share|improve this answer

I find open curly on a new line irritating. it should be in the same line as the conditional statement.

Also, I find green text over black background in vim too depressing. Black over grey is better.

share|improve this answer
I hate it when the opening brace and closing brace are not directly above/below each other. –  JD Isaacks Dec 5 '11 at 15:00

It bothers me to try to read/work with long functions. I detest scrolling so when someone writes a function that is long (usually 75 lines or more where it's longer than my screen size) I simple can't leave it along without doing refactor -> extract method. If the function has a very large loop or conditional in it, there is no way I can fight off the urge to break it up.

share|improve this answer

Whenever I see this:

if (var == 2)

I cannot stop myself from re-writing it as

if (2 == var)

When I was learning to program (with Ada) I made the mistake of mixing up an assignment operator with an equality test and ever since my programming style would make Yoda happy.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.