Whitesmiths Style Indenting

This page is dedicated to the Whitesmiths indentation style. And to why it is far superior to anything else :)

Visual Blocking

The reason Whitesmiths Style (WS) indenting is so much superior to anything else is because of Visual Blocking.  Visual Blocking is a term I just made up, but the name embodies the idea.  When looking at a collection of objects that are randomly laid out the mind tends to block them together into familiar shapes.  A good example is seeing shapes in clouds.  This idea is very similar to, if not the same as, the Gestalt Theory.

The Gestalt theory is mostly referenced in the realm of learning.  Software engineers spend most of their time staring at code to learn what it does.  Even if they wrote it.  So laying out code so that it is visually easy to perceive blocks of related code is extremely important.  Take for example a simple one line "if" statement:
One line if
As you can see the controlling statement, outlined in yellow, owns the indented line of code, outlined in green.  This is visually easy to see even without the shading.

The WS indent takes this same idea and extends it without changing the simple blocks created in the previous example.  The following code is indented using WS:

if (foo > 0) { foo --; bar += foo; }

In WS the braces are part of the block and therefore are indented with the block of code.  Another popular style of indenting is the BDS style as shown here:

if (foo > 0) { foo --; bar += foo; }

In this case the braces are pulled out to the level of the controlling statement.  This visually breaks up the indented block of code.  It may be easier to see in a more graphical example.  The two images below have the same code as above but with the additional shading of the code areas.

Whitesmiths Style
BDS Style

The clean line between the controlling statement and the block that it owns is broken by the braces in the BSD style.  The blocking of the code should not change just because the "if" statement has more then one line in it.  In WS the look of the code is similar to the above example with only one line.  This consistency is very important in maintaining readability in code. 

There are other styles of indenting where the braces are placed in all kinds of unnatural places.  These I will not even touch as they are beneath me and a disgrace to good and proper coding.  I will say this however,  "Braces must line up."  Readability is flushed right down the toilet when the opening and closing braces do no line up.  The eye is forced to scan all over Tibet (yes the place near china) to find the matching brace.  This is just wrong and I will not spend more time on it.

I hope by now you understand that WS is by far superior to anything else.  If you don't that is OK.  I understand that the world has indoctrinated you with false teachings.  Here is a site for you to go and waste more of your time on.

For those of us who are true WS followers we must band together and not give in to the foul coding styles of others.  Also as a further justification of WS it is interesting to do the shading on python code.

Python Style

Look familiar?  Hmmm?
Now get back to work!