I’ve been out of the Xojo world for a while, but I’ve decided to rewrite my old OOP book for the new Xojo.
The most obvious OOP feature that’s been added in the last few years is using with modules.
The documentation is, as usual, incomplete on the issue. From what I can see when experimenting with the feature, if a class is set to using a Module, then all the methods, protected or public, on the module are available as if declared on the class in question, but the exact semantics appear to be interesting.
If I declare a Class1 using a module Test, and I add Test.foo(extends c As Class1), then I can do
Dim c As New Class1
c.foo
From within a method on Class1, I can do just:
foo
and c gets transparently set to self. I can also call foo without the extends argument, and it still works, so this appears to be just cleverly picking up the extends argument when called from within a class that is using the module.
It seems that if I call a method defined on both Class1 and Test, then if I call that method from within code declared in Class1, I get CLass1’s version of the method. But if I call it from Test, even calling it on c from within foo, I get the version from the module.
This is all very interesting, and particularly useful in breaking up the features of a complex class so it’s not just enormous, or for sharing code between classes.
My question is: is this behavior specified somewhere? I will endeavor to provide detailed documentation of it in my book, but first I have to work out all the behavior for myself.