Vb Classic Containment And Delegation

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:

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


EditText of this page (last edited February 12, 2009) or FindPage with title or text search