Suppose I have a custom object, Student:
public class Student{
public int _id;
public String name;
public int age;
public float score;
}
And a class, Window, that is used to show information of a Student:
public class Window{
public void showInfo(Student student);
}
It looks quite normal, but I found Window is not quite easy to test individually, because it needs a real Student object to call the function. So I try to modify showInfo so that it does not accept a Student object directly:
public void showInfo(int _id, String name, int age, float score);
so that it is easier to test Window individually:
showInfo(123, "abc", 45, 6.7);
But I found the modified version has another problems:
Modify Student (e.g.:add new properties) requires modifying the method-signature of showInfo
If Student had many properties, the method-signature of Student would be very long.
So, using custom objects as parameter or accept each property in objects as parameter, which one is more maintainable?