I know that we're supposed to place important vars in Starter so they are always around. But I have to ask why we can't place them in a code module instead? That's always around also, right? Or do vars in code modules get purged now and then by the OS? Or are there other problems?
(Why a code module? Well, it's a pretty nice way of structuring them, with the added bonus of not cluttering up the Starter.)
However:
- Service_Create of the starter service is the program entry point. So it makes sense to use it to initialize the program globally accessed objects.
- Code modules cannot raise events. I almost never use code modules in B4A. Classes are more powerful.
I think that this thinking method comes from Java (not B4J) where you have interfaces, abstract classes and so on.
You can use Starter service to initialize important classes, so these classes can be shared if necessary. I personally use code modules for some basic tasks that aren't depended from other modules. If you have to initialize something then code module might not be best for the task.
However:
- Service_Create of the starter service is the program entry point. So it makes sense to use it to initialize the program globally accessed objects.
- Code modules cannot raise events. I almost never use code modules in B4A. Classes are more powerful.