This blog has been moved to Redwerb.com.

Friday, June 01, 2007

Beautiful Code

I was reading a post on Jeff Atwood's blog (Coding Horror) titled The Best Code is No Code At All the other day and in the comments many people were discussing the "beauty" or aesthetics of code. I've heard that phrase used before, in fact, I've used it myself, but what does it mean? What makes code beautiful?

The answer that I've come up with over the years is that "beauty" is simply the combination of all the aspects that makes code good, approaching perfection. When code is simple, concise, easy to read, correct, flexible, and perhaps some other qualities that makes code good that we know when we see it, but can't quite define, it is considered beautiful.

Unfortunately this is very difficult to achieve in real-world applications. Often times features must be complex due to real-world situations (data entry errors, government regulations, odd business practices, external APIs that don't quite work the way you want, etc). However, every once in awhile, you write that perfect bit of code and you just sit and stare in awe at it. Perhaps you post it on your company bulletin board, or hide it away so nobody can mess with it. Perhaps you force everybody to "code review" your code, or maybe you just move on to the next feature realizing that few people have the training, experience, or skill to appreciate it the way you do.

No comments: