Writing Solid Code
This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.
"Writing solid code" means writing Microsoft® Visual Basic® for Applications (VBA) code or script that performs as expected and is reusable, easy to understand, and easy to maintain. Many developers focus all their time and effort on just getting code to work. If you have ever struggled to understand code, whether written by you or someone else, or rewritten the same procedure to work in different applications, then you understand how writing solid code can make life easier.
One of the most important considerations for an effective Microsoft® Office application is how well it is designed. If your application has a user interface, you should be aware of consistency and ease-of-use issues every time you create a dialog box or add a custom toolbar. You also must be aware of the design and structure of the code you write. The way you design your code, from how you name variables to when you use class modules, can make a big difference in the maintainability and usability of your code.
In This Section
- Writing Solid Script
The benefits associated with writing reusable, understandable, and maintainable code can be realized whether you are writing script or Microsoft® Visual Basic® for Applications (VBA) code. - Using a Naming Convention
There are many formal naming conventions and each has its adherents and detractors. You can adopt one of the existing conventions or create one of your own. - Structuring and Formatting Your Code
How you use structured coding conventions directly affects how easy your code is to understand and maintain. - Commenting Code
All procedures and functions should begin with a brief comment describing the functional characteristics of the procedure (what it does). - Designing Code to Be Used Again
Reusable code is code that can be used, without modification, to perform a specific service regardless of what application uses the code.
Related Sections
- Programming Concepts
When you program, you store data and manipulate it with a series of instructions. The data and data storage containers are the raw materials of programming. - Custom Classes and Objects
If you have never used class modules to build custom objects before, this section covers the concepts that you must understand to design, build, and use custom objects with their own methods and properties. - The Windows API and Other Dynamic-Link Libraries
One of the most powerful features of Microsoft® Visual Basic® for Applications (VBA) is its extensibility. You can extend your applications by calling functions in the Microsoft® Windows® application programming interface (API) and other dynamic-link libraries (DLLs).