in reply to Foo::Button->new vs. newButton()
I not a fan of the idea of exporting procedural-style class constructors from modules, since it kind of hides the OO, and a symbol like "newButton" could be handy to users of your library elsewhere. IMHO exporting symbols can get real messy, real fast.
There is always the not-so-great indirect object syntax:
but that can sometimes be more trouble than its worth.$b = new Foo::Button @args
What about the syntax length bothers you? Are your modules nested deeply? (ex: Olga::Ming::Widgets::Button) If so, you could create your own class loader for your framework. I have done this with the object framework I have been working on and it works quite well. Here is the syntax :
Then the iI::Framework module's import method simply changes all the "."s to "/"s and requires each module. After that the modules can then be refered to as "Request" and "DispatchHandler" instead of "iI::Web::Request" and "iI::Web::ModPerl::DispatchHandler". Its a little weird (maybe not terribly perl-ish), but it keeps my module name length down and still allows me to organize the almost 100 different classes I have into a neat tidy folder heirarchy. -stvnuse iI::Framework qw( Web.Request Web.ModPerl.DispatchHandler );
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Foo::Button->new vs. newButton()
by bakunin (Scribe) on Jan 16, 2004 at 19:52 UTC | |
by stvn (Monsignor) on Jan 16, 2004 at 19:58 UTC | |
by hhdave (Beadle) on Jan 16, 2004 at 20:21 UTC |