Greetings,
I am trying to implement class modules in my VBA code using best practices, but I have question about encapsulation vs. redundant code. Let's say I have two class objects, both of which need to be able (purely as an example) extract a filename from the end of a full name string. To avoid redundant code, my first inclination is to write this a public function and then call this function from both class modules, but now I seem to have violated the principle of code encapsulation. Is it better to copy the code as identical private functions inside each class module? Should I put this common code in a "utility" class module, so that it is explicitly called in the other classes, making the dependency clear to future users of the code? I look forwarding to hearing your opinions.
Thanks for your advice,
Jeff
Bookmarks