Global variable or database always [closed]

1

I made an application using the jQuery Mobile library, it's an application to split account.

I created a main object called conta and it is incremented according to user actions (code below). As the pages are all in an HTML file, I used only one JS file as well and I was working with the global variables to store information, since I do not need to load the file to change pages. At the end, at the time of saving, I use JSON and pass the entire conta object to the localStorage.

Question

Should I always be storing and fetching the data in the database or can I use the global variables to store data in situations where the page will not have the page load? What is the best practice?

Code:

/*********************************************************
Todo o codigo eh em funcao deste objeto, que esta sempre mudando
**************************************************************/
var conta = {

    idConta: 0,
    nomeConta: "",
    data: "",
    contaCarregada: false,

    pessoas: {
        pessoa: [], //nome + id
        quantAdd: 0,

    },

    produtos: {
        produto: [], //aqui vai id, nome, quant... de cada produto adicionado
        quantAdd: 0,
        totalInserido: 0
    },

    jaCalculado: false,
    produtoAlterado: false

};
    
asked by anonymous 10.01.2017 / 00:20

0 answers