Programming Guidelines / Good Practices

Hi all,
New to Xojo, I was wondering if there were any Programming Guidelines / Good Practices “official” documents available out there ?
Thank you

https://documentation.xojo.com/

This post was flagged by the community and is temporarily hidden.

And the videos that date from more than 2 years may be obsolete too…

2 Likes

Ok thanks for the update

I see…

I do not understand the reason why members flagged this post.

I disagree about what you said about the examples; most of them are still useful and show the concepts of programming in Xojo. If you encounter an error in these examples, it is a good exercise to make it work and afterwards share your solution.

About programming guidelines, I put an abbreviation before the variable name, which represents the type. The same for every object. These are my abbrevations:

txt_ : text variable
str_ : string variable
int_ : integer number
int8_ : 8 bit integer
sng_ : single variable
dbl_ : double variable
bln_ : boolean variable

obj_ : object
grd_ : grid/listbox
txta_ : text box input area
txtf_ : text field input area
opt_ : option (radio) button
chk_ : checkbox
grp_ : groupbox
sld_ : slider
frm_ : window object (I used “frm” which stands for “Form” back in the nineties with VB6 and kept the abbreviation). Form is the same as Window in Xojo.

These are no official abbreviations, but they are a big help when something goes wrong.

Just comment or use remarks as much as you can, to document your code. In the future when you have to add features or have to modify something, you will be happy you did.

I hope this helps.

3 Likes

Thanks for sharing

Hi @Philippe_Fuentes

The quick starts are a good place to start. QuickStarts — Xojo documentation

Next, pull apart the examples, an excellent resource when getting started, and included with Xojo.

In terms of code style, the “official” document is at Coding guidelines — Xojo documentation, and is as good a place as any to start. Personally, I dislike the Absolutely Everything Starts With An Uppercase Letter style, and I place all my keywords in lowercase, which allows class names and so on to stand out, as they are in title case. I used to prefix items like @Chris_Verberne, and I know many still do, but I dropped that convention some years ago. So, previously, my DesktopWindows would have been named something like winMain. Now it’s MainWindow, and I find that works out just fine.

Xojo is pretty flexible, and a lot of these things will be your own personal choice as you develop. To get started, pick a style, and stick to it - for now.

1 Like

Fully agree with you.

Great, thanks for your reply

Books and PDF will provide information. However, hands on will provide experience. Priceless.

Same idea here, but I suffix them excepted for Controls: I prefix them.

Also, sometimes I write using two or three “compor-ents (ideas) to make the variable name useful (you understand what it is for at the first read), but in a way the Auto-complete feature fits the best; as an example, the start / end dates: MagDateStart / MagDateEnd. So I only have to type Mag + Tab and select Start or End…

A long name, all lower of UPPER case is a bit useless; using an UpperCase character in the variable name (look above the Dates examples) is best for reading. Sometimes I use an underscore like in: Open_FI, Save_FI, Open_Dlg, Save_Dlg, etc.

You have to find from the shared ideas what you like best and use it.