3 ms·
You had me until > more readable Without having more context, User in your code is possibly an ActiveRecord class, so to read the #select, you have to conside
by gkop 4y ago
You had me until
> more readable
Without having more context, User in your code is possibly an ActiveRecord class, so to read the #select, you have to consider that it could be radically different and heavier than Enumerable#select (eg. it may execute a DB query as a side effect). So I like your example still, because it’s representative, and certainly expressive, but not readable per se. IMO this sin here is simply that ActiveRecord shouldn’t have overloaded select.
- bin_bash 4y agoThat’s more of an argument against ORMs which I realize my example used. I was mostly trying to convey using map/filter against POROs though. Using an ORM was a poor choice on my part. I agree the magic there does harm readability since it makes it a lot harder to understand what it really is doing.