Login | Register
My pages Projects Community openCollabNet

Discussions > dev > [propel-dev] Re: [creole-dev] Criteria and Criterion design issues

propel
Discussion topic

Back to topic list

[propel-dev] Re: [creole-dev] Criteria and Criterion design issues

Reply

Author hlellelid
Full name Hans Lellelid
Date 2004-06-14 04:36:04 PDT
Message Hi Bryan,

> I finally got a chance to dive into the internals of Propel today.
> One thing I noticed is that the Criteria class is not very well defined.

Cool :) Welcome to Propel. I'm replying to this message & sending a
copy the Propel dev list, as Criteria/Criterion is pretty Propel
specific stuff. Of course Propel & Creole are quite related, so I doubt
anyone is saying "Criteria? What the %^&# is that?". :)

> Logically, I think the criteria class should define a set of rows from
> a table. Joins, sorting rules, and select columns all seem like they
> belong somewhere else. The fact that the criteria class contains
> those functions, yet they are not relevant when using criteria for
> UPDATE queries, is a bad code small IMHO.

The great thing about porting software is that you can always blame the
original product for design flaws. I'm not sure I would go so far as to
call Criteria/Criterion a design flaw yet, but it certainly has it's
cumbersome aspects.

Yes, for instance, it is a little akward that one system is used for
updates and for performing SELECT queries. I would say that Criteria is
designed for SELECT queries & in its simplest form just so happened to
be an appropriate containers for storing update values too. In the
latter case it just a collection class, and we could easily use a simple
assoc array in its place. Moving to a system where Criteria is only
used for SELECT queries would probably be more efficient -- and I doubt
it would break anyone's code.

Anyone [reading this] using Criteria values directly to generated
doUpdate() / doDelete() / doInsert() methods?

> Is there any flexibility we would have to loose by defining a criteria
> as the rules to get a set of rows in -one- table, and then having a
> select query would hold one criteria object for each table to be
> selected from and join information? Update queries could use the
> criteria without any extra baggage.
>
Well, there's a lot of flexibility built-in to the current Propel that
is not documented or particularly encouraged. For example the BasePeer
methods can all be used directly to perform table manip operations by
creating custom Criteria and passing them in. I think that in the
original Propel design there was a fear of having the templates build
too much logic. The generated peer classes do not perform the actual
queries; BasePeer does this.

That said, I can't think of any reason why we wouldn't want to have
templates build Criteria subclasses for each table.

> Also, the criteria/criterion relationship seems quite confusing. I
> propose dropping the idea of a criterion, and making the criteria an
> instance of the GoF composite pattern.

Well, from my [rather basic] understanding of the composite pattern, it
seems like that what Criteria/Criterion is. Criteria being the
composite class and the Criterion being the "leaf" class ... ? How
would you envision changing this relationship to better embody that pattern?

Criteria/Criterion is complicated, though. I've tackled a redesign at
several times, but generally only dug in to realize "oh, that's why they
did it that way" and so far haven't really wrapped my head around the
"right" solution. Being able to represent nested logical relationships
is the challenge. It can get clumsy in Criteria, but that's mostly
because Criteria has convenience methods like addAnd(), addOr() that are
a little misleading when it comes to actually joining columns together.
The logical inter-relationships are all stored in Criterion; Criteria is
just a dumb collection of those object, so having the addAnd()/addOr()
methods in Criteria is only for convenience.

Anyway, I don't know if that clears it up at all. I'm certainly not
opposed to making changes that fix some design issues in the current
system. It seems like cleaning up the dual-purpose nature of Criteria
is a good one. I'm curious to know whether people are actually using
Criteria objects for queries. These types of changes may need to wait
for a 1.1 release, but we can always branch (create 1_0) sourcecode when
we're ready to introduce some significant design changes.

Hans

--------------------​--------------------​--------------------​---------
To unsubscribe, e-mail: dev-unsubscribe@prop​el.tigris.org
For additional commands, e-mail: dev-help at propel dot tigris dot org

« Previous message in topic | 1 of 45 | Next message in topic »

Messages

Show all messages in topic

[propel-dev] Re: [creole-dev] Criteria and Criterion design issues hlellelid Hans Lellelid 2004-06-14 04:36:04 PDT
     Re: [propel-dev] Re: [creole-dev] Criteria and Criterion design issues Ross Shaull <ross at simanage dot com> Ross Shaull <ross at simanage dot com> 2004-06-14 07:53:46 PDT
         Re: [propel-dev] Re: [creole-dev] Criteria and Criterion design issues hlellelid Hans Lellelid 2004-06-14 16:34:15 PDT
             Re: [propel-dev] Re: [creole-dev] Criteria and Criterion design issues Ross Shaull <ross at simanage dot com> Ross Shaull <ross at simanage dot com> 2004-06-14 16:59:45 PDT
                 [propel-dev] Re: [creole-dev] Criteria and Criterion design issues hlellelid Hans Lellelid 2004-06-14 20:40:00 PDT
                     Re: [propel-dev] Re: [creole-dev] Criteria and Criterion design issues bhelmkamp Bryan Helmkamp 2004-06-14 20:56:59 PDT
                         [propel-dev] Re: [creole-dev] Criteria and Criterion design issues hlellelid Hans Lellelid 2004-06-14 21:18:42 PDT
                             Re: [propel-dev] Re: [creole-dev] Criteria and Criterion design issues bhelmkamp Bryan Helmkamp 2004-06-14 21:29:03 PDT
             Re: [propel-dev] Re: [creole-dev] Criteria and Criterion design issues hlellelid Hans Lellelid 2004-06-14 18:04:40 PDT
             Re: [propel-dev] Re: [creole-dev] Criteria and Criterion design issues bhelmkamp Bryan Helmkamp 2004-06-14 19:25:38 PDT
     [propel-dev] Re: [creole-dev] Criteria and Criterion design issues hlellelid Hans Lellelid 2004-06-14 11:59:11 PDT
         [propel-dev] Re: [creole-dev] Criteria and Criterion design issues bhelmkamp Bryan Helmkamp 2004-06-14 13:38:48 PDT
             Re: [propel-dev] Re: [creole-dev] Criteria and Criterion design issues bhelmkamp Bryan Helmkamp 2004-06-14 14:01:41 PDT
                 Re: [propel-dev] Re: [creole-dev] Criteria and Criterion design issues hlellelid Hans Lellelid 2004-06-14 16:23:21 PDT
                     Re: [propel-dev] Re: [creole-dev] Criteria and Criterion design issues bhelmkamp Bryan Helmkamp 2004-06-14 17:46:16 PDT
                         [propel-dev] Re: [creole-dev] Criteria and Criterion design issues hlellelid Hans Lellelid 2004-06-14 19:09:46 PDT
                             Re: [propel-dev] Re: [creole-dev] Criteria and Criterion design issues bhelmkamp Bryan Helmkamp 2004-06-14 19:40:04 PDT
                                 Re: [propel-dev] Re: [creole-dev] Criteria and Criterion design issues bhelmkamp Bryan Helmkamp 2004-06-14 20:02:59 PDT
                                     [propel-dev] Re: [creole-dev] Criteria and Criterion design issues hlellelid Hans Lellelid 2004-06-14 20:17:51 PDT
                                         Re: [propel-dev] Re: [creole-dev] Criteria and Criterion design issues bhelmkamp Bryan Helmkamp 2004-06-14 20:22:37 PDT
                                             [propel-dev] Re: [creole-dev] Criteria and Criterion design issues hlellelid Hans Lellelid 2004-06-14 20:49:42 PDT
                                 [propel-dev] Re: [creole-dev] Criteria and Criterion design issues hlellelid Hans Lellelid 2004-06-14 20:07:11 PDT
                                     Re: [propel-dev] Re: [creole-dev] Criteria and Criterion design issues bhelmkamp Bryan Helmkamp 2004-06-14 20:16:12 PDT
                                         [propel-dev] Re: [creole-dev] Criteria and Criterion design issues hlellelid Hans Lellelid 2004-06-14 20:28:08 PDT
                                             Re: [propel-dev] Re: [creole-dev] Criteria and Criterion design issues bhelmkamp Bryan Helmkamp 2004-06-14 20:45:37 PDT
Page: of 2 « Previous | Next »
Messages per page: