Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: MVC question: way to expose API

by roboticus (Chancellor)
on May 10, 2008 at 12:16 UTC ( [id://685859]=note: print w/replies, xml ) Need Help??


in reply to MVC question: way to expose API

Qiang:

By the example you've used, you may be trying to put too much into your model. A report would be a view of the model, so you wouldn't use MyApp::Backend::Report. The model should concern itself with ensuring that the data remain in a consistent state WRT business rules, etc. I know that was a one-off example and it may not be what you meant, but I thought I'd mention it. In general, I try to keep a model as simple as possible. So when I'm adding a method, I ask myself ... "Is this necessary? At the right level of abstraction? etc.".

...roboticus

Replies are listed 'Best First'.
Re^2: MVC question: way to expose API
by Anonymous Monk on May 12, 2008 at 03:13 UTC
    Definitely agreed on keeping view-related things in the view, but IMHO you really want to (as much as possible without breaking the layer abstractions) put as much as you possibly can into the Model layer.

    Think of it this way: the Model layer *is* your application, in an abstract sense. It is your application without any regard for specific output formats or input methods. So if part of your application involves generating summary reports of database data, there probably should be a model class/method which handles report generation.

    However, it should only generate the report data based on abstract input parameters, and not deal with any user parameter input or user output formatting. An appropriate controller would gather user report parameter input from an HTML form or an emailed form (or a voice-prompt UI over a telephone), and an appropriate View would transform the report data into HTML or PDF (or text to speech) or whatever output flavor of the month.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://685859]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (3)
As of 2024-04-24 19:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found