Reputation: 565
Ok, I had this argument with a friend about on how do we tackle data process in a restful environment.
The main idea is the application sends a data which is a position of the device (lat & long) to the server and expected to ping back the nearest device.
My argument was the process of determining the "nearest device" in the latlong position should be done in the server and just ping back the latlong of the nearest device.
Friend said that the process should be like this.. the server will pingback a json of every device with its latlong and the client itself will then determine the which one is the nearest.
Upvotes: 0
Views: 57
Reputation: 43364
Look at it this way:
A server is a datahub where all data is stored and processed.
A client is something that fetches data from a server, presents data to the user, and takes input from him.
Now you have to think about Seperation of Concerns. A client's job is to view data to a user, and take his input. A server's job is to process all data and transform it in such a way that a client needs to do minimal processing on it.
I.e. a client fetches some data from the server, all he should have to do now is show it on the screen. There should be minimal data processing on the client side. This is the server's job. The server's job is to make the client's job as easy as possible.
A client also has other things to do on the background (maybe also for other applications). It's CPU is not dedicated to your application, while your server's is.
What does a client need? The nearest device. What does the client ask the server? "Hey server, tell me what is the nearest device.". What should the server return? Exactly, the nearest device. Not a list of all devices which the client has to dig through himself.
Upvotes: 2
Reputation: 1477
No, I think that all information should be managed by the server...
If I understand you describe following schenario:
My questions is: why should a client compute the distance for anyone of (possible) thousands of devices?
In my mind the best idea is a RESTful service where:
This in my opinion. :)
Upvotes: 2