Class::StrongSingleton 0.02

Class::StrongSingleton 0.02

Sponsored Links

Class::StrongSingleton 0.02 Ranking & Summary

Ranking Click at the star to rankRanking level:
User Review: 0 (0 times) Download now
File size: 0.006 MB Platform: Any Platform License: Perl Artistic License Price: Downloads: 8131 Date added: 2007-06-19 Publisher: Stevan Little Publisher URL: http://search.cpan.org/~s

Class::StrongSingleton 0.02 description

Class::StrongSingleton is a stronger and more secure Singleton base class.

SYNOPSIS

package My::Singleton::Class;

use base qw(Class::StrongSingleton);

sub new {
my ($class, %my_params) = @_;
# create our object instance
my $instance = { %my_params };
bless($instance, $class);
# and initialize it as a singleton
$instance->_init_StrongSingleton();
return $instance;
}

1;

# later in your code ...

# create the first instance of our class
my $instance = My::Singleton::Class->new(param => "value");

# try to create a new one again, and
# you end up with the same instance, not
# a new one
my $instance2 = My::Singleton::Class->new(param => "other value");

# calling instance returns the singleton
# instance expected
my $instance3 = My::Singleton::Class->instance();

# although rarely needed, if you have to
# you can destroy the singleton

# either through the instance
$instance->DESTROY();
# or through the class
My::Singleton::Class->DESTROY();

# of course, this is assuming you
# did not override DESTORY yourself

# Also calling instance before calling new
# will returns a new singleton instance
my $instance = My::Singleton::Class->instance();

This module is an alternative to Class::Singleton and Class::WeakSingleton, and provides a more secure Singleton class in that it takes steps to prevent the possibility of accidental creation of multiple instances and/or the overwriting of existsing Singleton instances. For a detailed comparison please see the "SEE ALSO" section.

Here is a description of how it all works. First, the user creates the first Singleton instance of the class in the normal way.

my $obj = My::Singleton::Class->new("variable", "parameter");

This instance is then stored inside a lexically scoped variable within the Class::StrongSingleton package. This prevents the variable from being accessed by anything but methods from the Class::StrongSingleton package. At this point as well, the new method to the class is overridden so that it will always return the Singleton instance. This prevents any accidental overwriting of the Singleton instance. This means that any of the follow lines of code all produce the same instance:

my $instance = $obj->instance();
my $instance = My::Singleton::Class->instance();
my $instance = $obj->new();
my $instance = My::Singleton::Class->new();

Personally, I see this an an improvement over the usual Gang of Four style Singletons which discourages the use of the new method entirely. Through this method, a user can be able to use the Singleton class in a normal way, not having to know its actually a Singleton. This can be handy if your design changes and you no longer need the class as a Singleton.

Download now

Class::StrongSingleton 0.02 Screenshot

Sponsored Links
Download Class::StrongSingleton 0.02

Class::StrongSingleton 0.02 Keywords

Bookmark Class::StrongSingleton 0.02

Hyperlink code:
Hyperlink and Intro code:

Class::StrongSingleton 0.02 Copyright

WareSeeker periodically updates pricing and software information of Class::StrongSingleton 0.02 full version from the publisher, so some information may be slightly out-of-date. You should confirm all information before relying on it. Software piracy is theft, Using crack, password, serial numbers, registration codes, key generators is illegal and prevent future development of Class::StrongSingleton 0.02 Edition. Download links are directly from our mirror sites or publisher sites, torrent files or links from rapidshare.com, yousendit.com or megaupload.com are not allowed

Class::StrongSingleton 0.02 Related Software


Class::Bits is a Perl module with class wrappers around bit vectors.

Rose::Class::MakeMethods::Set is a Perl module to create class methods to manage sets.

Class::HPLOO is an easier way to declare classes on Perl, based in the popular class {...} style and ePod.

Class::DBI::AutoIncrement is a Perl module to emulate auto-incrementing columns on Class::DBI subclasses.

Class::DBI::Query is a Perl module with deprecated SQL manager for Class::DBI.

Class::ArrayObjects is a Perl utility class for array based objects.

Class::Meta is a Perl class automation, introspection, and data validation.

Class::ObjectTemplate is a Perl extension for an optimized template builder base class.

Class::DBI::ConceptSearch is a Perl module to retrieve Class::DBI aggregates from high-level conceptual searches.

TagCloud Maker Class is a class that takes a single dimensional array of terms and outputs a piece of HTML with each term.
Class::StrongSingleton 0.02 Review:
Author name* :  
Author Email* :  
Comment* :  
Security code* :  
     
   
My Software
You have not saved any software. Click "Save" next to each software to save it to your software basket
Related Information
Sponsored Links
TOP POPULAR DOWNLOAD