Click here to get back home

Module naming help

 HomeNewsGroups | Search | About
 comp.lang.perl.modules    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
Module naming help Timothy Hinchcliffe 04-27-2006
Posted by Timothy Hinchcliffe on April 27, 2006, 10:29 am
Please log in for more thread options


I have written 2 modules which I intend to upload to CPAN.
I have chosen the names "Class::MethodVars" and "Class::Framework", they
would both be uploaded in Class-Framework-??.??.tar.gz unless anyone has
better suggestions.

The first currently called Class::MethodVars allows you to tag a sub with
":Method" and get access to "this" (in various configurable forms).

Eg:
package MyClass;
use warnings;
use strict;

use Class::MethodVars qw( -fieldvars ),-field=>"internal_variable";

sub new :ClassMethod {
return bless({},__CLASS__); # Class is provided my the magic
of :ClassMethod
}

sub mymethod :Method {
my ($arg) = @_; # Note that object has been removed from @_
this->++;
this->othermethod($arg);
$++; # This is an alias to this->
}

"this" can be renamed and/or configured to be a variable (which is
automatically added to "use vars" to remain strict-safe).

The second module is currently called Class::Framework. It combines
Class::MethodVars with fields (as in "use fields") and Class::Accessor to
build an class for you.

Eg:
package MyClass;
use warnings;
use strict;

use Class::Framework
-fields=>qw( a b cde ), # creates with ->mk_accessors(qw( a b cde ));
-rofield=>"rofield", # creates with ->mk_ro_accessors(qw( rofield ));
-hiddenfield=>"hidden"; # No accessor created.

# new() is inherited for you.

sub concat_fields :Method {
return join("",this->a,this->b,this->cde,this->rofield,this->);
}

package main;

my $mc = MyClass->new(a=>1,b=>2,cde=>3,rofield=>4,hidden=>5);
print $mc->concat_fields; # Prints "12345"

__END__

----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+
Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----

Similar ThreadsPosted
Module naming conundrum March 9, 2006, 9:25 pm
Request for naming help (templating module) September 8, 2005, 11:34 pm
Module naming question: Tie::StorableDir January 17, 2005, 3:17 pm
Module naming: Boolean::Verbose March 11, 2006, 7:07 am
Request for naming assistance for new plotting module November 18, 2004, 5:31 pm
help with module naming: filehandle-tie for size-limited/rotating logfile March 18, 2007, 5:44 am
thoughts on modules naming March 23, 2006, 6:46 am
Naming modules from the Internet Archive April 14, 2006, 10:24 pm
Naming consultation request (proposed Geo::ReadGRIB) April 25, 2006, 2:35 pm
Proposal Database::Initialize::Postgresql (naming okay?) March 17, 2007, 11:12 am

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap