Debian lenny version packages
[pkg-perl] / deb-src / libclass-accessor-perl / libclass-accessor-perl-0.31 / README
1 NAMES
2       Class::Accessor         - automated accessor generation
3       Class::Accessor::Fast   - faster automated accessor generation
4       Class::Accessor::Faster - even faster, using an array
5
6 DESCRIPTION
7
8     This module automagically generates accessors/mutators for your class.
9
10     Most of the time, writing accessors is an exercise in cutting and
11     pasting. You usually wind up with a series of methods like this:
12
13         sub name {
14             my $self = shift;
15             if(@_) {
16                 $self->{name} = $_[0];
17             }
18             return $self->{name};
19         }
20
21         sub salary {
22             my $self = shift;
23             if(@_) {
24                 $self->{salary} = $_[0];
25             }
26             return $self->{salary};
27         }
28
29       # etc...
30
31     One for each piece of data in your object. While some will be unique,
32     doing value checks and special storage tricks, most will simply be
33     exercises in repetition. Not only is it Bad Style to have a bunch of
34     repetitious code, but its also simply not lazy, which is the real
35     tragedy.
36
37     If you make your module a subclass of Class::Accessor and declare your
38     accessor fields with mk_accessors() then you'll find yourself with a set
39     of automatically generated accessors which can even be customized!
40
41     The basic set up is very simple:
42
43         package My::Class;
44         use base qw(Class::Accessor);
45         My::Class->mk_accessors( qw(foo bar car) );
46
47     Done. My::Class now has simple foo(), bar() and car() accessors defined.
48
49 BENCHMARKS
50
51     accessors:
52                  Rate   Basic Average    Fast  Faster  Direct
53     Basic    189150/s      --    -42%    -51%    -55%    -89%
54     Average  327679/s     73%      --    -16%    -22%    -82%
55     Fast     389212/s    106%     19%      --     -8%    -78%
56     Faster   421646/s    123%     29%      8%      --    -76%
57     Direct  1771243/s    836%    441%    355%    320%      --
58
59     mutators:
60                  Rate   Basic Average    Fast  Faster  Direct
61     Basic    173769/s      --    -34%    -53%    -59%    -90%
62     Average  263046/s     51%      --    -29%    -38%    -85%
63     Fast     371158/s    114%     41%      --    -13%    -78%
64     Faster   425821/s    145%     62%     15%      --    -75%
65     Direct  1699081/s    878%    546%    358%    299%      --
66
67 AUTHORS
68
69     Copyright 2007 Marty Pauley <marty+perl@kasei.com>
70
71     This program is free software; you can redistribute it and/or modify it
72     under the same terms as Perl itself. That means either (a) the GNU
73     General Public License or (b) the Artistic License.
74
75 ORIGINAL AUTHOR
76
77     Michael G Schwern <schwern@pobox.com>
78