In Valid Logic

Endlessly expanding technology

Are you obsessive about code formatting?

Sitting here working on some code for my little project (after getting my little development board working last night) and was cleaning up some sample code I had downloaded when I realized exactly how obsessive I am about code formatting.  Here are a few things just to give you an idea:

  • Tabs, not spaces for indenting
  • Brackets around code blocks begin on new lines, not on the same line
  • Space around assignment and comparison (ie, i = 0 instead of i=0, and a == b instead of a==b)
  • No space before statements (ie, if(i) instead of if (i))
  • Spaces before comments (ie, // comment instead of //comment)
  • Clean consice function names (I love camel case, but hate the "m_", "s_" style stuff... boo!)
  • Short, precise functions (KISS = Keep It Short & Simple, break down your functions, short and to the point, no monolothic/does-everything functions)
  • Grammar and spelling - ok, it is code, so it doesn't hurt anyone, but I don't like seeing grammatical or spelling errors in code
  • Can't think of anything else right now.  I always configure these kind of rules into ReSharper and always clean up any sample code I download and plan on making using of.  For myself, it goes a long way to increase readability.

    What are you obsessive about in your code?

Sunday, December 10, 2006

blog comments powered by Disqus