In Erel's recent
"tips for B4X developers" post (which motivated me to clean up my code), he states that "Public (process_global) variables should be declared and set / initialized in Service_Create of the Starter service".
I understand that it's best to initialize/assign values to those public variables in Starter > Service_Create, because it's the only guaranteed entry point.
However, does it really matter where we declare our Process_Global variables - in Starter, or a common code module, or an activity?
There are a few reasons I ask this:
- I typically put PG variables in a common code module called "c", so the prefix is kept short when referenced from other modules (e.g. c.someVariable instead of Starter.someVariable). It reduces clutter a bit.
- If a PG variable is mostly used in a single module (and rarely referenced outside it), I usually put the variable in that module to keep it "close to home" (and to avoid prefixing in most cases).
- I'm hoping to minimize the amount of code I need to move around, probably because I'm lazy.
Thanks!