There is a number of common points between coding and writing

Spelling

The most basic mistake... Oops I wrote retrun instead of return... hopefully modern text editors check it on the fly.

Syntax

Correct sentences are made of word in a correct order. Here again, on the fly checking helps a lot.

Presentation

Is your code visibly clear... Enough space between parts, but not too much. Is you code clearly indented.

Style

Style is even more subjective. When coding, usually stay concise, but there are a lot of parameters here.

You can :

  • choose if statements or ?: alternating operator
  • define fluent interfaces to do things on several lines
  • use linq to express your intent more clearly,
  • use var implicit type or not
  • use anonymous types or not
  • use lambdas or functions

The important thing is that your style should fit some purpose, the style should emphasis important parts of your primary intent.

Structure

A book is divided in parts, chapters and paragraphs. The code is divided in files namespaces and classes. The structure of the code should help the reader go straight to what is the most important to him and understand how things are related.

 

Next time, we'll talk about substance. Tell me if you see more analogies !