Android Question [SOLVED] Placing important vars in Starter vs Code module?

Discussion in 'Android Questions' started by Sandman, Oct 19, 2018.

  1. Sandman

    Sandman Well-Known Member Licensed User

    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.)
  2. npsonic

    npsonic Active Member Licensed User

    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.
  3. Erel

    Erel Administrator Staff Member Licensed User


    - 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.
    Sandman likes this.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice