|
|
|
|
|
by lucaspiller
5104 days ago
|
|
It's an interesting article, but I'm not really sure this is the best approach. In terms of having the 'best' code that is 100% OO then sure, but in terms of actually having usable, understandable, code I'm not sure I agree. If you return a Hash of attributes everyone knows how a Hash works, but if you return a custom Attributes object people have to learn how it works, there could be bugs, etc. |
|
oh and since it's an enumerable it's easy to work with it just like with a hash.
I'm also not saying you should never ever use primitive objects because that would be silly :) The trick is to determine when it is better to use a custom class instead of misusing existing primitive ones. Hash is a good example in Ruby, people use it way too often.