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