I am working on a Android app and I have a dilemma. I have a list of Objects. I have to update each of these objects with a database. I have 2 methods:
Method 1: I can loop through the Objects. For each object I can connect to the server, update it, and then move on to the next Object, and so forth.
Method 2: I can store the Objects in a list, send the whole list to the server, update it on the server side, then return a list of updated objects.
My questions are:
By the way, Method 1 is easier for me to code :). Thank you.
Method 1: Will take a little longer and utilize more bandwidth and processing power
Reasons:
Method 2: Will generally take less time and tend to utilize less bandwidth and processing power
Reasons: See above :)
I don't think that there's going to be much of a difference (depends on the size) but method 2 will be more efficient, since you have less overhead of starting the process, negotiation, et cetera. I would go with method 2 always.
But performance-wise, I don't think it will really matter a lot.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.