From oliver.gorwits at oucs.ox.ac.uk Thu Jul 5 10:12:48 2007 From: oliver.gorwits at oucs.ox.ac.uk (Oliver Gorwits) Date: Thu, 05 Jul 2007 18:12:48 +0100 Subject: Module setup argument validation Message-ID: <468D2690.2070304@oucs.ox.ac.uk> Hi folks, I'm writing a module which is essentially a blob of glue between some other very useful Perl modules. What I'd like to do is validate the parameters coming in to my module, some of which are for my own use, and others are destined for the other modules (encapsulated as hashes). I'm currently looking at Params::Validate -- but my question is, are there any other contenders in the ring? Things I require are type checking (scalar, hashref, etc), setting of defaults for missing options, and ideally, overriding of options to enforced values. thanks in advance, oliver. -- Oliver Gorwits, Network Infrastructure Group, Oxford University Computing Services From nik at ngo.org.uk Thu Jul 5 15:53:28 2007 From: nik at ngo.org.uk (Nik Clayton) Date: Thu, 05 Jul 2007 23:53:28 +0100 Subject: Module setup argument validation In-Reply-To: <468D2690.2070304@oucs.ox.ac.uk> References: <468D2690.2070304@oucs.ox.ac.uk> Message-ID: <468D7668.3090100@ngo.org.uk> Oliver Gorwits wrote: > I'm writing a module which is essentially a blob of glue between some > other very useful Perl modules. > > What I'd like to do is validate the parameters coming in to my module, > some of which are for my own use, and others are destined for the other > modules (encapsulated as hashes). > > I'm currently looking at Params::Validate -- but my question is, are > there any other contenders in the ring? There seem to be quite a few. I note on CPAN: Params::Check (and Params::Check::Faster (!)) Params::Util Params::Validate::Micro If I wasn't going to use Params::Validate I would probably use Params::Util -- that's based solely on the author's reputation though. I wrote about using Params::Validate a while back, http://jc.ngo.org.uk/blog/2007/01/15/perl-parameter-validation-and-error-handling/ might be helpful. N From nbowden at dsl.pipex.com Fri Jul 6 01:50:04 2007 From: nbowden at dsl.pipex.com (Nigel Bowden) Date: Fri, 6 Jul 2007 09:50:04 +0100 Subject: Module setup argument validation References: <468D2690.2070304@oucs.ox.ac.uk> <468D7668.3090100@ngo.org.uk> Message-ID: <001301c7bfaa$a63d76e0$0201010a@kcom.com> Nik, very nice article. Nigel. ----- Original Message ----- From: "Nik Clayton" To: "Oliver Gorwits" Cc: "Milton Keynes Perl Mongers" Sent: Thursday, July 05, 2007 11:53 PM Subject: Re: Module setup argument validation > Oliver Gorwits wrote: >> I'm writing a module which is essentially a blob of glue between some >> other very useful Perl modules. >> >> What I'd like to do is validate the parameters coming in to my module, >> some of which are for my own use, and others are destined for the other >> modules (encapsulated as hashes). >> >> I'm currently looking at Params::Validate -- but my question is, are >> there any other contenders in the ring? > > There seem to be quite a few. I note on CPAN: > > Params::Check (and Params::Check::Faster (!)) > Params::Util > Params::Validate::Micro > > If I wasn't going to use Params::Validate I would probably use > Params::Util -- that's based solely on the author's reputation though. > > I wrote about using Params::Validate a while back, > http://jc.ngo.org.uk/blog/2007/01/15/perl-parameter-validation-and-error-handling/ > might be helpful. > > N > _______________________________________________ > MiltonKeynes-pm mailing list > MiltonKeynes-pm at pm.org > http://mail.pm.org/mailman/listinfo/miltonkeynes-pm From oliver.gorwits at oucs.ox.ac.uk Fri Jul 6 07:29:10 2007 From: oliver.gorwits at oucs.ox.ac.uk (Oliver Gorwits) Date: Fri, 06 Jul 2007 15:29:10 +0100 Subject: Module setup argument validation In-Reply-To: <468D7668.3090100@ngo.org.uk> References: <468D2690.2070304@oucs.ox.ac.uk> <468D7668.3090100@ngo.org.uk> Message-ID: <468E51B6.80203@oucs.ox.ac.uk> Nik Clayton wrote: > I wrote about using Params::Validate a while back, Excellent, many thanks. Having looked at the alternatives you suggest, I am going to stick with Params::Validate and Exception::Class after all because they best fit my needs. I'd already written some code with them on the hunch anyway, having needed to factor out some custom validating code from someone's library which I'm preparing for the CPAN. By the way, I'm glad I posted to the list. Usually I would have just pestered poor old Tom and the others on IRC[1] but this time around he wisely suggested I email the list instead :-) cheers, oliver. [1] #miltonkeynes at irc.perl.org -- Oliver Gorwits, Network Infrastructure Group, Oxford University Computing Services From peter at dragonstaff.com Thu Jul 12 08:41:44 2007 From: peter at dragonstaff.com (Peter Edwards) Date: Thu, 12 Jul 2007 16:41:44 +0100 Subject: FW: Exeter University - Open Source community survey Message-ID: <003b01c7c49b$44930810$0501a8c0@DRAGON1> Maybe of interest to any guinea pigs out there :) Cheers, Peter Dragonstaff Limited http://www.dragonstaff.com Business IT Consultancy -----Original Message----- From: A.Rabinovich at exeter.ac.uk [mailto:A.Rabinovich at exeter.ac.uk] Sent: 12 July 2007 15:54 To: peterdragon at users.sourceforge.net Subject: Exeter University - Open Source community survey Dear Peter, We are contacting you because of your contributions to the Open Source community. We are social psychologists from the University of Exeter studying the structure and functioning of the OS movement. We are interested in the movement not just from our personal perspectives, but as a social phenomenon. OS does not appear to make much sense economically. So why does it work? We would like to invite you to participate in an online survey (OS-based) that will take you about 15 minutes to complete. The survey explores several potential reasons why the OS movement is such a success. Among others, it seeks your opinion about the "OS ideology." Recently there have been discussions on OS forums and blogs about this ideology: some people think that it is something that keeps the movement going, others believe that ideology is immaterial to OS success. We are interested in your opinion and in the role that ideology plays in the success of the OS movement. We also ask your opinions about a range of other factors which might be involved. As social psychologists, we are interested to know what importance the OS movement members attach to this community and how this affects intentions to contribute towards projects. We would be grateful if you could spare 15 minutes of your time to participate. The survey can be found here: http://psy.ex.ac.uk/~ar216/survey/index.php?sid=11 Please feel free to forward this link to other members of the OS community. If you have any questions or comments about the survey, we will be happy to answer them; please write to Prof. Tom Postmes (T.Postmes at ex.ac.uk) or Anna Rabinovich (a.rabinovich at ex.ac.uk). Yours sincerely, Prof. Tom Postmes Anna Rabinovich From ziya at suzen.net Sun Jul 15 03:08:10 2007 From: ziya at suzen.net (Ziya Suzen) Date: Sun, 15 Jul 2007 11:08:10 +0100 Subject: use Aspect? (was: Module setup argument validation) Message-ID: <7e7471f80707150308pdfa7e7csa3bd43c3b9e05291@mail.gmail.com> Hi there Just realized! did not send this to the group. It's kind of late now, so let's change the thread: Anyone using Aspect (see message below)? Any good for production use? cheers -z ---------- Forwarded message ---------- From: Ziya Suzen Date: Jul 6, 2007 2:21 PM Subject: Re: Module setup argument validation To: Nik Clayton On 7/5/07, Nik Clayton wrote: > Oliver Gorwits wrote: > > I'm currently looking at Params::Validate -- but my question is, are FWIW, I used this one in a few projects. I think it is the most popular one, but I found that my code became very messy very quickly, trying to check all the calls. It should probably be enough to use it on the modules api methods only. > > There seem to be quite a few. I note on CPAN: > > Params::Check (and Params::Check::Faster (!)) > Params::Util > Params::Validate::Micro Checking the parameters is important but it seems like they are all creating a lot of noise in the code (Although a lot better than doing it by hand, I suppose). A little out side of the topic, but has anyone used Aspect seriously? Maybe checking the parameters using something like this is cleaner? Better? package YoungPerson; sub age { my $self = shift; my $age = shift; # do something useful } sub name { ... } sub address { ... } package main; use Aspect; before { my $context = shift; die "error" if $context->params->[1] > 150; # call stack is different, so it might be little confusing actually } call 'YoungPerson::age'; It is a trivial example, but imagine that with a few subs and a few params each with complicated validation rules and so on... you get the picture. BTW, I am not suggesting to use it. I don't know enough about Aspect (performance?, reliability? debugging? war stories? ...). But looks like a good solution to me. I though I'd mention it. > I wrote about using Params::Validate a while back, > http://jc.ngo.org.uk/blog/2007/01/15/perl-parameter-validation-and-error-handling/ Nice one. Thank you. Cheers --Ziya From tom at eborcom.com Tue Jul 17 00:27:34 2007 From: tom at eborcom.com (Tom Hukins) Date: Tue, 17 Jul 2007 08:27:34 +0100 Subject: Meeting: Tuesday 24th July 2007 Message-ID: <20070717072733.GA68359@eborcom.com> At last: I've managed to announce a meeting with plenty of warning before it happens. Join us for the monthly Milton Keynes Linux and Perl social meeting. The topics of conversation vary, so if you write, use or think about any sort of open source software you might find it interesting. If you don't, there will be beer and you're still welcome to come along. As usual, we will meet at the Wetherspoon's near the railway station (not the one in the snow dome): http://miltonkeynes.openguides.org/?J.D_Wetherspoon%2C_Central_Milton_Keynes I'll be there from around 8pm, but you should arrive and leave whenever suits you - people usually come and go throughout the evening. A few of us usually eat at the pub. If you're worried you might not spot us, please ask off-list for my mobile number. Don't look for the infamous laminated penguins: they've disappeared. See next week, Tom From tom at eborcom.com Tue Jul 17 00:46:00 2007 From: tom at eborcom.com (Tom Hukins) Date: Tue, 17 Jul 2007 08:46:00 +0100 Subject: use Aspect? (was: Module setup argument validation) In-Reply-To: <7e7471f80707150308pdfa7e7csa3bd43c3b9e05291@mail.gmail.com> References: <7e7471f80707150308pdfa7e7csa3bd43c3b9e05291@mail.gmail.com> Message-ID: <20070717074600.GB68359@eborcom.com> Hi, Ziya. I like your idea of using Aspect to validate input: it fits well with AOP's emphasis on separation of concerns. I guess you could also use after {} to assert that you produce the expected output. 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) but I've never used it in production. The module itself doesn't do anything too scary, but relies on Hook::LexWrap for its cleverness, so any concerns about reliability and performance should focus on this. Several people asked me after my talk how well Aspect would cope with production code. I don't know, as I've not tried it, but some people seemed to think it would slow things down significantly. I guess Benchmark will tell you how it performs with your existing code. You might also want to take a look at Sub::Override, or mess with %Your::Module:: manually if you feel especially brave: use YAML; use Your::Module; print Dump %Your::Module::; Good luck: let us know how you get on. Tom From peter at dragonstaff.com Tue Jul 17 02:22:08 2007 From: peter at dragonstaff.com (Peter Edwards) Date: Tue, 17 Jul 2007 10:22:08 +0100 Subject: use Aspect? (was: Module setup argument validation) In-Reply-To: <20070717074600.GB68359@eborcom.com> References: <7e7471f80707150308pdfa7e7csa3bd43c3b9e05291@mail.gmail.com> <20070717074600.GB68359@eborcom.com> Message-ID: <007c01c7c853$f87d4af0$2f00a8c0@DRAGON1> >You might also want to take a look at Sub::Override, or mess with >%Your::Module:: manually if you feel especially brave: > use YAML; > use Your::Module; > print Dump %Your::Module::; I just searched on CPAN for Your::Module ... Doh! From tom at eborcom.com Tue Jul 17 02:47:02 2007 From: tom at eborcom.com (Tom Hukins) Date: Tue, 17 Jul 2007 10:47:02 +0100 Subject: General Confusion (was: use Aspect?) In-Reply-To: <007c01c7c853$f87d4af0$2f00a8c0@DRAGON1> References: <7e7471f80707150308pdfa7e7csa3bd43c3b9e05291@mail.gmail.com> <20070717074600.GB68359@eborcom.com> <007c01c7c853$f87d4af0$2f00a8c0@DRAGON1> Message-ID: <20070717094702.GA69837@eborcom.com> On Tue, Jul 17, 2007 at 10:22:08AM +0100, Peter Edwards wrote: > I just searched on CPAN for Your::Module ... Doh! Don't worry, it's not as daft as announcing a meeting on a date that doesn't conform to our rules. I don't want to confuse people further by rearranging the date, so let's pretend that July has 30 days. Tom From ziya at suzen.net Tue Jul 17 04:58:59 2007 From: ziya at suzen.net (Ziya Suzen) Date: Tue, 17 Jul 2007 12:58:59 +0100 Subject: use Aspect? (was: Module setup argument validation) In-Reply-To: <20070717074600.GB68359@eborcom.com> References: <7e7471f80707150308pdfa7e7csa3bd43c3b9e05291@mail.gmail.com> <20070717074600.GB68359@eborcom.com> Message-ID: <7e7471f80707170458o73ccb39brc1be770834348629@mail.gmail.com> On 7/17/07, Tom Hukins 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 From zen35638 at zen.co.uk Tue Jul 17 05:25:30 2007 From: zen35638 at zen.co.uk (Rod Norfor) Date: Tue, 17 Jul 2007 13:25:30 +0100 Subject: General Confusion (was: use Aspect?) In-Reply-To: <20070717094702.GA69837@eborcom.com> References: <7e7471f80707150308pdfa7e7csa3bd43c3b9e05291@mail.gmail.com> <20070717074600.GB68359@eborcom.com> <007c01c7c853$f87d4af0$2f00a8c0@DRAGON1> <20070717094702.GA69837@eborcom.com> Message-ID: On 17 Jul 2007, at 10:47, Tom Hukins wrote: > On Tue, Jul 17, 2007 at 10:22:08AM +0100, Peter Edwards wrote: >> I just searched on CPAN for Your::Module ... Doh! > > Don't worry, it's not as daft as announcing a meeting on a date that > doesn't conform to our rules. I don't want to confuse people further > by rearranging the date, so let's pretend that July has 30 days. > I didn't want to mention anything, just thought it was probably to do with some people visiting vienna... but that's not until next month.... confusion reigns..... Of course the meeting is probably cursed, as normally happens when we change dates... cheers. Rod > Tom > _______________________________________________ > MiltonKeynes-pm mailing list > MiltonKeynes-pm at pm.org > http://mail.pm.org/mailman/listinfo/miltonkeynes-pm From tom at eborcom.com Mon Jul 23 04:48:57 2007 From: tom at eborcom.com (Tom Hukins) Date: Mon, 23 Jul 2007 12:48:57 +0100 Subject: Meeting: Tuesday 24th July 2007 In-Reply-To: <20070717072733.GA68359@eborcom.com> References: <20070717072733.GA68359@eborcom.com> Message-ID: <20070723114857.GA57459@eborcom.com> Hi all, I thought I should send a quick reminder that we're meeting tomorrow, on Tuesday 24th: http://mail.pm.org/pipermail/miltonkeynes-pm/2007-July/000261.html We're not meeting on the 31st as you might have expected. See you soon, Tom From peter at dragonstaff.com Thu Jul 26 17:17:02 2007 From: peter at dragonstaff.com (Peter Edwards) Date: Fri, 27 Jul 2007 01:17:02 +0100 Subject: YAPC::EU 2007 in Vienna Message-ID: <002001c7cfe3$9808d530$6501a8c0@DRAGON1> I?ve booked my conference ticket, travel and accommodation for YAPC::EU in Vienna Going from Heathrow (LHR) Monday 27th August on BA0704 at 14:55 to Vienna (VIE), returning on BA0701 Thursday 30th August at 14:15. Staying at the Levante Parliament http://vienna.yapceurope.org/ye2007/wiki?node=StayingAtLevanteParliament Regards, Peter Dragonstaff Limited http://www.dragonstaff.com Business IT Consultancy?