Wednesday, June 10, 2009

Introduction to Optimization

In the modern world, people want software to perform labyrinthine tasks quickly. If people are forced to wait for software, they become frustrated, and they may seek alternative software to use. While great expansions have been made in hardware, the glory days of moore's law is almost over, and the burden of providing performance is increasingly being shifted onto programmers. As programmers do code optimization more frequently, they need to learn a few basic rules. Even though code optimization can increase the speed of a program, programmers should use optimization with great care, and they should always maintain clarity in code.

In many situations, code optimization can often be avoided by using good programming practices. Writing code is much like writing arguments or essays, and good programmers will often write an outline of the software program before they sit down to code it. Outlines allow programmers to focus on the clarity of the software without having to worry as much about details. After an outline is created, programmers should evaluate individual functions for algorithm selection. Since algorithms have strengths and weaknesses, programmers should select the right one for the task at hand. Like in English, programmers should also proof read for errors and redundancy. Good programming practices can reduce development time and provide better quality software, and they can also lead to more responsive software.

Many programmers often waste time optimizing irrelevant code. Optimizing every single line of a program is poor programing practice and a complete waste of time. When a program has speed problems, it should be profiled to identify areas in code that are causing the latency. Loops and complex calculating instructions should be the targeted areas during the optimization process. When an algorithm is identified as being the cause of performance loss, the algorithm should be evaluated by big-O notation before optimization is considered. If an algorithm has a poor big-o, it would be a waste of time to optimize the algorithm. Programmers must be able to identify areas in code that cause performance problems so that they do not waste time optimizing useless code.

Optimized code can be very difficult to maintain. Documentation is very important when code is being optimized because optimized code can be cryptic to read. Since optimized code is so complex, programmers should always provide the algorithm being used before optimization in their documentation. Aside from providing the unoptimized algorithm, programmers should detail every step of the optimization process so that they can understand the algorithm at a later date. Documentation is a critical part of the optimization process, and good programmers will always document optimized code rigorously.

In conclusion, programmers must follow good programming practices as they become increasingly responsible for performance gains in the computer industry. Programmers should always follow the software development cycle and proof read their code. During the coding process, programmers should rigorously document optimized code to avoid errors and maintenance nightmares.

No comments:

Post a Comment