Posts Tagged ‘c#’

Programming style

February 9, 2014

See here: http://cjacobi.com/misc/csharp_style.pdf

I have spent the last years writing substantial amounts of C# code for White Hawk Software.  I found it rather important that my code can be maintained; more precisely: that I myself will be able to understand my own code when I need to read it again.

It would be nice if I could pick up some other style guide.  However, I found that most code is written for people with huge memory capacities.  I had to write in a style which makes “code in the large” readable; I don’t care about small examples with lots of text explaining what it does.  If my memory needs lots of help and style-guided support to understand my programs, I guess other people might consider my code too easy to read.  That is however not something I have experienced.

These features have been paramount for this style guide

  • The C# language construct, a “using alias directive” is prominently used.  In fact, this feature was the main reason wich caused me to choose C# for programming-in-the-large.
  • From Xerox Parc I took the idea that “values” are key, and the difference between variables, constants and macros is irrelevant.  The one thing different, are Types.
  • From C++ I picked the habit of using small capitalization for methods.
  • Monitor size matters.
  • Programmers read source code.  Try reading this, putting stress on different parts of the sentence…

I found writing a style guide difficult. A style guide isn’t a beginner text in programming, nor should it be a straight jacket for experts. Writing a style guide isn’t a goal, it is a means to programming.   Writing a book-sized style-guide may be very interesting, but it doesn’t leave time for actual programming.

If you would like to discuss this style, my bulletin board has reserved some space.

Chris

Advertisement