2 ms·
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 ac
by lucaspiller 14y 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.
- solnic 14y agoWe needed a set-like data structure with enumerable interface that would also know how to handle attributes from parent classes. That's why a custom object worked better. 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.
- sirfried 14y agoreminds me of json builder in ruby, yikes!