[Catalyst] Program the logic

Eden Cardim edencardim at gmail.com
Thu Jun 29 13:41:51 CEST 2006


On 6/28/06, Eduardo Oliveros <eduardo.oliveros at gmail.com> wrote:

> 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, no, the MVC pattern is actually just a specialized Adapter
pattern so you can program your Views and Models independently without
having to conform the Application and its Presentation to a specific
interface. In Web Development that basically means web designers can
work without having to know any gory details of the application logic
and technology, and vice-versa. This reduces the development effort
enormously IMHO.

> 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).

Catalyst is very flexible, you can put your mapped DB classes wherever
you want, you could even have a View that's mapped to a database that
stores your templates or even your application data if you want. You
could program your application logic directly inside Controller
Actions if you wish. You'll have trouble maintaining your code later,
but that's not Catalyst's fault.

> Anyway, the question is just what is the best practice to program the
> logic and test it before link the logic with the web application?.
> (using the classes generated by the Class::DBI or whatever plugin).

I'd stick to the fundamental OO Pattern theory: program to interfaces
not implementations. Personally, I have my Controller actions call
operations from a Model class interface and my aplication logic stays
in the Model, behind the interfaces I defined. That way, I can test
the aplication logic independently with unit tests and later on, run
integration tests by mocking context objects.



More information about the Catalyst mailing list