In most other Object Oriented languages. it would be sacrilege to have each function receive a single associative array of Objects rather than enumerating each in the method signature. Why though, is it acceptable and commonly used in most popular frameworks for both of these languages to do this?
Is there some justification beyond wishing to have concise method signatures?
I do see a benefit in this — that the API could remain unchanged as new, optional parameters are added. But Javascript and PHP already allow for optional parameters in their method signatures. If anything, it seems like Java or another OO language would benefit from this more… and yet I rarely see this pattern there.
What gives?
The major reason is that those particular languages simply do not support having multiple calling conventions for the same function name. I.E. you can’t do the following:
So you must find another way to create simpler ways to pass your variables around, in PHP we end up with
someFunc(array('some'=>$some, 'another'=>$another))because it is the only convenient way. In JavaScript we end up using objects, which isn’t as bad:someFunc({some: something, another: anotherthing})