Optimizing Your Source Code!

Source code optimization is the modification of code for improved performance and efficiency. Optimization can be done in various parts of the code like loops(using methods like Loop unrolling, Loop splitting etc.), data flow optimization(using methods like Induction variable recognition and elimination, Dead store elimination) etc.

As everything in this world comes with a trade-off, optimizing the source code is no different. Generally we talk about time and space complexity when calculating the performance and efficiency of the program. For improving one, other has be compromised. But these two are not the only aspect of optimization, it has other faces as well. As said by Sir Donald Knuth-

“Premature optimization is the root of all evil”

There is no particular part or phase in the software development life cycle where optimization is supposed to be done, if required, it should be done by the developer when writing the code. As there is a saying-

Think twice and Code once!

If there is a big project and let say the developer has used hell loads of static variables in it and some other developer is asked to optimize the code then in most of the situation what will happen is the one optimizing the code(without knowing the logic behind it) will end up inserting more bugs in the code.

We should understand that not every code can be optimized and it depends upon the situation whether we really need to optimize our code or not and if we really are talking about increased performance and efficiency then we should be thinking something bigger than choosing between int and long.

 

 

 

Leave a comment

Create a free website or blog at WordPress.com.

Up ↑