Microsoft Office Project 2003 Inside Out

There are some people who would say that in this age of cheap computer memory and stunningly fast processors, efficient code isn't as important as it used to be. Perhaps they're right in a strict sense, but the idea of efficient code is more than just code that doesn't require much memory and uses as few processor cycles as possible. Efficient code also means using the best data type for the job, using object references wisely, and writing "smart" code.

Inside Out

Visual Basic is high level and compiled, which means that what you write is converted by a compiler into machine code for use by the computer. Modern compilers are amazingly good at optimizing the compiled code, but you are (in theory, at least) giving up some level of efficiency by not writing machine code directly. The tradeoff is that it is much, much faster and easier to write in a compiled language.

Visual Basic is also what's known as a high-level language, which means that it doesn't support methods for working with memory and the computer's processor that are available in a low-level language such as C.

 

Writing efficient code is as much an art as a science, and a full discussion of it is far beyond the scope of this book. There are, however, some simple things you can do to make your code more efficient:

Категории