14 ms·
Postgres has a built in function that converts strings into lowercase. Why not use that? This seems like an extremely convoluted way of performing the example t
by colonwqbang 3y ago
Postgres has a built in function that converts strings into lowercase. Why not use that? This seems like an extremely convoluted way of performing the example task.
One could suppose that it's just a contrived simple example to show the point, but the headline suggests otherwise.
- stevebmark 3y agoThe best part is the map that not only mutates its own arguments, but also mutates the arguments to the function, which all is in a "service" which has to be instantiated and then "called." I really wish the Rails community would pick up best practices from other languages.
- Toutouxc 3y agoThis. I think that the Rails community is slowly forgetting how to actually write Ruby, and reinventing known and tried OOP patterns using as little OOP as possible — in a purely object-oriented language! I’m working on a codebase where someone had the amazing idea to implement some of the multi-model business logic using the “Interactor” gem. I’ve just spent two days rewriting one of these interactor abominations into a simple 250 LOC module of module_function-ed methods with clear dependencies and data flow, as a temporary solution to be able to see what’s even happening there and build some actual domain models from it. I can’t imagine anyone with some CS background and a bit of experience with other languages to look at the interactor stuff and go: omg this is perfect, exactly what this codebase needs. It’s like a normal Ruby class but it: - hides all instance variables into an opaque “context” bag - has methods which don’t take arguments (they reach into the “context” bag instead) - has methods that don’t have return values (side effects go into the “context” bag) - has no constructor and just chucks everything you pass to #new into the “context” bag - is not understood by RubyMine, arguably the most intelligent Ruby IDE, at all