in reply to How Are Attributes Useful?
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.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: How Are Attributes Useful?
by Ovid (Cardinal) on Jan 18, 2005 at 22:47 UTC | |
by chromatic (Archbishop) on Jan 19, 2005 at 00:16 UTC | |
by perrin (Chancellor) on Jan 19, 2005 at 00:15 UTC |