Hi Oded!

I feel that the shorter the method, the better. Generally a method should receive parameters (which is generally a bit more complex in Perl 5 due to the @_ stuff), possibly validate them, and then return a value that is a single expression. The reason for this is that that way one can more easily over-ride such methods or inherit from them and have greater code re-use. I recall seeing a very long method in the Catalyst (a web-framework for Perl’s) codebase, and I needed to override a very small expression out of it in order to make sure that it did not treat URLs with a trailing slash (“/”) the same as URLs without them.

Of course, I sometimes write my methods and functions longer out of laziness, and because they acquire cruft, but this is the ideal. One of the codebases that I’m most proud of in having short, single-purpose methods is Test-Run. I’ve spent a long time perfecting it, partly because I started from an old and monolithic and completely non-OOP codebase (reportedly dating back to Larry Wall’s perl 1.0), which I decided to whip into shape, and while completely breaking backwards-compatibility.

And finally, can you please get comments previews here? I don’t know if this comment would be OK. Stupid WordPress.