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 );
In reply to Re: Foo::Button->new vs. newButton()
by stvn
in thread Foo::Button->new vs. newButton()
by bakunin
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |