|
|
|
|
|
by ryanto
4454 days ago
|
|
I think it is unfair to single Ruby out here and call it a "flaw". What you are describing is just bad code/design that can exist in any language. Also, as far as Ruby is concerned your class's external API is only made up of methods. There are no attributes, model.foo is always a method. Because of this your long running or resource intensive methods need to be documented or have clear names if you are exposing them as public API. In other words: Model.foo shouldn't take 30seconds, but maybe Model.download_foo will. |
|
Actually the problem he is describing is a consequence of language design, not of architecture design.
In Javascript, if I write foo.bar, I know that it is accessing some field of the foo object, and that's it. Unfortunately we're going to get a bunch of stuff in ES6 that's going to change this, but the fact that we can have some invariants (especially in a dynamic language like Ruby) on property accessors is pretty important when trying to reason about performance.
The fact that Ruby only exposes methods is a language design decision that can enable some pretty bad architectural decisions.
Language features are about tradeoffs .For example, among other things, the calling syntax for ruby means that point-free functional programming is pretty much impossible (though there are possible language-level solutions for this). Depending on what you're looking for, that can be considered a flaw , because it deviates from your personal definition of the ideal programming environment.