Monday, November 9, 2015

Indentation and style: A mild rant.

People, people, people.  When you're writing your code, you don't indent it and use brackets consistently  in order to get brownie points.  You do it to avoid long, long hours spent fruitlessly searching your code for something that should have been obvious.  You don't do it so that your code looks pretty, you do it so that your code is clear.

This was brought on by a snippet of code I found on pastebin that I rather wish I hadn't even seen.  The indentation was all over the map and brackets were placed willy-nilly, and the guy wanted help.  I wish he'd seen fit to help himself first.  It's not like formatting code is even a difficult task.  Any decent IDE will do it for you in no time flat.  This can expose all sorts of issues, like that string of closing brackets down at the end that probably should have been interrupted by code that was, instead, nested at the deepest level.

Back in the day, we'd run our code through a 'pretty printer' program before checking it in to source control.  This didn't offer the same amenities we have now, but at least when someone checked out a module they didn't find themselves recoiling in horror until after they'd reviewed the logic.

When you format your code consistently, you're not doing me a favor.  You're doing yourself a favor.  Future you will thank you for that, even as he or she is still kinda cheesed off that you chose to eat so many Doritos and didn't hit the gym enough.