3 ms·
You should submit a pull request. In fairness, some RPC web frameworks do this in a completely non-ironic non-joke way. CakePHP "findBy" comes to mind.[1] [1]
by throwaway2016a 8y ago
You should submit a pull request.
In fairness, some RPC web frameworks do this in a completely non-ironic non-joke way. CakePHP "findBy" comes to mind.[1]
[1] https://book.cakephp.org/2.0/en/models/retrieving-your-data.html#findby https://book.cakephp.org/2.0/en/models/retrieving-your-data....
- twic 8y agoAlso Java's Spring Data: https://docs.spring.io/spring-data/commons/docs/current/reference/html/#repositories.query-methods.query-creation https://docs.spring.io/spring-data/commons/docs/current/refe... Wasn't it an ActiveRecord thing to begin with? Spring got a lot of its more recent awful features by trying to copy Rails.
- diroussel 8y agoYeah in general this approach is based on ActiveRecord from Ruby On Rails. But in Ruby it's based on method_missing not a proxy. I believe ruby got it's method_missing idea from Smalltalk. But there might be other precursors.
- DFHippie 8y agoPerl for one: http://perldoc.perl.org/perlsub.html#Autoloading http://perldoc.perl.org/perlsub.html#Autoloading
- jon-wood 8y agoAnd somewhat ironically Rails deprecated the particularly magical features like `find_by_name("Bob")` aliases in favour of saner variants like `find_by(name: "Bob")`.
- always_good 8y agoWhat a great change. It always seemed ridiculous to put the lookup key and lookup value in two different places. Nice to see Rails reconsider these things I once thought it would never surrender.
- bobbyi_settv 8y agoRuby didn't have keyword arguments when they came up with the initial approach.
- always_good 8y agoThat's not why they did it. For example, they could've used maps: find_by name: "foo"
- tenaciousDaniel 8y agoAlso the Grails ORM, but that's probably taken from Rails as well. I actually really liked it back when I was using it. Is there a good argument why automated function synthesis is a bad thing? Not trying to argue, just curious.
- jestar_jokin 8y agoIt's not type safe, so if you change a property name it's not going to be picked up at compile time, so you'd better have tests in place for every synthesised function. (Of course, most implementations are made in dynamically typed host languages, which have this problem with every line of code.) It's also just a limited DSL that has none of the capabilities of the host language, and can't be used to express e.g. complex queries.