AutoCAD VBA Programming: Tools and Techniques

Chapter Thirteen: Programming Style

Overview

Style is always a difficult subject to broach because everyone believes that his or her system is the best. Still, there are many things about programming style that programmers can agree upon. The reason we need a common style is so anyone trying to maintain our code can read it and understand it. Whether you write for multiple clients, or in-house for your company, or at home to make your projects run more quickly, it is best to follow some simple guidelines for your code. Good style code always has the following guidelines in common. Some of the important common guidelines are:

  • The code is always well commented.

  • The code is kept concise and simple.

  • Repetitive actions are placed in their own subroutines or functions.

  • Variables are defined within the proper scope, precedence, and life.

  • All modules have error trapping.

We can look at these common guidelines in detail in the following pages. Whole books have been written on the subject and this chapter just covers some of the more common guidelines.

Commenting Your Code

On the surface, commenting on code may seem to be a common sense practice but you would be amazed at how programmers interpret this subject. Some ignore it and do not comment at all, others comment only at the beginning of a section of code, and others comment every line. Not commenting your code at all is an open invitation to disaster. No matter how good you are, failing to comment the code will lead...

UNLIMITED FREE
ACCESS
TO THE WORLD'S BEST IDEAS

SUBMIT
Already a GlobalSpec user? Log in.

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.

Customize Your GlobalSpec Experience

Category: Code Analyzer Software and Tools
Finish!
Privacy Policy

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.