Library best practices

Hello all,

Before I jump into working with Libraries, is there any defined best practices to use? Or just follow the help?

Thanks
Tim

You may start reading the documentation, then the Xojo blog posts, maybe some of the testers messages in the forum.

Checking Out Xojo Libraries

Creating Libraries that Support Multiple Project Types

I also wrote a few notes myself in a blog post:

With Xojo 2025r3 we got a new thing: Libraries

After reading the first two articles, it looks like there are duplicated code to be expected.
For instance, taking the example of the first page (the ReverseString method), and making it working for each project type (what the second page is about), it appears the library would need to contain one ReverseString method per platform, making the exact same method appearing for desktop, web, mobile and console.
I don’t find efficient, and not OOP compliant, to have the exact same method (e.g. ReverseString) appearing 4 times in a library.
Or I’m maybe overlooking something?

Library are compiled code, so if you target multiple platform then you will have multiple compiled code, but your original code is only one.

1 Like

Pertinent remark. The compiled code will be duplicated, but not the original code.
Still, the original code will need to be copied&pasted from each project type.

Maybe we should have a feature request to build a library for desktop + console in one go?

Like for a library doing JSON stuff or math, which can be used anywhere.

1 Like

I’m a little surprised it doesn’t do that just by setting the compatibility flags, but it might have been an easier lift to match the build to the current project type for this first version.

I made a Feature request.

https://tracker.xojo.com/xojoinc/xojo/-/issues/80534

2 Likes

Thank you.

I thought this hassle exactly should a library solve. But in case of multiplatform/multiprojecttype, it doesn‘t.

But it does so for crossplatform of one project type, thats a nice first step.

So, apparently “first version” and “first step” do seem natural for you.

I am not a bad by who want all and everything right now, but this does not satisfy me at all.

I am in this boat since early 1998, and too accustomed to this way of doing things, re-doing things, changing for the sake of changing, coming after the battle, and so on.
“The way things are going” (*)
I will be dead before this development software will be in pair with the others


(*) From : The Beatles, “Ballad of John and Yoko” lyrics (John Lennon).

This is a confusing statement.

The person that is making the library may need to do this, but not the people that are using them.

1 Like

The more I hear about libraries, the more glad I am that I chose not to renew at the Black Friday sale.

2 Likes