News for hackers. Stuff that matters.
Re:I Love Ruby by pqdbr on Monday December 18, 2023 @05:28PM (#38689295)
In my experience this is almost never the case. #supports_feature? would be defined right there where you'd expect - in that Subscription model.

Even tough you can reach for metaprogramming (like define_method or method_missing), that's really not how the entire ecosystem of guides and tutorials will point you.

Anyways, when in doubt, just plug a debugger and call "@subscription.method(:supports_feature?).source_location`, and generally that's all it takes.

Re:I Love Ruby by Fire-Dragon-DoL on Monday December 18, 2023 @07:17PM (#38690202)
The most common framework in ruby disagrees. It wiuld be 5 layers deep
Re:I Love Ruby by rezonant on Tuesday December 19, 2023 @06:07AM (#38694184)
Well, it would probably be 2-3 layers deep in a concern, really. Concerns are just fancy modules, and modules are just reusable parts of a class. In Rails basically everything is a concern. To a concerning degree actually, as a professional Rails developer of many years, I think they went way overboard with it. My team and I also curse it's single minded design when we have to drill down there. Thankfully that's a pretty rare thing to have to do.

As for the abstraction, Rails does take it pretty far, but you also have to take into account that it's a framework that supports numerous pluggable strategies and disparate backends, and extensibility. I think most mature frameworks are pretty complex-- the goal of the framework is that it's all encapsulated away from you for the vast majority of tasks, and in Rails, that is extremely true.

Re:I Love Ruby by mplewis on Monday December 18, 2023 @05:55PM (#38689561)
Rails is the biggest Ruby project and it’s heavily based on metaprogramming. Even Rubymine has trouble finding the canonical definition of a named method sometimes – it has to guess. I love Ruby but I totally understand this criticism.
Re:I Love Ruby by sodapopcan on Tuesday December 19, 2023 @08:17AM (#38695139)
Rails is a library, though, the advice applies to application/business code. Metaprogramming is extremely useful for making really simple-to-use libraries. If your business logic is full of metaprogramming, that's more of a problem, especially in this day of age where it's common for developers are only sticking around at any given job for 2 to 3 years.