Program Code: Working Properly or Just Pretty?

Question:

“Is it better to write a program that works, or write code that just looks pretty?”

To most people, this is a stupid question. Obviously, programs need to work properly. They are there to do a job. So, who cares what code looks like as long as it works?

But, as is often the case with stupid questions with obvious answers, the question may not be entirely stupid, nor the answer as obvious as it seems.

To illustrate, I will restate the original question, thus:

“Is it better to write code that is easy to maintain, than to get it right first time?”

Personally, I think that maintainability far outweighs correct functionality in the majority of cases. Why? Simply because long-term low-cost correct functionality is so much more likely to be achieved when code is maintainable. Code that is impossible to maintain will need to be entirely re-written if it is defective or if real-world needs change. This is always costly, and can be very risky.

The only possible exception is code that is intentionally a short-term hack that needs to be implemented immediately. Even then, however, I have my reservations: these kinds of hacks all too often become a permanent fix.

So, on the grounds that elegant code is generally maintainable code, I would prefer pretty code over working code any day of the week.

That reminds me: I must go and tidy my desk.

Advertisements

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 )

Google+ photo

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

Connecting to %s

%d bloggers like this: