I had an argument with my PHP developer today who tried to convince me that REST API has to provide all the request from PHP since a server is faster than client devices such as desktop. As I am a REST API developer, I told him that it would be better if client can reduce the number of API request since since client devices can handle more stuff these days with powerful CPU power and greater memory. This is what we are trying to do. The REST API will provide a list of sale items for e-commerce site with a category of each items. I was asking PHP developer to generate filtering option based on provided categories in the item list. The PHP developer asked me to to provide the filtering option as a JSON. He wants to request two for this transaction, but I told him he can do it by only one request. Which way is right?
|
If I'm understanding you correctly, you are providing a list of items with 2 (or more) categories and you want to display them sorted or separated in some way. The options are multiple requests, one for each selected category. Or a single request allowing the client to specify multiple categories. If that's in any way close to the correct understanding, this is how I would look at it... Primarily, right or wrong, seems to be a harsh way to look at it. Advantages and disadvantages might be a less confrontational way to approach it and it might make it easier to come to an agreement. The advantages of multiple requests:
Advantages of a single request:
In general, I would say less requests is absolutely what you would want to aim for. But you really need to evaluate your individual situation and take into account a wider picture of the system and how it is likely to be used. And this may change over time. A system designed with a total of 3 categories, that grows over time to hundreds of categories would probably need to be reevaluated. |
||||
|