What are the advantages/disadvantages of using objects as parameters to
other object methods?
I'm mostly thinking of PHP here, but if you want to refer to other
languages that's fine.
An object has a method that requires data contained in another class of
object.
Should I extract that data from the other object into a variable and then
send just that data to the requesting object?
Or should I pass the entire data-containing object into the data-requiring
object, and then have the requesting object perform the data extraction
operations?
I'm asking because I'm working on a big project that I've written 100% of
the code for, and some of my early code takes string or numeric arguments,
but my later code seems to be leaning toward passing around objects. As I
bump into some old code, I'm wondering if I should convert it to object
parameters.
No comments:
Post a Comment