Containment and delegation is what
VbClassic does instead of inheritance. Yeah I know, OO good,
VbClassic bad, but here's my 3-Tier/MTS/ASP/COM/MSMQ/DNA/ADO skilled
VbClassic crew, and there's your OO language
waaaaaay ooover theeeerree.
So the problem is
VbClassic doesn't seem to support even C&D very well - your solutions to the following problems much appreciated:
- There's no #include statement in VbClassic. So every VbClassic "derived" class that you want to have delegate to a "base" class has to duplicate delegation methods. Unless anyone knows a way to do a #include?
- So ... dropping in a preprocessor could plainly fix this, but our IDE-dependent developers don't have any way to add-in a preprocessor ... right?
- So ... the "Visual Basic Extensibility model" looks vaguely like it will generate delegation code, but how much work is this? And if we want to be able to refactor the generated code later?
- So ... there are commercial 3rd-party tools that sort of do this right ... but they're not MS, and if we wanted to do non-MS solutions do you think we'd be using VbClassic?
Any cleverness along these lines in your
VbClassic bag of tricks, please explain below.
There is no such cleverness. The best you can do is to contain your "base" object and expose it as a property of the "derived" object. If you want to get polymorphic about it, however, you're still going to have to at least implement the _Base interface and write, by hand, a bunch of clunky _Base_method delegation routines. It is amazing that VbClassic has been rewritten 6 times now, and is still this bad a language. Well, that's not as amazing as the fact that corporates keep on buying into it ...
What is a 'bad language'? And why is
VbClassic one? How do you define 'bad'? And 'good'? -- Thomas Eyde
No, if you really want to do OO in the sort of context you're talking about, there's nothing better than PythonLanguage. --
PeterMerel
VisualBasicDotNet supports inheritance.
(Why it took them so long, I'll never know. ;-)
I have found a decent way to do
TemplateMethod in
VbClassic: You have to think backwards: Create an instance of the general class and feed it with the specialization. Let's say you want to sort collections. The usage would be something like:
Dim thePersons As Collection
Set thePersons = db.GetPersons()
'
Dim theSorter As New CSorter
Dim theSortedPersons As Collection
Set theSortedPersons = theSorter.Sort(thePersons, new CPersonSorter)
The CPersonSorter would implement the ISorter interface. The Sort method would contain the common code and calls the specialized code on the passed ISorter.
--
ThomasEyde
CategoryVbClassic