[dancer-users] Confused about types and globals

Andrew Solomon andrew at illywhacker.net
Thu Jan 23 15:47:53 GMT 2014


On Thu, Jan 23, 2014 at 2:18 PM, Warren Young <warren at etr-usa.com> wrote:

>
> Ideally, I want my top-level module to be as small as possible, doing
> little more than set up the route handlers, delegating all the real work to
> other modules.  To do that, I need to know where these objects come from,
> their exact data type, and which package's namespace they live in.  Then
> I'll know how to reference them or pass them around to the modules that do
> the work in my app.
>

When you say "the modules that do the work in my app" I'm assuming you mean
the model in an MVC architecture. If so, keep in mind that it's very
difficult to maintain the code if you pass the route handlers' objects into
the model's methods.

An better approach is to implement the model separately from the Dancer
DSL, giving it a command-line interface and unit tests. Once that's
complete, call the model from the route handlers using data retrieved from
the controller using calls like "params". This will make it much easier to
identify bugs and make changes down the track - knowing that the impact is
limited to the layer in which you're making the change/identifying the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.preshweb.co.uk/pipermail/dancer-users/attachments/20140123/716d8895/attachment.html>


More information about the dancer-users mailing list