Wednesday, May 16, 2012

Is it better to pass reference to an object or pass individual attributes in an object in Java?

I'm dealing with legacy code and I constantly see method calls with multiple attributes from the same object being passed into a method:



update(user.getID(), user.getLanguage() etc...)


Is there a distinct advantage or disadvantage to doing it this way or would I just be as well to pass in the user object (in this case) and deal with attributes within the method called?



Cheers,



Alexei Blue.





No comments:

Post a Comment