<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html; charset=ISO-8859-1"
 http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
<br>
<div class="moz-signature">
<div align="center">Steve Schafer<br>
Matsch Systems<br>
<small>Phone: 616-477-9629<br>
Mobile: 616-304-9440<br>
Email: <a class="moz-txt-link-freetext" href="mailto:steve@matsch.com">steve@matsch.com</a><br>
Web: <a class="moz-txt-link-freetext" href="http://www.matsch.com/">http://www.matsch.com/</a><br>
</small>
<div align="left"><br>
</div>
</div>
</div>
<br>
On 5/27/2010 9:41 AM, Bill Moseley wrote:
<blockquote
 cite="mid:AANLkTikqwWYu4oRyAgsYjCKG-eP_9BQNDjsWbPlUbO-7@mail.gmail.com"
 type="cite"><br>
  <br>
  <div class="gmail_quote">On Thu, May 27, 2010 at 5:38 AM, Steve <span
 dir="ltr">&lt;<a moz-do-not-send="true" href="mailto:steve@matsch.com">steve@matsch.com</a>&gt;</span>
wrote:<br>
  <blockquote class="gmail_quote"
 style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
    <div bgcolor="#ffffff" text="#000000">
    <div class="im">
    <blockquote type="cite">
      <pre>I think your business logic should be moved to the model, not the
controller.
The model does the heavy lifting.
  </pre>
    </blockquote>
    </div>
My model is currently comprised only of my DBIC Result and ResultSet
classes.&nbsp; Are you suggesting that some of the logic in my controllers
should be moved into my DBIC classes, or should I create new Moose
classes.&nbsp; If Moose, how do I 'hook up' those classes to Catalyst?</div>
  </blockquote>
  <div><br>
  </div>
  <div>There's always room for another layer of abstraction. &nbsp;That
said, I find that adding custom ResultSet and Result methods (and using
custom base classes for both) handles most of the abstraction. &nbsp;You can
abstract most calls so that you aren't writing little, if any,
DBIC-looking code in your controllers. &nbsp;The Controller actions should
be pretty tiny -- just a few lines at most.</div>
  </div>
</blockquote>
At present, the only DBIC-looking code is contained in two lines
(chaining resultsets).&nbsp; I'm not sure it's worth the effort for this
application, but it certainly will be for others.&nbsp; Can you elaborate on
the custom base classes idea?&nbsp; If my Catalyst model is: "use base
'Catalyst::Model::DBIC::Schema'", would it then become "use base
'MyApp::Model::Custom'", then MyApp::Model::Custom uses
'Catalyst::Model::DBIC::Schema'?<br>
<blockquote
 cite="mid:AANLkTikqwWYu4oRyAgsYjCKG-eP_9BQNDjsWbPlUbO-7@mail.gmail.com"
 type="cite">
  <div class="gmail_quote">
  <div><br>
  </div>
  <blockquote class="gmail_quote"
 style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
    <div bgcolor="#ffffff" text="#000000">
    <div class="im">
    <blockquote type="cite">
      <pre>"Decouple as much as possible. If you have to fire up your web application
in order to test database insertion, that's wrong. Build the model so that
you can use Perl one liners to manipulate data through it."</pre>
    </blockquote>
    </div>
    </div>
  </blockquote>
  <div><br>
  </div>
  <div>True, although I've been working on an app that is entirely
AJAX-based so the Catalyst app is exposed as an API of URLs (I'll avoid
the term REST here). &nbsp;So, that means all access to the app is via the
API -- even for cron scripts. As a result, the bulk of the tests are
talking to the app via URLs and HTTP method names. &nbsp;(PUT /user/1234).
&nbsp;We still have tests for the model, but no other code uses the model
directly (by contract). We still push as much code low into the model
as possible.</div>
  <div><br>
  </div>
  <div>And to your original post:</div>
  <div><br>
  </div>
  <div>Take a look at&nbsp;<a moz-do-not-send="true"
 href="http://search.cpan.org/%7Emasaki/Catalyst-Controller-Resources-0.08/">http://search.cpan.org/~masaki/Catalyst-Controller-Resources-0.08/</a>&nbsp;.</div>
  <div><br>
  </div>
  <div>I would split up your existing controllers. &nbsp;Think about the
objects returned and name them them the same. &nbsp;I often have model class
names that are the same as controller class names (and form classes). &nbsp;
Need to get a user? &nbsp;/user/$id &nbsp;Instead of a verb like /ViewStmt use a
name for the thing you want: &nbsp;/statement/$id or /invoice/$id. &nbsp;I'd be
interested to hear opinions about your admin interface, &nbsp;but, I often
mirror existing controllers with /admin/user/$id &nbsp;(admin's view of a
user).</div>
  </div>
</blockquote>
In which case the controllers would be...?&nbsp; Admin, User, and Statement?<br>
<br>
I'm not sure I am quite ready for ANOTHER layer of abstraction...yet.<span
 class="moz-smiley-s1"><span> :-) </span></span><br>
<blockquote
 cite="mid:AANLkTikqwWYu4oRyAgsYjCKG-eP_9BQNDjsWbPlUbO-7@mail.gmail.com"
 type="cite">
  <div class="gmail_quote">
  <div><br>
  </div>
  <div>I often have a /login controller -- POST /login creates a new
token (cookie). &nbsp;Then there's room for /login/forgot_my_password kind
of thing.</div>
  <div><br>
  </div>
  <div>&nbsp;</div>
  </div>
  <br>
-- <br>
Bill Moseley<br>
  <a moz-do-not-send="true" href="mailto:moseley@hank.org">moseley@hank.org</a><br>
  <pre wrap="">
<fieldset class="mimeAttachmentHeader"></fieldset>
_______________________________________________
List: <a class="moz-txt-link-abbreviated" href="mailto:Catalyst@lists.scsys.co.uk">Catalyst@lists.scsys.co.uk</a>
Listinfo: <a class="moz-txt-link-freetext" href="http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst">http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst</a>
Searchable archive: <a class="moz-txt-link-freetext" href="http://www.mail-archive.com/catalyst@lists.scsys.co.uk/">http://www.mail-archive.com/catalyst@lists.scsys.co.uk/</a>
Dev site: <a class="moz-txt-link-freetext" href="http://dev.catalyst.perl.org/">http://dev.catalyst.perl.org/</a>
  </pre>
  <pre wrap="">
<fieldset class="mimeAttachmentHeader"></fieldset>

No virus found in this incoming message.
Checked by AVG - <a class="moz-txt-link-abbreviated" href="http://www.avg.com">www.avg.com</a> 
Version: 9.0.819 / Virus Database: 271.1.1/2899 - Release Date: 05/27/10 02:25:00

  </pre>
</blockquote>
</body>
</html>