Search code examples
zk

Is my programming logic correct?


In my programs I use the next logic.

I create a MySession class with methods save, update, delete, loadAllRecordsFromMyTable, findMyRecord, etc, or rather every function that "query" database. In this class, I put also some static final consts like

protected static final Logger LOGGER = Logger.getLogger("Log");
protected static final List<EntityXYZ> allXYZ = new ArrayList<>();

EVERY viewmodal extends class MySession, but not every viewmodal uses all methods in MySession.

Here's my doubts:

  • I want to load some static list only once, cause they are immutable data in my database: is it correct to use a static final List<> in MySession? Where I have to load it the first (and unique) time?
  • Is this logic the correct one? Otherwise, which is the recommended approach?

Solution

  • Here the answer to many of my doubts.

    Thanks to chillworld for the great advices.