Multiple parameters vs single parameter(object with multiple properties)

Posted by Shwetanka on Programmers See other posts from Programmers or by Shwetanka
Published on 2012-12-09T18:12:54Z Indexed on 2012/12/09 23:42 UTC
Read the original article Hit count: 121

Filed under:
|

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.

  1. Pass all filters as params to the method
  2. 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.

© Programmers or respective owner

Related posts about php

Related posts about programming-practices