I have written a PHP application that uses Objects heavily. Added, deleting, updating etc.. rows in my database. I want it to conform to a easy to read standard for future developers and the possibility of open sourcing the code. Which is easier for you? Assume variables are public.
$tablename = new tablenameClass;
result= $tablename->addrow($POST,$AdditionalStuff,$Settings);
or using the object
$tablename = new tablenameClass;
$tablename->AdditionalStuff = array(whatever);
$tablename->Settings = array(settings);
result= $tablename->addrow($POST);
So this question is more about convention then anything else. Sorry I know the code is broken.
I really like the way jQuery does it.
tablename(array({
thing:stuff,
thing2:stuff2
}));
The 2nd example is much easier to read and understand…
AdditionalStuffandSettingsare defined right there.The 2nd example also seems to fall in line with high cohesion as you have members supporting a well-focused role and/or responsibility.
Your 1st example has a method that accepts multiple arguments, which isn’t necessarily bad, but in the 2nd example, this same method is reduced to only needing one argument which seems to promote more cohesion in the method.