Write Bug-Free Code
I encourage a guided, trial-and-error approach to learning how to program. This is mainly because I don’t think anyone can remember all the facts and information you need to know without having some way to apply that information in a practical way. Also, I think most of us are impatient by nature and want to get started as soon as possible.
However, I don’t want you to confuse this approach with disorganization or sloppiness. Either of those bad habits will make your programming experience difficult and frustrating. The following list is a collection of good habits that will pay off as you learn and develop your career:

Figure 1-33. Your digital signature now appears in the macro security warning
- Declare all your variables
Adding
Option Explicitto the top of each class or module helps make sure you don’t accidentally misspell a variable name and cause a subtle error that can be hard to locate.- Type carefully
Many names in Excel, such as worksheet names or named ranges, can’t be checked through
Option Explicitand misspelling one of those in code can lead to similarly hard-to-locate errors.- Use short, descriptive names
There are different conventions for naming variables and procedures but the crux of all of them is to be short and descriptive. Be careful not to be too descriptive though. I try to keep variable names down to a few characters and I tend ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access