Create new variable or make multiple chained calls?
- by Rodrigo
What is the best way to get this attributes, thinking in performance and code quality?
Using chained calls:
name = this.product.getStock().getItems().get(index).getName();
id = this.product.getStock().getItems().get(index).getId();
Creating new variable:
final item = this.product.getStock().getItems().get(index);
name = item.getName();
it = item.getId();
I prefer the second way, to let the code cleaner. But I would like to see some opinions about it.
Thank you!