Hardcode items or retrieve them from the server and store them localy?

Hey guys,

I’m asking myself a design question. I have a list of items I use in the app. This list is stored in the db on the server side. User will interact with it in the app.
Now what makes more sense to display them?
option 1: retrieve all those items during a login and store them in the local storage until log out and then just call them out from there
option 2: hard code the list in the js and retrieve them directly.

My doubt is related to updates of the app, what is the best ? If I add new items in the DB I will then hard code the list in the app, update the app, release an update whereas with option1 I will need to wait for the user to retrieve them a next login…
Considering these are items are essentials for the app visual interface (but not visible if not logged in) I was leaning towards options 2.

What do you guys think?

Hello again,

If the list data has the chance of being changed I would pull it from the database. It is a lot less work to modify the database than to update the html and release a version to the app store (especially if you’re creating it for iOS since they can take a week to approve your app).

If updating the list is not time critical, then you could hard code it, but I always lean towards pulling data in over hard coding.

You don’t necessarily have to wait for the user to retrieve them on the next login, you could call a function on resume of the app (for example) that pulls in this list information (if they are logged in). I do this in my app to make sure the user has a connection on resume, since they can’t do anything without a connection:

$ionicPlatform.on('resume', function(){
    // If the user resumes the app we need to call the register device service in case they were dormant
    // for a long time and we have since gone into maintenance mode
    httpRequests.registerDevice();
});

Let me know if I misunderstood you.

1 Like

Thanks that’s exactly what I asked.
It’s not time consuming to add in the html but the app store argument makes a lot of sense!

Thanks!

ps: I’m preparing a next question hahaha :stuck_out_tongue:

You’re welcome. And okay ha. :smile:

1 Like