View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
chatterbox chatterbox is offline
external usenet poster
 
Posts: 11
Default Separating Business Logic from User Interaction (Userforms)

Hi everybody !

I want to tidy up an Excel VBA project. The principal interface is a
form with four meaty pages. Being new to all this I initially coded
much of the business logic into the form class module, interacting with
a collection class object which held much of the data. This lead to
several thousand lines of code being housed in the form class module.
This was a prototype and it served its point.

I now wish to develop the code afresh for the full-blown software. I
have read that it is best to separate out the user interaction code
from the business logic, and I certainly agree. I intend placing code
for each form page in separate standard modules, leaving the interface
code in the form class module, and the class object where it is. From
this I have 2 questions I would like a little guidence with.

1. Should I create a User Interface Support (UIS) class module to
handle interaction between the form class and the individual standard
modules, or should I just have the form class and standard modules ?
What are the merits of a UIS layer ?

2. Consider the following. I pass a list box user selection to the
UIS layer and then to the business logic layer, and on interrogation
that layer needs to return more than one value back to the interface
layer to populate more than one control box with return values. How
should I code the Business logic layer to pass these multiple
independent values back through the UIS layer and finally to the
interface layer ? Or should I scrap the UIS layer ?

(My ambling thoughts: would each layer have to use a raise event to
pass upwards an array of values or function return ? Would I have to
pass each value upwards separately ? And if so, how ?)

Thanks in advance for any assistance you can offer.

chatterbox