1MakeMethods::Docs::RelaUtseedrMoCdounltersi(b3u)ted PerlMaDkoecMuemtehnotdast:i:oDnocs::RelatedModules(3)
2
3
4
6 Class::MakeMethods::Docs::RelatedModules - Survey of Class Builders
7
9 http://search.cpan.org/search?mode=module&query=Class
10
12 There are a variety of modules on CPAN dedicated to the purpose of gen‐
13 erating common constructor and accessor methods. Below, I survey sev‐
14 eral of these, summarizing some basic features and technical
15 approaches, and comparing them to Class::MakeMethods and other modules.
16
17 Caution
18
19 Please note that these comments are for basic comparison purposes only
20 and may be incorrect or out of date. Please consult the documentation
21 from a current version of each module for more specific details. Cor‐
22 rections and clarifications would by welcomed by the author at the
23 email address below.
24
25 Points of Comparison
26
27 In general, I compared the following characteristics:
28
29 Distribution
30 Is it included with Perl, or on CPAN? Is it being actively main‐
31 tained?
32
33 Usage
34 How do you go about declaring your class's methods?
35
36 Mechanism
37 How are they generated and delivered?
38
39 Instance type
40 Are the objects of your class blessed hashes, or something else?
41
42 Core Methods
43 Does the module provide a constructor and basic accessors? Are
44 there specialized methods for hash-ref, array-ref, and object-ref
45 accessors?
46
47 Extensible
48 Can you subclass the package to create new types of methods, or is
49 there some other way to extend it?
50
51 Other Methods
52 Other types of methods provided.
53
54 Emulator
55 Does Class::MakeMethods provide a drop-in replacement for this mod‐
56 ule?
57
58 Comments
59 Other characteristics or features of note.
60
62 accessors
63
64 Distribution
65 CPAN. Uploaded Sep 2003.
66
67 Comments
68 I have not yet reviewed this module in detail.
69
70 Example
71 package MyObject;
72 use accessors qw( foo bar baz );
73
74 Attribute::Property
75
76 Distribution
77 CPAN.
78
79 Comments
80 I have not yet reviewed this module in detail.
81
82 Class::Accessor
83
84 Distribution
85 CPAN. Last update 4/01.
86
87 Usage
88 Inherit and call function with declaration arguments
89
90 Mechanism
91 Generates and installs closures
92
93 Instance Type
94 Hash.
95
96 Subclasses Cleanly
97 Cleanly.
98
99 Standard Methods
100 Scalar accessors.
101
102 Extensible
103 Yes.
104
105 Comments
106 Accessor methods call overwritable "self-<get(key)" and
107 "self-<set(key, value)" methods.
108
109 Also includes Class::Accessor::Fast, which creates direct hash keys
110 accessors without calling get and set methods.
111
112 Emulator
113 Yes, but only for the Fast variation; see Class::MakeMethods::Emu‐
114 lator::AccessorFast.
115
116 Example
117 package MyObject;
118 @ISA = qw(Class::Accessor);
119 MyObject->mk_accessors(qw( simple ordered mapping obj_ref ));
120
121 Class::Class
122
123 Distribution
124 CPAN. Last update 1/00.
125
126 Usage
127 Inherit and fill %MEMBERS hash; methods created when first object
128 is created
129
130 Mechanism
131 Generates and installs closures
132
133 Instance Type
134 Hash.
135
136 Subclasses Cleanly
137 Yes.
138
139 Standard Methods
140 Constructor and various accessors.
141
142 Extensible
143 No.
144
145 Example
146 Usage is similar to Class::Struct:
147
148 package MyObject;
149 use Class::Class;
150 @ISA = qw(Class::Class);
151 %MEMBERS = (
152 simple => '$',
153 ordered => '@',
154 mapping => '%',
155 obj_ref => 'FooObject'
156 );
157
158 Other Method Types
159 Provides a polymorph() method that is similar to Class::Method's
160 "ClassName:class_name -require".
161
162 Class::Constructor
163
164 Distribution
165 CPAN. Last update 11/01.
166
167 Usage
168 Inherit and call function with declaration arguments
169
170 Mechanism
171 Generates and installs closures
172
173 Instance Type
174 Hash.
175
176 Subclasses Cleanly
177 Cleanly.
178
179 Standard Methods
180 Hash constructor, with bells.
181
182 Extensible
183 No.
184
185 Emulator
186 No, but possible.
187
188 Example
189 package MyObject;
190 @ISA = qw(Class::Constructor);
191 MyObject->mk_constructor( Name => 'new' );
192
193 Class::Classgen
194
195 Distribution
196 CPAN. Last update 12/00.
197
198 Usage
199 Pre-processor run against declaration files.
200
201 Mechanism
202 Assembles and saves code file
203
204 Instance Type
205 Hash.
206
207 Subclasses Cleanly
208 Yes. (I think.)
209
210 Standard Methods
211 Constructor and various accessors.
212
213 Extensible
214 No. (I think.)
215
216 Example
217 header:
218 package MyObject;
219 variables:
220 $simple
221 @ordered
222 %mapping
223 $obj_ref
224
225 Class::Contract
226
227 Distribution
228 CPAN. Last update 5/01.
229
230 Usage
231 Call function with declaration arguments
232
233 Mechanism
234 Generates and installs closures
235
236 Instance Type
237 Scalar reference with external data storage.
238
239 Subclasses Cleanly
240 Yes.
241
242 Standard Methods
243 Constructor and various accessors.
244
245 Extensible
246 Yes. (I think.)
247
248 Comments
249 Supports pre- and post-conditions, class invariants, and other
250 software engineering goodies.
251
252 Example
253 package MyObject;
254 use Class::Contract;
255 contract {
256 ctor 'new';
257 attr 'simple' => SCALAR;
258 attr 'ordered' => ARRAY;
259 attr 'mapping' => HASH;
260 attr 'obj_ref' => 'FooObject';
261 }
262
263 Class::Data::Inheritable
264
265 Distribution
266 CPAN. Last update 4/00.
267
268 Usage
269 Inherit and call function with declaration arguments
270
271 Mechanism
272 Generates and installs closures
273
274 Instance Type
275 Class data, with inheritance.
276
277 Subclasses Cleanly
278 Yes, specifically.
279
280 Standard Methods
281 Scalar accessors.
282
283 Extensible
284 No.
285
286 Example
287 Usage is similar to Class::Accessor:
288
289 package MyObject;
290 @ISA = qw(Class::Data::Inheritable);
291 MyObject->mk_classdata(qw( simple ordered mapping obj_ref ));
292
293 Emulator
294 Yes, Class::MakeMethods::Emulator::Inheritable, passes original
295 test suite.
296
297 Class::Delegate
298
299 Distribution
300 CPAN. Uploaded 12/0.
301
302 Comments
303 I have not yet reviewed this module in detail.
304
305 Class::Delegation
306
307 Distribution
308 CPAN. Uploaded 12/01.
309
310 Comments
311 I have not yet reviewed this module in detail.
312
313 Class::Generate
314
315 Distribution
316 CPAN. Last update 11/00.
317
318 Usage
319 Call function with declaration arguments
320
321 Mechanism
322 Assembles and evals code string, or saves code file.
323
324 Instance Type
325 Hash.
326
327 Subclasses Cleanly
328 Yes.
329
330 Standard Methods
331 Constructor and accessors (scalar, array, hash, object, object
332 array, etc).
333
334 Extensible
335 Unknown.
336
337 Comments
338 Handles private/protected limitations, pre and post conditions,
339 assertions, and more.
340
341 Example
342 Usage is similar to Class::Struct:
343
344 package MyObject;
345 use Class::Generate;
346 class MyObject => [
347 simple => '$',
348 ordered => '@',
349 mapping => '%',
350 obj_ref => 'FooObject'
351 ];
352
353 Class::Hook
354
355Distribution
356CPAN. Uploaded 12/01.
357
358Comments
359I have not yet reviewed this module in detail.
360
362
363Distribution
364 CPAN. Experimental/Alpha release 07/2001.
365
366Instance Type
367 Hash, array, or flyweight-index.
368
369Subclasses Cleanly
370 No. (I think.)
371
372Standard Methods
373 Constructor and scalar accessors; flywieght objects also get scalar muta‐
374 tor methods.
375
376Extensible
377 No. (I think.)
378
379Comments
380 I'm not sure I understand the intent of this module; perhaps future ver‐
381 sions will make this clearer....
382
384
385Distribution
386 CPAN. Last update 1/01.
387
388Usage
389 Import, or call function, with declaration arguments
390
391Mechanism
392 Generates and installs closures
393
394Instance Type
395 Hash, Static.
396
397Subclasses Cleanly
398 Yes.
399
400Standard Methods
401 Constructor and various accessors.
402
403Extensible
404 Yes.
405
406Example
407 Usage is similar to Class::MakeMethods:
408
409 package MyObject;
410 use Class::MethodMaker (
411 new => 'new',
412 get_set => 'simple',
413 list => 'ordered',
414 hash => 'mapping',
415 object => [ 'FooObject' => 'obj_ref' ],
416 );
417
418Emulator
419 Yes, Class::MakeMethods::Emulator::MethodMaker, passes original test
420 suite.
421
423
424Distribution
425 CPAN.
426
427Usage
428 Import, or call function, with declaration arguments; or if desired, make
429 methods on-demand with Autoload, or declare subroutines with a special
430 Attribute.
431
432Mechanism
433 Generates and installs closures
434
435Instance Type
436 Hash, Array, Scalar, Static, Class data, others.
437
438Subclasses Cleanly
439 Yes.
440
441Standard Methods
442 Constructor and various accessors.
443
444Extensible
445 Yes.
446
447Example
448 Usage is similar to Class::MethodMaker:
449
450 package MyObject;
451 use Class::MakeMethods::Hash (
452 new => 'new',
453 scalar => 'simple',
454 array => 'ordered',
455 hash => 'mapping',
456 object => [ 'obj_ref', { class=>'FooObject' } ],
457 );
458
460
461Distribution
462 CPAN. Last update 7/02.
463
464Usage
465 Call function with declaration arguments.
466
467Mechanism
468 Generates and installs closures (I think).
469
470Instance Type
471 Hash (I think).
472
473Subclasses Cleanly
474 Unknown.
475
476Standard Methods
477 Constructor and various scalar and reference accessors.
478
479Extensible
480 Unknown.
481
482Comments
483 I haven't yet reviewed this module closely.
484
486
487Distribution
488 CPAN. Last update 2/00.
489
490Usage
491 Inherit; methods created via AUTOLOAD
492
493Mechanism
494 Generates and installs closures (I think)
495
496Instance Type
497 Hash.
498
499Subclasses Cleanly
500 Yes.
501
502Standard Methods
503 Constructor and scalar/code accessors (see Comments).
504
505Extensible
506 No.
507
508Comments
509 Individual objects may be assigned a subroutine that will be called as a
510 method on subsequent accesses. If an instance does not have a value for a
511 given accessor, looks for a method defined with a leading underscore.
512
514
515Distribution
516 Included in the standard Perl distribution. Replaces Class::Template.
517
518Usage
519 Call function with declaration arguments
520
521Mechanism
522 Assembles and evals code string
523
524Instance Type
525 Hash or Array
526
527Subclasses Cleanly
528 No.
529
530Standard Methods
531 Constructor and various accessors.
532
533Extensible
534 No.
535
536 package MyObject;
537 use Class::Struct;
538 struct(
539 simple => '$',
540 ordered => '@',
541 mapping => '%',
542 obj_ref => 'FooObject'
543 );
544
545Emulator
546 Yes, Class::MakeMethods::Emulator::Struct.
547
549
550Distribution
551 CPAN. Last update 12/00.
552
553 No documentation available.
554
555Usage
556 Unknown.
557
558Mechanism
559 Unknown.
560
562
563Distribution
564 CPAN. Out of date.
565
566Usage
567 Call function with declaration arguments (I think)
568
569Mechanism
570 Assembles and evals code string (I think)
571
572Instance Type
573 Hash.
574
575Subclasses Cleanly
576 Yes. (I think.)
577
578Standard Methods
579 Constructor and various accessors.
580
581Extensible
582 No. (I think.)
583
584Example
585 Usage is similar to Class::Struct:
586
587 package MyObject;
588 use Class::Template;
589 members MyObject {
590 simple => '$',
591 ordered => '@',
592 mapping => '%',
593 obj_ref => 'FooObject'
594 };
595
597
598Generates methods that fail with a message indicating that they were not
599implemented by the subclass. (Cf. 'Template::Universal:croak -abstract'.)
600
601Also provides a list of abstract methods that have not been implemented by a
602subclass.
603
604Distribution
605 CPAN. Last update 3/01.
606
607Extensible
608 Unknown.
609
610Mechanism
611 Uses Class::Data::Inheritable and installs additional closures.
612
614
615Distribution
616 CPAN.
617
618Usage
619 Call function with declaration arguments.
620
621Mechanism
622 Generates and writes source code to a file.
623
624Instance Type
625 Hash (I think).
626
627Subclasses Cleanly
628 Unknown.
629
630Standard Methods
631 Constructor and various scalar and reference accessors.
632
633Extensible
634 Unknown.
635
636Comments
637 I haven't yet reviewed this module closely.
638
640
641Distribution
642 CPAN.
643
644Usage
645 Package import with declaration arguments
646
647Mechanism
648 Generates and installs closures
649
650Instance Type
651 Hash.
652
653Standard Methods
654 Scalar accessors.
655
656Extensible
657 No.
658
659Example
660 use HTML::Mason::MethodMaker (
661 read_write => [ qw( simple ordered mapping obj_ref ) ]
662 );
663
665 The following modules are relevant but have not yet been cataloged
666 above.
667
668 Attribute::Property
669
670 Class::Accessor::Chained
671
672 Class::Accessor::Lvalue
673
674 Class::Accessor::Ref
675
676 Class::AutoClass
677
678 Class::Builder
679
680 Class::Member
681
682 Class::Trigger
683
685 See Class::MakeMethods for general information about this distribution.
686
688 Developed By
689
690 M. Simon Cavalletto, simonm@cavalletto.org
691 Evolution Softworks, www.evoscript.org
692
693 Copyright
694
695 Copyright 2002 Matthew Simon Cavalletto.
696
697 Portions copyright 2000, 2001 Evolution Online Systems, Inc.
698
699 License
700
701 You may use, modify, and distribute this document under the same terms
702 as Perl.
703
704
705
706perl v5.8.8 2004-09-0M6akeMethods::Docs::RelatedModules(3)