Good Code vs Bad Code

Posted: July 13, 2009 in Programming
Tags: , ,

I’m going to compare coding with film making, though they differ in one way. Coding is a long and continous process compared to movie making which is a one time effort. But still, they can be compared, since adding to the existing code is analogous to a film remake. So here we go,

Good code has the characteristics of a good movie. It has a clear message/purpose. The entire code revolves around that message. The code can be broken into characters/classes. Each character is important for getting the message across to the audience and they have a well defined role to play. There are no unnecessary characters(code).  And the communication between these characters(classes) is meaningful and is something that has some context to the message the movie delivers.  Summing up, a good code is like a good movie, the story can be remembered and passed on to future generations easily.

Bad code has the characteristics of a “mega” serial. There isn’t any clear message or the message itself isn’t apparent at the end of the work. They start with something in mind and end up with something totally different.  Here again the code can be broken down to characters/classes. New characters appear and disappear as the story goes on. But the existence of these characters, doesn’t add any meaning to the  story. There are  multiple sub plots and characters involved are different.  The story can’t be remembered and passed on, because of the haphazard way the characters communicate. In short, it’s a mess.

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s