VBA Best Practice
There is a lot of information floating around about how to get various things done in VBA, how to make the best use, or sometimes just the most use of VBA and Excel.
This section aims to add an element of Quality and Best Practices. These are just general guidelines, a professional developer will always assess the options and make the appropriate choice in their specific situation.
These suggestions are specific to Excel VBA in commercial settings, many will not translate to other technologies or other settings.
VBA Best Practice Series
Design - 2 Questions, 2 Approaches
In terms of design there are two key questions and two key approaches
What will happen when things go right?
What will happen when things go wrong?
It is important to consider these two cases, many problems are created later in the life of the system if the second one is ignored early on.
What will the system do?
What real world objects am I modeling?
The first question leads to a procedural design, the second leads to a more object oriented one. OO has lots of benefits in many large scale developments. Often for smaller systems, which many spreadsheet systems are, a procedural approach is the simplest to implement and maintain. If all developers have only OO experience though then that must be factored in, and may result in an OO system because that is easier for the development team.
There is no best, or right and wrong, people who advocate one or the other very strongly, often just have no experience of the other. Certain technologies can also influence choice - Excel/VBA is not very rich from an OO point of view so a functional or procedural approach often makes sense. C++ and C# on the other hand have very powerful object oriented features and work best in OO style projects.