Article Preview
Buy Now
COLUMN
Optimizing REALbasic
Optimizing with Stock Replacements
Issue: 4.2 (November/December 2005)
Author: Hank Marquis
Author Bio: Hank Marquis is the creator of Extreme Optimizing (
Article Description: No description available.
Article Length (in bytes): 11,129
Starting Page Number: 44
Article Number: 4221
Related Web Link(s):
http://www.extremeoptimizing.com
http://www.slayfire.com
http://www.slayfire.com/OptimizerScience/speedtest7.html
Excerpt of article text...
In the last issue I introduced the concept of what I call Extreme Optimization (XO). XO is a way of writing code that produces the fastest code in the least amount of time. One of the key elements of XO is to optimize as you code, and never wait until after development is complete to start optimizing. Another principle is the concept of making many small changes in your code. The net affect of many small changes is often a dramatic improvement of overall performance of an application. This issue I want to focus on how to combine these two XO concepts into a single useful habit: coding stock replacements.
Stock Replacements
A stock replacement is code you write in a specific way every time you need to address a particular programming need. A stock replacement is a "best practice" that provides a repeatable performance gain.
The idea behind the stock replacement is that the code you write for some programming tasks is virtually always going to induce a performance penalty. Loop constructs such as Do, For, and While are examples. Instead of waiting until after development concludes to optimize, XO says optimize as you code. Our goal is to train ourselves and develop a method of coding that builds in optimization as we code so that we don't't have to spend time trying to optimize later.
Remember, optimization should always be a part of initial development. Trying to optimize at the end of the development cycle, while common, is often not as effective and can induce problems. For example, one good stock replacement is to always use a counter variable when working with For loops: consider the code in listing 1.
Listing 1: Non-optimized For Loop
...End of Excerpt. Please purchase the magazine to read the full article.