-1

This question probably already exist but its too specific and hard to seach for it.

So, imagine that we have a ecommerce application.

On page 1 we have a list of products. And when its tapped, we go to a page 2, where it holds more information about the product that you just tapped for. Pretty much like any other ecommerce out there.

Which one of these two situations are better:

  1. When one product is tapped, we pass via arguments all the informations about this product to the page 2. Then, no requests to the database is necessary.
  2. When one product is tapped, we pass its ID only, then we need to do a request to get this product information from database.

You might think its obvious that the option 1 is better, but with option 2 we pretty much guarantee that all product informations have the last update from database, because the owner might change the product price milliseconds after you just clicked.

image describing user interaction

image describing user interaction

Md. Yeasin Sheikh
  • 54,221
  • 7
  • 29
  • 56

1 Answers1

0

I would go for the second option most of the time.

As you already said, the information will always be up to date. Also if you request all the products with all of their information it creates quite some overhead, depending on the size of the product page and the information about the different products. Another thing is updating the information live. Maybe you'll decide to add a Stream later on, updating the information while the user is on the product page. Querying each product will make that easier as well.

If you can afford the resources of requesting the product every time and your process isn't too expensive it's in my opinion the better option.

Lee Taylor
  • 7,761
  • 16
  • 33
  • 49
NicoFoth
  • 11
  • 2