I’m only just attempting to use subclasses (derived classes) in LotusScript for the first time, and have a question about method overriding. I hope someone with more experience in this area can answer it…
Say MyClass1 contains three methods called in a stack, like this:
Class MyClass1
Sub Method3
' Do something...
End Sub
Sub Method2
Call Method3
' Do something else...
End Sub
Sub Method1
Call Method2
' Do something else...
End Sub
End Class
Now I make a subclass than only overrides Method3, like this:
Class MyClass2 As MyClass1
Sub Method3
' Do something different to the superclass...
End Sub
End Class
What happens when some code creates an instance of MyClass2, then calls Method1?
Does it end up calling MyClass1’s version of Method3, or MyClass2’s version?
(I will probably try actually coding this with print statements to find out for sure.)
If it calls MyClass1’s version, is there any simple way to make it call MyClass2’s version without overriding Method1?
I have a specific situation where I need to do exactly this…
I’m trying to rewrite an old script library with 42 subs/functions, about 2600 lines of code, and no classes.
This code works fine as is most of the time, but four functions use ODBC, and we have a customer running Linux servers where this script library (and several agents that use it) won’t load. The servers have a problem with UseLSX “*LSXODBC”.
I’m trying to rewrite this as two classes in separate script libraries. The superclass will contain nearly all the existing code, just without the ODBC parts.
The subclass will override just the four functions that use ODBC. The problem is that those functions are called by several other functions in the existing script library. If calling the overridden versions of those four functions requires overriding everything that calls them, that means maintaining two exact copies of at least 500 lines of code.