Friday 23 November 2012

Formatting code for readability

On the theme of making things better and caring about the parts that can't be seen, here is an example of how I like to format large groups of .Net methods (so that they are easier to read and to look at)

Here is what a .Net Class usually looks like (if you allow VisualStudio to format it)

This is really hard to read, so let's improve it by aligning by method name:

Then by first parameter:

And finally by last Parentheses :

The final version can still be improved a bit (for example with some method names being alphabetically sorted) , but look at how it compares with the original version :)