0

For the sake of brevity and easier refactoring, I feel like I shouldn't have method calls spanning 2 lines of code just because their signature contains 10+ arguments. I feel like I should wrap them in an object.

Is that a bad idea to do in a ASP.NET Core HTTP GET action method?

We are talking about an endpoint, accepting simple parameters (of type int, string etc). No collections, arrays, or anything complicated like that.

Is there a better approach to this problem?

SpiritBob
  • 2,355
  • 3
  • 24
  • 62
  • If the the arguments are related and it makes sense to put them into a class: yes. Otherwise no ? Or why does the method take so many arguments, split it into multiple methods. – nanu_nana Jun 24 '20 at 11:32
  • I have also passed the parameters in the body also in GET request – Vivek Nuna Jun 24 '20 at 11:35
  • @viveknuna passing a body in a GET request is forbidden. You should even get an error I believe? (Not at compile time, but when making the request) – SpiritBob Jun 24 '20 at 11:36
  • @nanu_nana because it's an endpoint? I can't just split an endpoint in two. – SpiritBob Jun 24 '20 at 11:37
  • @SpiritBob it is still allowed. PostMan also allows it to send HTTP request with body – Vivek Nuna Jun 24 '20 at 11:40
  • @viveknuna woah, you are correct! I wonder why, specs suggest against doing that sort of thing. Context: https://stackoverflow.com/a/983458/11272124 – SpiritBob Jun 24 '20 at 11:45

0 Answers0