[Catalyst] Program the logic

John Napiorkowski jjn1056 at yahoo.com
Thu Jun 29 12:20:34 CEST 2006


This response is probably OFFTOPIC at this point, but maybes it's a good type of discussion for our community to have, if we can all be civil about it.  Personally I think there are several points of view with the best way to do MVC.  MVC, like quite a few programming paradigms offers a simple idea but translating that into real life can be hard.  So there are lots of points of view.  I think a lot of applications tend to underplay the role of Model because programmers have an easier time understanding the Controller.  I think most of the simple demo style apps for catalyst tend to have a lot in the Controller because it's easier to get someone started who is used to writing monolythic cgi type applications.   Personally I put all the logic having to do with manipulating the database into my model class.  So things like adding/removing users or very common searches I put there.  Anything that more than a single controller might want I put in the Model.  

IMHO this best thing to do is choose a set of best practices that reflect the way you write code and also match the project and just try to stick with it.  I think the best practice style for Catalyst is still something developing.  Sometimes it makes sense to create a lot of stored procedures in the database while other times it doesn't.  I've actually been involved in huge projects that were totally written in Oracle PL/SQL.  Sounds messy and looks messy but it worked.  MVC is just a thing we made up, it's not some reality we need to discover the one true path on.  At least that's how I see it.

-john

----- Original Message ----
From: Zbigniew Lukasiak <zzbbyy at gmail.com>
To: The elegant MVC web framework <catalyst at lists.rawmode.org>
Sent: Thursday, June 29, 2006 3:37:58 PM
Subject: Re: [Catalyst] Program the logic

I dont' agree with the statement that all the application logic should go into the Controller.  In my opinion in the Controller you should have only the code that is directly web related - all the rest should go into the Model.  This way you can call your business logic from a cron script without the overhead of all the web stuff. 

--
Zbyszek

On 6/28/06, Nilson Santos Figueiredo Junior <acid06 at gmail.com> wrote: On 6/28/06, Eduardo Oliveros <eduardo.oliveros at gmail.com> wrote:
> I'm planning to program the logic of the application (the Model in
> MVC) previously to start with web page and the presentation. 

Actually, the Controller is what is supposed to drive the logic of the
application. The model is really just that: the model. It's usually
mapped to some kind of storage engine such as a RDBMS. Many strong
 advocates of MVC specifically try to leave business logic out of the
database.

> What I see is that what Catalyst calls Model is just the Objects that
> map with the tables in the DDBB. And the logic of the application are 
> developed in the Actions (in fact linked to the web application).

You'll see that it's "a little" more than that (at least when you're
using DBIx::Class - Class::DBI can't even be compared feature-wise 
nowadays).

> I know is difficult in practice to separate both worlds (logic from
> the presentation) but that is the false promise of the MVC pattern :).

Not really. It's something somewhat straight-forward when using 
something like Catalyst. All you've got to do is resist the temptation
of polluting your controllers with things that really should be in
your views. But sometimes it's even worth it.

-Nilson Santos F. Jr. 

_______________________________________________
List: Catalyst at lists.rawmode.org
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst 
Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/
Dev site: http://dev.catalyst.perl.org/ 




-- 
Zbigniew Lukasiak
http://brudnopis.blogspot.com/_______________________________________________
List: Catalyst at lists.rawmode.org
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/
Dev site: http://dev.catalyst.perl.org/




-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.rawmode.org/pipermail/catalyst/attachments/20060629/3452b3bf/attachment.htm 


More information about the Catalyst mailing list