Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: How Are Attributes Useful?

by pemungkah (Priest)
on Mar 24, 2007 at 08:40 UTC ( [id://606396]=note: print w/replies, xml ) Need Help??


in reply to How Are Attributes Useful?

Take a look at Class::AutoPlug. It uses attributes to allow you to declaratively build pluggable versions of non-pluggable modules using attributes and some clever uses of import(). Essentially, your pluggable main class looks like
package Something::Pluggable; use base qw(Class::Autoplug::Pluggable); 1;
and your plugins look like
package Something::Plugin::Foo; use base qw(Class::AutoPlug::Plugin); sub x:PluggedMethod(methodName) { ...} sub y:Prehook(someBaseMethod) { ... } sub z:Posthook(someBaseMethod) { ... } 1;
All the monkey code to find the methods, add hooks, etc., is handled inside the base classes, letting you concentrate on the actual job at hand. Attributes make it easy to define what you want declaratively, without stuff like having to construct lists of methods and hooks.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://606396]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (4)
As of 2024-04-19 05:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found