[Courses] C Programming For Absolute Beginners, A note about indentation

Kai MacTane kmactane at gothpunk.com
Tue Mar 13 03:03:45 UTC 2012


On 3/11/2012 5:39 PM, Jacinta Richardson wrote:
> G'day folk,
>
> I'm just going to hijack Carla's course for a moment to talk to you about the
> single best programming practice you can have.  Oh there are lots of good
> programming practices that you should follow, but if there had to be a single
> most important one, it'd have to be indentation.
>
> Indentation is a wonderful thing.

I hope nobody minds if I chime in here.

I've been trying to follow along with the course. Unfortunately, life 
events have made it so I'm too busy to really do the exercises any more, 
and I already speak a bunch of other languages, so I haven't got a lot 
of time to learn C.

But that fact, that I speak various other programming languages, just 
segues into my point:

I am a professional programmer. I've been making my living, paying my 
rent and bills, by writing program code (in languages like Perl, PHP, 
JavaScript and Ruby) for over 12 years now. Just so you know where I'm 
coming from when I say:

Jacinta, thank you for pointing this out. I completely agree. Indenting 
code properly is the single best habit a programmer can get into -- and 
*not* indenting it properly can be the source of all sorts of bugs, and 
can make it much harder to _find_ those bugs! It's simple to do, and so 
critical to writing good code.

In fact, I recently wrote a blog entry that touches - a bit obliquely, 
but still very importantly - on how critical indentation is.

http://kagan.mactane.org/blog/2012/01/30/beware-of-optional-curly-braces-they-will-bite-you/

The importance of proper indentation forms more of a background to that 
post than a foreground, but it's still there.

I still consider indenting properly *as I'm writing* to be the single 
best, most critical habit I've formed as a programmer - and when I see 
code that isn't indented properly, it makes me worry about the 
programmer who wrote it. The habit of indenting should be so ingrained 
that, after writing an "if", "while" or "for" statement, pressing "Tab" 
after "Enter" should be just as automatic as hitting "Enter" in the 
first place was.

Again, thank you Jacinta, for pointing out the importance of indentation.

                                                 --Kai MacTane
----------------------------------------------------------------------
"Deadly angels for reality and passion..."
                                                 --Shriekback,
                                                  "Gunning for the
                                                   Buddha"


More information about the Courses mailing list