Program design question...

L

Lyndon

Hi all,

Just wondering what the recommended design approach is with VBA in
regards to classes versus modules. I come from an OO background and
am used to writing functionality within Classes or if I really bend
the rules, static methods. With VBA there seems to be two choices -
create a Class that contains the functionality I desire or create a
Module that performs the same functionality that can be called
"statically" without instantiating. What is the recommended approach
within VBA..?

For instance, I am writing an automated commentary tool that compares
derived values against various thresholds and then uses these pass/
fail conditions to select predefined pieces of text. These are
assembled in a hierarchy to produce a textual summary of the data. I
can see two ways of doing this in VBA, 1) Create a type that stores
these derived values as they are calculated and then pass the
populated type to a module that extracts the values one by one and
performs the necessary logic to create the commentary, 2) Create a
class, instantiate the class and set each property with the derived
values then call MyClass.Generate() which triggers the class to
perform the same logic to return the commentary. Both approaches seem
correct in the VBA world so I was wondering which is more correct.

Thanks in advance.

Lyndon.
 
M

Mark Lincoln

I don't believe either approach is "more correct." Go with what works
best for you.

Mark Lincoln
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top