I understand the title of the forum is Visual Basic but as I've seen other people have posted Excel and macros, I suspect it extends to VBA. My question relates to writing VBA in an object oriented fashion.
For example, this shows Compostion (to make up for the lack of Inheritance in VBA):
Note in ClsVolume, I have:
I know it's a minor point, as both return the same (correct) result but would one be preferable over the other?
I am aware of the following:
though have not really seen it / aware it's been applied in VBA.
My main obstacle lies in the preparation stage, ie BEFORE coding takes place. I don't know how to model the task.
(My example above of Area vs Volume is one simple example (I think) showng a base class (Area) and its derived class (Volume)).
I have read a lot of OO but the material tends to cover other languages. The closest I've come across is RubberDuck (
https://rubberduckvba.com/) but I found it hard to understand.
The standard response for writing OO is that it's good for large projects and makes things scalable.
Well every program starts off small and since nobody knows if it'll grow bigger, surely that means all programs should be written in an OO way?
Can someone provide examples of a VBA program written in both styles, ie "the usual way" vs in an OO way, then point out why OO might be better?
Thanks