|
|
|
good chemistry is complicated, and a little bit messy -LW |
|
| PerlMonks |
Re: How Are Attributes Useful?by chromatic (Archbishop) |
| on Jan 18, 2005 at 17:36 UTC ( [id://423207]=note: print w/replies, xml ) | Need Help?? |
This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.
I've used attributes productively a few times. In a client server application, I used attributes on methods of the model classes to implement access controls. The syntax was something like :Access( rw ) to mark a method as needing read and write access. The actual server class performed authorization and authentication and knew the permissions of remote users. Before delegating any method call to a model object, it would check the permissions. I could have done this without attributes, but it seemed like a nice way to keep the metadata (what does this method accomplish) in the same place as the actual code of the method. In a recent journal entry (Dark, Dark Corners of Perl), I speculated that it's possible to use attributes on methods to simplify declaring and accessing parameters. I'm not ready to demonstrate my proof of concept yet, but I really like how the syntax works. It's nice to be able to manipulate subroutines at the appropriate time without resorting to source filters.
In Section
Seekers of Perl Wisdom
|
|
||||||||||||||||||||||||||||||||