Multiple parameters vs single parameter(object with multiple properties)
- by Shwetanka
I have an Entity Student with following properties - (name, joinedOn, birthday, age, batch, etc.) and a function fetchStudents(<params>).
I want to fetch students based on multiple filters.
In my method I have two ways to pass filters.
Pass all filters as params to the method
Make a class StudentCriteria with filters as fields and then pass
the object of this class
While working in java I always go with the second option but recently I'm working in php and I was advised to go with the first way. I am unable to figure out which way is better in maintaining the code, reusability and performance wise. Thanks.