Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- New OO module idea - looking for suggestions
October 2, 2007, 3:26 am
rate this thread
I've been working on a module that provides encapsulation, inheritance
and strong typing. I know there are several OO frameworks already in
CPAN, but I have not seen any that implements the OO principles that
strictly. The module I'm proposing will provided private, protected
and public methods and properties. It will also implement the concept
of virtual methods, and only methods marked as such can be overridden
by the children.
Another key piece of functionality is that when a method is overridden
by a child, from the perspective of the parent the method behaves as
the original method did and the new method or property is only
available from the child down. Also private properties and method are
only visible in the class the implements them and the children are
free to use the same names without the problem of collisions or
overriding those entities.
Basically, it would be and OO implementation closer to how it's
currently implemented in Java or C#, my hope is that it would make
folks versed in those languages more comfortable with perl and allow
perl developer to explore and perhaps even enjoy some of the features
of those languages.
In order to make use of the functionality of the proposed module a
perl developer would simply have to inherit from the proposed module
and use function attributes to mark the functions as a properties or
methods and whether they are private, protected or public. Functions
marked as properties will be used for defining the property type and
how to handle gets and set within a tied hash which will be to object
core structure. Most of the overhead associated with enforcing the
encapsulation will take place during the CHECK phase and when classes
are instantiated, from there on they work off dispatch tables which
should be pretty fast. The biggest benefit would be for those folks
working under mod_perl as they will compile once and use many times.
Sorry for the rant, but I was wondering if there is any interest out
there for such a animal. If there is please let me know and I will
post the module for peer review.
Re: New OO module idea - looking for suggestions
the --> those
You meant to say "that implements /those/ OO principles...."
Bad idea. Methods should be "virtual" by default.
Perl has this already.
Why should Perl be Java?
Persons versed in those languages are already accommodated--they have
Java and C#.
There may indeed be some interest, but most people interested in strong
typing and enforced encapsulation are using a language other than Perl.
I see no need for Perl to become another language to attract programmers.
However, your efforts may bear fruit. As you develop your class-building
framework, you may consider the functionality in some of these modules:
You will find those modules on CPAN and pre-installed in some Linux
Also look into "inside out classes."
- » IO::Socket::SSL: cannot connect using different LocalAddr
- — Next thread in » PERL Modules Announcements
- » Using external REXX function libraries with PERL
- — Previous thread in » PERL Modules Announcements