javserlah / qforce

QForce
0 stars 0 forks source link

Why using two approaches to return data from endpoints. #3

Closed marceloverdijk closed 6 years ago

marceloverdijk commented 6 years ago

Why is

https://github.com/javserlah/qforce/blob/4f75e51011e43ba3d84e3c04ad4fe240e200952d/src/main/java/nl/qnh/qforce/controller/QForceController.java#L31

returning a List<Person>.

And

https://github.com/javserlah/qforce/blob/4f75e51011e43ba3d84e3c04ad4fe240e200952d/src/main/java/nl/qnh/qforce/controller/QForceController.java#L43

returning ResponseEntity<Person>.

What is rationale to use two different approaches? One returning normal Java objects and the other one using ResponseEntity. Don't you think it would be better for consistency to use the ResponseEntity in both methods?

javserlah commented 6 years ago

Yes, you are right, is much better to standarize both of them in the same way. I just tried to show different ways of returning data. I personally think that the second approach is much better as it gives you more flexibility when returning data, I used it in the second case for returning different status codes.

marceloverdijk commented 6 years ago

Yes I agree the second approach is much more flexible.