I am developping an application that retrieves some data from a server.
I have two options:
-
Get the whole data set from the server and then work with it using the pattern ‘singleton’ to reduce the number of queries
-
For each query, get the corresponding data set from the server
What is the best choice?
In my opinion it depends.
It depends on the size of the data and if it even makes sense to return data that your user may not even need.
Personally, in my app that I am building I will be returning only the data that is required at that time. Obviously though, once I have the data I won’t be fetching it again if it makes sense to keep hold of it for good or even just temporarily.