Sunday, December 21, 2014

Is your computer program optimized?

Image credit: https://www.flickr.com/photos/improveit/1987747052
You may be well-versed in writing computer programs in your specialized topics. My question is how well the program you write is optimized? If your program is already optimized, then there is no need to revise or modify it. But some programs written with poor structure and with too many resources may not work efficiently. They consume more execution time and memory storage thereby increasing the cost. By modifying those parts, a computer program may be optimized for increasing its speed of execution drawing less memory storage and power.

Some tips for program or software optimization:

1. Avoid the use of too many variables


If you can solve a problem with two variables, remove the third one that you’ve used in your program.

2. Divide your program into functions or sub-routines


When the same process has to be executed many times in a program, consider it to put in a function rather than writing the same procedure all over again. This would shorten the length of your source code. This is the main feature of top-down, structured programming.

3. Make a smaller function inline


Inline functions expand at the time of the function call itself. This reduces the cost of overheads such as jumping to the function, saving registers, pushing arguments into the stack and returning to the calling function. When a function is small, a substantial amount of time is spent in such overheads.


Related post in Hubpages:

How to learn programming; 5 best resources for a beginner







2 comments:

  1. Nice and simple introduction to good coding practices for a beginner.

    ReplyDelete
    Replies
    1. Thanks Venkat for the heads up. Much appreciated.

      Delete