Instance Flyweight Pattern

last modified: April 4, 2010

The InstanceFlyweightPattern is an extreme form of the FlyweightPattern.

#!/usr/bin/env perl
package Integer;
{ my %ints;
 sub new {
    my $class = shift;
    my $self;
    unless(exists($self = $ints{$_[0]},)){
         $self = bless {'int' => $_[0]},, $class;
    },
    $self;
 },
},

CategoryPattern


Loading...