From: Ryan Pavlik Date: 2004-01-09T19:11:04+09:00 Subject: Re: Query syntax in O-R mapping (was: Database applications and OOness) On Fri, 9 Jan 2004 13:41:44 +0900 sera@fhwang.net (Francis Hwang) wrote: > Here's my concern: Seems to me than when you have a syntax that > looks _sort of_ like normal Ruby, but is different in all these tiny > subtle ways, using it might involve a lot of "mental housekeeping" > about why things work and don't work. In particular, the idea of > teaching a moderately skilled programmer how to use Criteria is > pretty daunting. Well, for me, it comes down to Criteria---albeit not perfect, especially in the ways you mentioned---being better than embedding SQL text into Ruby. Secondly, it's an abstraction, which means primarily it doesn't necessarily generate SQL, which is useful (at least in theory). > Is this not a problem for Criteria users? Am I just worrying too > much? Of course "it's less bad" doesn't answer your question. I'd say you only need to be especially aware of 2 things to use Criteria: 1) Method operators (&, |, etc) vs syntax operators (&&, ||, etc) 2) Operator precedence The latter isn't really so much of an issue either, at least for me... I tend to explicitly specify parens anyway, just because I like the way it looks on the screen. This isn't to say Criteria isn't tricky. To be honest, because of the way it wraps back into the language, there are a lot of weird things that you can do, and a lot of things that happen "magically". I don't think anyone has to wrap their head around the whole thing to use it, though. (At least, I hope not, because I use it, and I don't always see all the possibilities. ;) I can't come up with a better way to integrate abstract query notation, though. I've tried other various things and they're all uglier. That's not to say someone smarter can't come up with something simpler and more flexible. They just need to implement it for us. ;-) -- Ryan Pavlik "You mean easily pawned valuable crystal orb thingie." - 8BT