The benefits you achieve by using this technique vary, as always, based on your personal situation. If you are working on a method whose parameter list is lengthy and wildly unstable, in a framework that is intended to be used by others, it will likely lower overall costs if you specify arguments in a hash. However, if you are writing a method for your own use that multiplies two numbers, it’s far simpler and perhaps ultimately cheaper to merely pass the arguments and accept the dependency on order.
- Chapter 3. Managing Dependencies
- from Practical Object-Oriented Design in Ruby: An Agile Primer
- Publisher: Addison-Wesley Professional
- Released: September 2012
Use the hash argument appropriately. If there are a large number or unstable list of arguments then pass a hash. Otherwise, if the argument list is short/simple or stable then pass them in a specific order and no harm will be done. Use your judgement.
Share this highlighthttp://www.safaribooksonline.com/a/practical-object-oriented-design/3550/