Special

Introducing the “Welcome to Xojo” Bundle!

New to Xojo and looking for guidance? We've put together a terrific bundle to welcome you! Xojo Bundle

This bundle includes six back issues of the magazine -- all of year 21 in printed book and digital formats -- plus a one-year subscription (beginning with 22.1) so you'll be learning all about Xojo for the next year. It's the perfect way to get started programming with Xojo. And you save as much as $35 over the non-bundle price!

This offer is only available for a limited time as supplies are limited, so hurry today and order this special bundle before the offer goes away!

Article Preview


Buy Now

Issue 4.2

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 (http://www.extremeoptimizing.com) and CTO of SlayFire Software Co., creating performance, quality, and porting tools for REALbasic (http://www.slayfire.com). He is the author of code optimization tools for Visual Basic and the author of VB6 Programmers Toolkit and the VB6 Bible and presents code optimization sessions at REAL World.
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.