Thursday, 28 October 2010

Code Sense n’ Sensibility

“A programmer who writes clean code is an artist who can take a blank screen through a series of transformations until it is an elegantly coded system”.

Probably the topic gives an impression that I am one of the geeks who eat, drink and sleep coding OR at the least it gives away the notion of me being passionate about it. Have you heard of phrase “Jack of all trades and master of few”? Apparently, not, because I made it up just now. Don’t dare use it it’s my copyright!! Few years in IT and I have learnt that if I am not the best around at least I strive to deliver best in the little I contribute.

I was given a book, ‘Clean code’ by a well known Geek from work. I call him geek because I am sure he can be described very well from the first few lines of the above paragraph. Well, I wasn’t sure if I would like the book but then I wondered what harm can it do to me? Probably teach me couple of new tips, phew! I love reading books, BUT strictly Fiction. So, here I was reading this book and almost sure that I might get bored with the writing.

I have read a lot of books ... few may qualify as technical books which I picked up while I was on my window shopping spree. Over the time I have started believing that every book’s ghost, called ‘The <book_name> ghost’ who endeavors to tell us the moral of the story, things to learn etc..etc. I am usually **scared** of techie books, because, somehow I fear that it is screeching at me in its monotonous tone ‘Com’n read it you ___! Don’t you need to learn about this better?’

Okay, before I get diverted again … I started to read this book and surprisingly the writing or the tone was calm and friendly. My <book_name> ghost was talking to me as if it had been watching people commit mistakes; indulge in fake promises that they know they can’t keep. I was happy to be attuned to it. The flow was nice and serene, I was happy to meet a nice ghost after so long. It held my hand, took me though the growing chapters, scolded where it had to, explained me where I needed improvement and where I need to let go of oldies … as I was rejoicing the momentum ...... everything faded… and … and … engulfed in darkness there I was, wondering my whereabouts when my alarm went off mad, it was then I realized …….. I had slept off! It’s the sad part of reading a ‘techie’ book at night. I still haven’t finished the book, though I firmly hope to complete it one (some) day and make my friendly ghost happy!

Here’s bird’s eye view (who even came up this phrase?) or looking into the valley view (@ copyrighted by ME!) of what the friendly book explained me. It’s not all because if I sit to write EVERYTHING, I’ll become Martin junior (who’s he? Ofcourse, the writer!)

• Writing meaningful Names - The <book_name> ghost asked me "We take lot of pain in deciding name of babies or even puppies why can’t we decide on meaningful names to methods, attributes?"
• Do one thing – In other words, stop acting smart and finish the first thing in hand.
• Comment – The <book_name> ghost suggested me … “Behave! You’ve good manners, then, why pass bad commented code to you peers?”
• Don’t forget to arrange your work in order – Looks Matter, doesn’t it?

The list goes on...

Again, I couldn’t help but share few of my favorite lines/phrases from the book.

• Writing clean code is what you must do in order to call yourself a professional.
• There is no reasonable excuse for doing anything less than your best.

Sources: Book - Clean Code, My mind