Jeff AA wrote:
> do you use any standards for the data being
> returned to the Controller? eg do you use a struct [ie hash/array Perl
> primitive] or do you return an object? eg a table object etc?

HTML::Template requires you to pass a perl data structure.  Template 
Toolkit can handle objects as well (i.e. automatically call their 
accessor methods to fetch properties).  Passing perl structs is faster, 
while passing objects allows for some additional tricks, like 
lazy-loading data in Class::DBI objects.  (Class::DBI is a module for 
modelling database data as objects.)

For more background on templating tools, see my article here:
http://perl.apache.org/features/tmpl-cmp.html

 > does the Model returned data contain lots of
> style hints? Or do you leave this completely to the View layer?

Ideally you should have no style information at all in the model.

> How does
> the view layer know for example to render an Error cell as RED in HTML
> but blue in Excel due to Excel palette limitations?

You have different views for different targets.  Make an HTML view and 
an Excel view and have the controller know which one to use.

>>Optimally, the View avoids *ALL* application logic.  
> 
> mmmm - so the Model has to say RED rather than ERROR?

Just the opposite: the model provides the list of errors, and the view 
knows how to display them.

> Sounds like Controller only interacts with one Model?

The model might be made up of dozens of different classes, but it's 
still referred to as "the model" as in "the application's data model."

> What controls the overall layout?

The view.

> e.g. what is the equivalent of the
> 'Grid Bag' layout manager - is this done in the Controller? and then
> passed to the View with all the data from a set of Models? Or do you 
> make the Controller minimalist and have a meta-Model that assembles
> all the sub-Models into a layout.

I don't know what a Grid Bag is, but the idea is pretty simple:
- Controller looks at input and decides which model objects to call.
- Controller calls some methods on model objects.
- Controller picks a view and passes data from model objects to it.

I wrote about this in my article on the eToys system:
http://www.perl.com/pub/a/2001/10/17/etoys.html

- Perrin

Reply via email to