Name : perl-Class-StrongSingleton
| |
Version : 0.20.0
| Vendor : obs://build_opensuse_org/devel:languages:perl
|
Release : lp155.1.1
| Date : 2024-07-20 00:28:47
|
Group : Unspecified
| Source RPM : perl-Class-StrongSingleton-0.20.0-lp155.1.1.src.rpm
|
Size : 0.02 MB
| |
Packager : https://www_suse_com/
| |
Summary : Stronger and More Secure Singleton Base Class
|
Description :
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 it\'s actually a Singleton. This can be handy if your design changes and you no longer need the class as a Singleton.
|
RPM found in directory: /packages/linux-pbone/ftp5.gwdg.de/pub/opensuse/repositories/devel:/languages:/perl/15.5/noarch |