New App Templates

Just wondering what your opinion is about creating a startup template for new applications? Of course, the reason is to avoid starting from scratch, but the downside is how to keep from adding more than is really necessary.

The main issue is to keep them updated. For me it is more about rocket solid code bits but mainly certain structure of code. For instance a login screen for WebApp and all the involved dependencies (database connection, comments of the db structure needed, etc.).

But it really depends on your business as well. If you are doing something repeatedly or very often templates can be precious. I for instance have the need 2 or 3 times a year to write a Windows Service … and most of the time I would forget the steps I need to take (as well to install the services later). For this I have build an own template for a few customers, as they have slight differences in their configuration. But of course, I could as well just copy a repository in my private github …

As rule of thumb: for me a template is more about guiding you either on the needed structure of your code, or rock solid pieces of code which you have to use often.

I use external modules rather than templates. One advantage is that if you fix something, that fixes it everywhere.

1 Like

Well, only if you do it right, when I begun using them that didn’t always work :wink: - but it is a good learning curve to write clean and modularized code.

I’m interested in this technique.
Could you give me a quick “Module 101” course? How you export/save them and how you get them into a new project?

Thank you

Add a module to your project, right-click it and choose “Make External”. Go to another project and Ctrl-Shift-drag the module file into your project. (Windows, not sure what the modifier keys are for Mac. Probably Cmd-Shift-drag.) That brings the module into your project as an external item. Any changes you make to the module will be reflected in the other project as well.

Tim - FYI, the keys on a Mac to drag an external class or module into a project is Cmd+Option.

We do this for both classes and modules but you have to be careful and ensure that the class and module fit into each of your projects. This is sometimes easier said than done, but we’ve been doing this for quite sometime.

We have a project called PW_NEWAPP that was created years ago and whenever we start a new project we simply open that project and save it to a new folder, then rename accordingly. It has a bunch of functionality builtin so keep you from starting from scratch. Such as, splashscreen, default menubar, error handling, activation (for our apps), downloading updates, etc.

I’m in the process of creating a new PW_TEMPLATE based on the latest version of xojo because using our PW_NEWAPP did create a problem when certain features become deprecated and removed from xojo. Using our PW_NEWAPP meant that certain features that were deprecated still work because they are sort of “grandfathered” into our project, but you may not realize the issue until they are finally removed from XOJO. A good example of this is RealSQLDatabase, which still works in the apps build with PW_NEWAPP.

Creating a new PW_NEWAPP means that any of the legacy code that worked because the original project was created with an older version now needs to be fixed because it may not work with a newer version of XOJO.

I’ll also note that you can drag an entire directory in at once and the IDE will create a folder with all the files in it as externals. We have a directory of standard code that goes in all our apps. There are 20 or so separate modules and classes in it and it’s really convenient to add them all at once.

That said, I usually start from a project that is similar to what I want to do and just copy it to a new name and hack away at it. We have 4 types of projects, all related to database content editing.

The simplest is a simple window with a listbox that can be edited in place. That’s for support tables that have just a few fields.

For support tables with more than a few fields, we have a combo-window. A window divided into two areas: a listbox displaying the identifying info for each row, and an area with the edit fields for the database row. As you scroll through the listbox, the fields are updated to reflect the row and you can just click into them to edit. Your changes are saved automatically if you click back into the listbox. (We do provide Edit/Update/Delete buttons as well.)

Then there’s the meaty projects with a more complex listbox and a popup window to edit the details. Stuff like invoices and customer records. Things that use the supporting tables to actually do business processes.

And finally, there are reports, which contain our custom reporting engine (another folder containing a dozen files that gets dragged in as needed).

Someday I need to create 4 templates to keep things clean.

I picked up meny good ideas from the post.
Thanks everybody for sharing them

1 Like