[cgiapp] Model design in C::A/Titanium
Ron Savage
ron at savage.net.au
Wed Oct 22 23:24:13 EDT 2008
Hi Mark
On Wed, 2008-10-22 at 22:35 -0400, Mark Rajcok wrote:
> On Tue, Oct 21, 2008 at 7:45 PM, Ron Savage <ron at savage.net.au> wrote:
[snip]
> > But why /exactly/ is it growing?
>
>
> Ron, I wasn't too clear about who I was quoting. Richard Jones had the
> growing Model class, so he would need to answer that question.
Oops. My mistake.
[mega-snip]
> If it wants person data, it calls Database.pm's some_method() to get a
> > data structure, which then gets formatted into either HTML or JSON.
>
>
> So if you need more than one Person (object), you'd have to create a
> some_other_method() in Database.pm. Sounds like a lot of methods in
> Database.pm might pop up over time.
Ah, but at this stage I don't ever have more that one Person object.
A search will return an array of of hash refs, each hashref equivalent
to a Person object, i.e. holding personal data, without quite being a
fully-blown object. Not much different, really.
[snip]
> I like having HTML template files and separate model classes... for this
> reason: if I add a new field to the User table, then normally only the
> "add/edit" user HTML template and the User.pm class need to change.
Right. I use HTML::Template. So a new field requires a template change
of course.
But it also requires changes to the validation code, and probably the
save code.
It just so happens that for a small app I have my save code in my
database module, but yes, I could split it out if the complexity per
object grows.
> I have not started thinking about how I'm going to do table joins yet. I
> may end up with a Database.pm-like class for that...
'Joins'? Damn - another thing I have to read up on on WikiPedia :-)).
--
Ron Savage
ron at savage.net.au
http://savage.net.au/index.html
More information about the cgiapp
mailing list