[JOB] Perl Software Developer and Database programmer

Andy Armstrong andy at hexten.net
Thu Feb 23 13:44:43 GMT 2006

On 23 Feb 2006, at 13:28, Peter Hickman wrote:
> my $name_of_feed = feed_name(@list_of_names);
> then I would say that it was wrong but if you are using it to add  
> some semantic information to the code as in
> validate(feed_name(@list_of_names))

The latter.

> then it would be right. The first tells you nothing that the  
> receiving variable name does not and the fact that you have written  
> a subroutine to do this might lead people to think that feed_name()  
> is actually doing something important. The second tells you  
> something that is not readily apparent, but of course a comment  
> would also do the job.

You don't have to use a comment everywhere you call the sub though -  
using the name is automatic. Why put something in a comment when it  
could be intrinsic to the code?

> How would you feel if you came across code littered with routines  
> like add_two_numbers(), append_item_to_list(),  
> check_hash_key_is_defined() and the like. Too much syntactic sugar  
> for my liking.

Oh yeah - that'd be shit. But add_two_numbers() describes a language  
intrinsic, bump_overall_total() might do (nearly) the same thing but  
is potentially makes code more readable. It's the same as the  
distinction between

#define THREE 3


#define RETRY_COUNT 3

(I've seen code that did

#define HUNDRED 107

but they actually had a valid excuse. Well nearly)

Andy Armstrong, hexten.net

More information about the london.pm mailing list