Over the last few months I have been working with Symfony and have got used to passing values to methods via an options array but I have recently had to pick up an older project in which the values are passed to the methods by individual parameters.
This has given me a good opportunity to evaluate both techniques and determine my personal preference for working.
The more traditional technique is to pass values to methods using individual parameters as in the example below:-
public function someMethod($name, $age = null) { // do something }
The benefit I have found with this method is that you can clearly identify what needs to be passed to the method, however, if you need to change the method to include an additional parameter it means that you have to update every call to this method so that every parameter is specified.
continue reading…