[Dbix-class] Search_rs not returning newly created rows

Len Jaffe lenjaffe at jaffesystems.com
Wed Jun 20 16:40:10 GMT 2012


On Wed, Jun 20, 2012 at 12:06 PM, Benjamin Hitz <hitz at stanford.edu> wrote:

> Not to get in the way here... but I think (not a Dbix::Class/Catalyst
> expert) that Len is saying that:
> putting {accounts =3D> $rs and pager =3D> $rs->pager()}in the stash is
> effectively forcing the template system to make DB calls.  It has to be
> even though Kenneth didn't actually post his template code.
>
That was my well reasoned conclusion :-)


> At first I thought it was just the pager, but I re-read and saw the $rs
> itself was passed.
> But I am not posting this just to pile on (and in fact, I could well be
> wrong -- or correct materially but wrong in details)... but I want to ask
> Len:
> What is bad about this design?   Especially in a case where the pager
> (possibly not this one) has to fetch pages?
> Is the (your) preferred design pattern to put any UI fetches behind a
> webservice/ajax call?
>

Controller uses the model to manipulate and retrieve all the data,  crams
it into the stash, and hands the stash to the the view for presentation to
the end user.

While it feels cleaner to gram a result set and iterate over it in the
template, it totally violates MVC. View is for presentation, Model is about
the data and business logic.

While I've been know to violate this convention once or twice myself, I
think that retrieve multiple related records for each master record, in the
view, is the kind of violation that will cause maintenance nightmares.
 Since code spends 80-90 percent of its life in maintenance mode, coding
for maintainability is a key goal of mine (again, I fall off that horse
occasionally -- all things in moderation).

Experience is why I say I dislike the idea of doing it that way.  It will
certainly work. It might event be faster to develop that way, because you
won't have to retrieve all the data ahead of time, and structure it so that
the view can access it efficiently.

I have similar conversations with folks I know who are new to application
maintenance, and who are doing the same thing with
Rails/ActiveRecord/HAML/ERB.

Pager: pagers should not be retrieving rows, they should be calculating
which rowset parameters to send to the controller to get the new records
they want.

L.
-- =

lenjaffe at jaffesystems.com   614-404-4214             www.volunteerable.net
Proprietor: http://www.theycomewithcheese.com/ - An Homage to Fromage
Greenbar <http://www.greenbartraining.org/>: Grubmaster: 2012-2009, Grub
Asst: 2008, Trained: 2007.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/dbix-class/attachments/20120620/70d=
abef2/attachment.htm


More information about the DBIx-Class mailing list