[PBP-pm] Book review of PBP

C. Garrett Goebel ggoebel at goebel.ws
Sun Nov 20 06:26:15 PST 2005


Nice reviews.

On Sun, 20 Nov 2005, Andrew Savige wrote:
>
> I'm interested to hear opinions on:
>
> 1) What new guidelines would you like to see added to the book?

How to write threadsafe code.

But you've already got that covered with "Tips on coding for concurrency"
and your concerns with Class::Std's thread safety issues. It looks like
the mod_perl's CHECK block issue will be cleared up in the next release.


> 2) What guidelines do you disagree with or not follow?

The guideline on multi-contextual return values (ch9, subroutines). I
disagree with encouraging a finer granularity of context sensitivity
without discouraging subroutines as contextual homonyms.

Programmers are used to getting different results from different inputs.
But we're not that used to the idea of return value context as one of
those inputs.

Personally, in cases where no single return value is appropriate for a
list returning subroutine... I'd rather see an object returned so the
DWIM aspect is dropped in favor of self-documenting code:

my ($status_obj) = get_server_status($server_ID);

my $load    = $status_obj->get_NUM();
my $is_up   = $status_obj->get_BOOL();
my $summary = $status_obj->get_STR();


Which would look nicer if the accessors were aliased to be more
descriptive:

my $load    = $status_obj->load();
my $is_up   = $status_obj->is_up();
my $summary = $status_obj->summary();

cheers,

Garrett



More information about the PBP-pm mailing list