Premature Optimization

“Premature Optimization is root cause of all evil” - Sir Tony Hoare (famous by Knuth).

The most important function of computer code is to communicate the programmer’s intent to a human reader. Any coding practice that makes the code harder to understand in the name of performance can be premature optimization.

Following can be examples of early optimizations that can be premature:

The performance problems should be solved top-down rather than bottom-up. The Service Level Agreement (SLA) for each web service has to be fixed and all efforts should be made in order to achieve that SLA. For example, the SLA for a web service can be 100 ms and when we failed to fulfill that we have to think of further optimizations.

The key characteristics of a good software system are - reliability, efficiency, security & maintainability. Trading off these characteristics for the sake of insignificant performance benefits leads to disaster.

Note:

The premature optimization can be easily misinterpreted. Below are few pointers to be aware of :