CodeBetter.Com
CodeBetter.Com
RSS 2.0 via Feedburner
           Do you Twitter? Follow us @CodeBetter

Paul Laudeman

Helping You to Make "Smart Clients" Smarter!

More on using Enums and designing for performance

Fellow blogger and long time friend Darrell Norton recommends that you always use Enums instead of hard coded constant values. I'd even argue that even with a marginal performance impact, code should be designed for long term maintenance rather than squeezing every last drop of performance out of your application.

It's also worth noting that one of the main tenents of Test Driven Design advocates that you develop first and then optimize later. A quote from this article citing Michael Jackson states:

[The First Rule of Program Optimization]
Don't do it.
[The Second Rule of Program Optimization---For experts only]
Don't do it yet.

In addition, Steve McConnell cites a study on program optimization in Code Complete that states:

“If the development time saved by implementing the simplest program is devoted to optimizing the running program, the result will always be a faster running program than one in which optimization efforts have been exerted indiscriminately as the program was developed.”

Does this mean that you should develop your application without keeping performance in mind? Of course not, but with anything, there are trade-offs involved. I'd argue in favor of writing easy to read and maintainable code almost every time and then optimize later as necessary.



Check out Devlicio.us!

Our Sponsors

Free Tech Publications