Classes, Best practices question
I'm writing my first application that I will make use of classes in. I've read some on Object Oriented programming and would like to take my code to the next level (over standard modules). Let's say I have 3 distinct email types that my application will produce (Type A, B, and C).
I'm tempted to create a class for each type (clsA, clsB, and clsC). But, doing so would create redundant code in the 3, unless I can reference 1 standard module for the boiler plate functions.
So, the question is: Can I reference the Standard Module from each class, and if I can, should I? Perhaps there is a better way to handle this?
I'm sure this is a very rudimentary question for most, sorry if I placed it in the wrong section.
You might consider creating a single class with all the common functionality and then create subclasses by inheriting from it.
That is exactly what should be done. Consider the controls you probably already use in your applications. There is a Control class that contains all the common functionality that every control will have and then each individual control class inherits that base class, adding their own specific functionality. In that case, there are other intermediate classes too. In fact, controls are so varied and numerous that there are several layers of inheritance. In your case though, you probably only need one base class and then three derived classes. That said, if two of your email types share some functionality that the third doesn't, you might create a common base type for them that inherits the class that provides the functionality common to all three.
Originally Posted by Nybbler13
Excellent, thanks guys! For the benefit of others, here is an article I found after your responses which I think describes the process pretty well. (even though it's a 16 year old article)