John,
Thanks for the help. I've been boning up on my Perl at perldoc.com and I
just need to clear a few things up ...
You said:
> As stated before, there are several different styles for modeling
> common functionality. The "has a" - delegation approach tends to be a
> little more complicated but it scales a lot better than the "is a" -
> subclass approach.
We're not using "is a" in the same context as @ISA ... right?
> The key word here is scale. If the project isn't that large the choice
> is less of an issue, i.e. either should work.
>
> If the only differences you have are your "views" then you should be
> able to implement everything in a single module and use two different
> instance (.cgi) scripts to do what you have described below. One script
> might be called user.cgi and the other would be called admin.cgi.
>
That is what I have begun to do.
Already I'm seeing benifits in code reduction. For example, before (during
setup) I was storing things like references to DB handles and menu
(TMPL_LOOP) hash's as cgiapp param's. Now, these are in my SuperClass
(during cgiapp_init) so I can get to them in my SubClass user/admin.cgi by
saying $self->dbh and $self->menu instead of calling $self->param to get a
reference and then deal with it.
So I think I'm on the right track with this.
I'm right now fiddling with this, looking at how I might use
cgiapp_postrun(). Following the doc's example, I would use it my SubClass.
Can I use this in my SuperClass and override it in my SubClass as well? If
so, would I also need to call the SUPER::cgiapp_postrun or would it be
called auto-magically?
>
>
> In regards to overriding methods and extending methods, her are two
> trivial examples. There is no magic here. =) Be forewarned that I
> assume you have some programming experience. To override the method in
> a parent class. In your class:
>
> sub parent\Method {
>
you mean parentMethod (the "\" is a fat finger?)
> # your code goes here
> }
>
> To extend a method in a parent class, put this into your module:
>
> sub parentMethod {
>
> $self->SUPER::parentMethod();
>
> # your code goes here
>
> }
>
and it could also be ...
sub parentMethod {
# your code goes here
$self->SUPER::parentMethod();
}
... or does the call to the parent class method need to come first?
Thanks,
Bill
Previous part of thread ...
>
> > Mark,
> >
> > Thanks for speedy reply.
> >
> >> I'd say there are still a number of alternatives. The best solution
> >> may
> >> depend on the details of arrangement. You could use an "is a"
> >> relationship and have the modules inherit from a common parent,
> >> overriding or adding methods as needed.
> >
> > This is the way I'm leaning, while also taking advantage of some of the
> > built in init and run mode hooks and methods to override. Could you
> > maybe
> > give just a brief example on how to override and extend a method from a
> > parent class? I've had no luck finding the right place on perldoc.com
> > (but
> > I'm still looking.)
> >
> >>
> >> You could also use a "has a" relationship, where both admin and public
> >> modules just "use" a common utility module.
> >
> > I'm actually already using this for some things, but maybe need to make
> > better use of it along with the aforementioned "more OO approach". I
> > hate
> > changing similar code in more than one place.
> >
> >>
> >> Finally, you might be able to use exactly the same run modes, with a
> >> validation check beforehand as to whether your are in "admin mode" or
> >> note.
> >
> > Validation check? As in checking a CGI:App PARAM? Or is there a more
> > elegant
> > solution that you've used?
> >
> > *snip*
> >
> >>
> >> If you post a more detailed example, perhaps someone could be of
> >> further
> >> help.
> >>
> >
> > See my last post.
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.506 / Virus Database: 303 - Release Date: 8/1/2003
---------------------------------------------------------------------
Web Archive: http://www.mail-archive.com/[EMAIL PROTECTED]/
http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]