I'm fairly new to C# and programming in general, hence why I'm asking this question.
I recently got my code reviewed by a colleague, and he stated that for the following method, I should use a class for some parameters.
public List<Items> DoSomething(List<OtherItems> someItems, int amountOfItems,
DbGeopgrahpy Location)
{ //More stuff, irrelevant to the question.
He pointed out that I should put the amountOfItems
and Location
in a class which would contain those values instead.
This method will be called from a controller which returns this data to the client.
Now my question is why? I understand that it would improve readability (arguably imo), but is there any benefits to using classes as parameters? I think I can assume this would even impact performance negatively when you have to declare a class each time you want to call this method.
I also found that structs can be used this way, if this is a good practice, when should I use structs and when should I use classes?