4 ms·
This is exacerbated by ruby's tendencies towards "fluent" interfaces, which is actually code for lots of methods that take undocumented hashes of
by JohnBooty 2y ago
This is exacerbated by ruby's tendencies towards
"fluent" interfaces, which is actually code for
lots of methods that take undocumented hashes of
arguments
Well, I hate this too. I've been away from Ruby for 18 months but my impression was that the community has been moving away from that for a long time and toward keyword args (or whatever they're called, I forget)
and hash access with strings and symbols? nightmare fuel.
What's the alternative? I like hash access with symbols. Prevents typos and the string values for the hashes are interned AFAIK.
After running a number of rails applications in production
for going on a decade, this is really hard,
I don't feel that Ruby is worse than other languages I've used extensively (Ruby, Python, JS, C#) in this regard.
The issue is one's apps dependency graph. You keep dependencies flowing in one direction. Or you do not and you get spaghetti. I have not worked with languages that are really better or worse at this.
To take the example of a typical Rails app: it's very easy to add code to your Model A that depends on Models B, C, and D. Do that in a few models and...boom! spaghetti! Rails does not discourage or warn about this in the slightest.
It's relatively easy to avoid: have a rule that "no model can contain a reference to another model. if you have to do a thing that involves two models, put it in a service class" or some such. Of course, nobody ever does this.
Are there languages and frameworks that encourage/enforce The Right Thing in a more active way?
- wkirby 2y ago> Are there languages and frameworks that encourage/enforce The Right Thing in a more active way? I don't think so, as evidenced by the fact that I'm still so pro Rails after a decade of doing this. But that doesn't mean we can't be vocal about the things that still suck. > I like hash access with symbols Oh, I vastly prefer symbol access to string access, but this is really a ruby problem, not a rails problem. The fact that I can pass `{ "foo" => "bar" }` and `{ foo: "bar" }`, and my method has to either call `with_indifferent_access` or _strictly_ enforce being called with one of the two access types is a huge footgun, because improper access doesn't result in an error, it just results in a `nil`.