Create "package"?

Maybe this is a dumb question, but I have to ask it nevertheless …

A few days ago Beatrix Willius gave a hint to the book “Head First Design Patterns” in this thread. (Thanks for that!)
As a hobby programmer I read the term “design pattern” several times but never got into it. So now I bought the book and the first pages were really fascinating. In order to practice I started to try to implement the Strategy Pattern, which helped me with a problem at a current project: I wanted to create a TextArea subclass, which should be able to handle opening and saving of text files of various file types; the Strategy Pattern seemed to be a good solution. The UML of my implementation now looks like this: Link to picture

Now my question: I would like to reuse the FileHandler with the associated classes (and corresponding FileTypes etc.) in other projects in the future. Do I have to copy each and every class to the other project – which needs taking care of not forgetting one because of dependencies –, or is it possible to “bundle” the pattern classes to some kind of package or library?
Any hint will be appreciated …

make an “external item”, and add them to your new projects in the future.

except if its a module that contains modules & other classes and … yeah I wish I had been able to make all that work but … blech !

yep I would so like to have external modules that could contain classes and windows !

@Jean-Yves Pochez: If I do that I have a bunch of class files exported; but still I have to import every single of those classes in the next project.
My intention was to merge those classes to one single file (bundle/package/library?), so that the next time I would only have to include one item. I would even be satisfied to create a subfolder of classes in the IDE for a better overview, but I haven’t found out if that’s possible.

@Norman Palardy: I’m sorry, but unfortunately my English is not good enough to get the last part of your comment …

If you want to use a MODULE as an external item it CAN NOT contain other modules or classes

No, there is no module, just a bunch of classes, an interface and a FileType group, which I wish I could somehow merge together to one entity.

[quote=467094:@Jens Knipp]@Jean-Yves Pochez: If I do that I have a bunch of class files exported; but still I have to import every single of those classes in the next project.
My intention was to merge those classes to one single file (bundle/package/library?), so that the next time I would only have to include one item. I would even be satisfied to create a subfolder of classes in the IDE for a better overview, but I haven’t found out if that’s possible.[/quote]
I don’t know it this will help but you can place all of the items in a Folder in the IDE and export that to somewhere on your desktop. Then, for later projects, drag the folder into the project (don’t try to import it) and it should all get loaded. They will be local to the project, not as external items.

That really helped indeed. Thank you very much!
It just works as you described it, and it will be much easier next time to just grab the whole folder instead of searching together all dependant classes etc. …

I just use svn externals which are forunately dead easy to set up AND can be used with any svn server whether its local or remote
But you do need to be using the text format

You can also make template projects, with all the required external items in it.
just select when you create a new project it’s 1 second.
the external items helps in that if you modify in one project, then all other projects that have this external item in them
get modified when you compile them again. this is a feature I use all the time.

For now I will go with the folder solution, but I will keep externals in mind.
Until now I don’t have much reusable code (and there are only very few own projects that are really useful to me), but digging deeper into design patterns might (hopefully) change that some day.

You can drag a folder into the IDE using the modifier keys to import the whole thing as external items. Ctrl-Shift-Drag on Windows.

I will try that, thank you!

[quote=467094:@Jens Knipp]@Jean-Yves Pochez: If I do that I have a bunch of class files exported; but still I have to import every single of those classes in the next project.
My intention was to merge those classes to one single file (bundle/package/library?), so that the next time I would only have to include one item. I would even be satisfied to create a subfolder of classes in the IDE for a better overview, but I haven’t found out if that’s possible.[/quote]

It is possible – what you are looking for is a module. Create a new module, give it a name, put all your interdependent stuff inside and export it. Then you can add that module to other projects in just one step. It’s really useful – I have modules for window handling, preferences, checking for updates etc. that I use in nearly all my projects.

So what’s the issue the others were talking about? In principle a module can be external: to add a module to a project you only need to add a reference. That means there is just one version of the module that any number of projects may share. Now if you ever find a bug in your module and fix it, every project referencing that module automatically inherits that fix; you only need to recompile. But the issue is that once you add classes to your module it loses the ability to be referenced externally. You can still import it in other projects, no problem, but Xojo will copy it to your project rather than adding just a reference. So you get multiple instances of the module, one for each project, and if you fix a bug you need to fix it in each project using that module. Too bad, but modules are a useful way of packaging code nonetheless. Don’t let this issue deter you from using modules.

(By the way, using modules containing classes and stuff as externals is impossible not only in the sense that you cannot do it using the current version of Xojo, but also in the sense that in so many years, nobody has found a way of changing Xojo so you could.)

Ah, I didn‘t know that I can put classes in a module. I will try that approach.
(Bugfixing is a minor problem at the moment because I don‘t have many projects. Time will show if I have to favor modules or externals.)

you can, but only in a “local” module. if you change it to an external module, classes inside are not supported.

I‘m a bit startled about how much there is I still don‘t know even about the IDE, although I have been using Xojo for about three years by now…