[Catalyst] Making a hash available across the application

Alexander Hartmaier alexander.hartmaier at t-systems.at
Thu Mar 18 08:50:57 GMT 2010


Am Donnerstag, den 18.03.2010, 00:08 +0100 schrieb Tomas Doran:
>
> In fact, generally - you don't want to be calling the generic ->search
> method in your controllers _at all_.
>
> The specific search functionality should instead be pushed down into
> your ResultSet classes, so that you say:
>
> $c->model('DB::Books')->find_all_books_by_author($author_name);
>
> Rather than $c->model('DB::Books')-
>  >search({ %stuff_including_author_name }, { %ordering_stuff });
>
> The former is your controller declaratively asking the domain model
> for what it wants. The latter is for controller manipulating the
> domain model directly by having knowledge of it's implementation.
>
> Which tables you join (and how you join / sort / order / filter them)
> to get a set of data _IS NOT_ something controller code should know or
> care about, as that takes away your ability to alter the data
> representation (e.g. changing the table structure) without changing
> every place that knows about that representation...
>
> When you need to change your schema (and this will happen!), then only
> having to change the implementation details in the model is
> significantly less work (and testing), especially when you have dozens
> of controllers!
>
> Cheers
> t0m
>

We should add that somewhere at the very top of some DBIC doc!

( no, I don't wanna hear a 'well volunteered' this time! )

--
Best regards, Alex


*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*
T-Systems Austria GesmbH   Rennweg 97-99, 1030 Wien
Handelsgericht Wien, FN 79340b
*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*
Notice: This e-mail contains information that is confidential and may be privileged.
If you are not the intended recipient, please notify the sender and then
delete this e-mail immediately.
*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*



More information about the Catalyst mailing list