As Software Engineers, we need to be concerned about performance when we are building an application. Performance is a very legitimate concern for any non-trivial application, and it requires much thought and care. No matter how wonderful and functional the application is, if it is not performant it will turn users off very quickly. It is natural to want to optimize the code at all times. After all, we have been trained to think in terms of zeros and ones. br>
Loosely speaking, highly optimized applications are often hard to debug, maintain, and require more time to develop. This is because highly optimized code requires specialized knowledge or clever algorithms that might not be intuitive to everyone. This specialized algorithm often it is not susceptible to change and it is often very cryptic to understand. With modern software, changes in business requirements are inevitable. br>
Often people will have some preconceived notion as to how a certain type of code will behave in a cookie cutter way under a given condition. Software has been more complicated than ever. It is hard to predict the behavior of the software without actually testing it. On top of that, modern compiler’s optimization has been more intelligent than before. Writing clever code sometimes yields no benefit because the compiler will often optimize it, and it could possibly confuse the compiler in certain cases. br>
The point I am trying to make is that premature optimization often leads to cryptic code and more time to develop. The time might be better used to provide more functionality in software than trying to make some operation perform slightly faster. Of course, we all want our application to run as fast as possible, but without actually writing some code to test the performance under a specific load, it is hard to guess how the software will perform. People often attempt to optimize the code as they are writing it for the first time, which can be very time consuming and may provide no benefit. It is much easier to optimize the code after you run some profile on the code, and figure out the slow areas. If the business requirement changes and the optimized code is no longer needed, all the effort is wasted. It is best to apply all the optimization as needed at the last possible moment in the development to gain the maximum benefit, so the development time can be reduced. In order to accomplish this, the application’s architecture must be flexible enough. Which means proper abstractions and separations are required to make this possible. br>