use Aspect? (was: Module setup argument validation)
Ziya Suzen
ziya at suzen.net
Tue Jul 17 04:58:59 PDT 2007
On 7/17/07, Tom Hukins <tom at eborcom.com> wrote:
> I like your idea of using Aspect to validate input: it fits well with
Actually just saw Class::Container. As far as I can tell it separates
parameter validation (and more) in your code quite well. The down/up
side is you need to treat most of the things as objects, as far as I
can tell.
As far as I know (correct me anyone, if this is wrong)
Class::Container extracted from the same project (HTML::Mason) which
created Exception::Class and Params::Validate as well. It seems to be
using Params::Validate behind the curtain as well.
> AOP's emphasis on separation of concerns. I guess you could also use
> after {} to assert that you produce the expected output.
Very nice. It becomes a bit like a 'contract', doesn't it?
> I've used Aspect.pm quite a bit for analysing how code works (see my
> slides: http://miltonkeynes.pm.org/talks/2006/10/learned_at_yapc.pdf)
I think you mean this:
http://miltonkeynes.pm.org/talks/2006/06/tom_hukins_tracing_aspect.pdf
Good one. Thank you.
> Good luck: let us know how you get on.
Mine is just an experiment for now. AOP is sure a very interesting
topic and I have been looking into opportunities to use it for quite a
while now. But I suppose I am not 100% sold on the idea just yet.
Things like exception handling, stack traces, performance and so on
and most of all using it in a team still concerns me a lot.
In one of the problems I considered using Aspect.pm was with a big .pm
file. There is this huge piece of .pm file in my hand and it's been
growing day by day (Tom, you know what I am talking about). I have
considered AOP and other approaches to move some of the stuff out of
it. But the methods are sooooo huge as well, nothing seemed to make
sense.
So, I ended up slightly extending/changing your approach (clever
subclassing at creation) and adding 'hook' methods (instead of
'$obj->can($method)' checks) here and there and use them from
subclasses.
Cheers
--Ziya
More information about the MiltonKeynes-pm
mailing list