Using a class within a class

I have a class which has a few properties, nothing else (in fact I have a number of classes like that, all in a folder named “Classes”). This particular class is used only in a particular thread subclass. It struck me that I ought to be able to move it out of the Classes folder and put it with the collection of items (methods, events, etc) for that particular thread, thus improving the modularity of my app in some small way.

However, this appears not to be possible. Should I be using something other than a class for this collection of properties (Structure appears not to be appropriate)?

1 Like

Use a module with proper scope settings



Not currently possible, but would be a good feature

Move the class and the thread subclass to their own module. (I think that’s what Karen was suggesting.)

Yes that is what I was saying. You can make the friend class private that way by setting scope



Yes, I did a very quick trial and I see how to do that. The only thing then is that when instantiating the thread elsewhere in the app, I seem to have to fully qualify the name. So, instead of just:

t = new mythread

I would now have to say:

t = new mymodule.mythread

which is a bit cluttering. When I saw that I was a bit surprised as the threadclass name mythread is unique across the app and I have numbers of methods in other modules which I can use directly anywhere with no need to qualify their names. Perhaps I have to play a bit with scopes.

1 Like

Set the scope to Global rather than Public.

i normally do this:
Module name: MyFramework (fullname)
Class names: MFclassname (prefixed, inside the module)
classes are GLOBAL (as kem suggests) and then it’s much easier to know where the class belongs to.
Basicly what apple does with NS… prefix.

But you can do whatever you want or do as xojo did:
MyFramework.className … etc.

Thanks, that works nicely. What was also confusing was that until I moved these two classes into a module, there was no setting anywhere to set their scope. Once in the module, such settings appeared.

Thanks for the suggestions and help.

1 Like