in reply to Re^2: Easily catalog subroutines with a synopsis comment
in thread Easily catalog subroutines with a synopsis comment
Some of my routines have long names, but they are not usually public API's. They are used internally there to give context when they are being called. I also try to use names so that they work well with variables that are being passed to help give context.
Here is an example that I used in reference to a baseball game I am writing.
################################################# sub __playball_game_over { my $self = shift; my $result = shift; return if $self->__playball_inning_get < 9; if ( $self->__playball_team_on('offense')->get_id eq $self->away_team->get_id) { return if $result->run_scored; return 1 if $self->__playball_score_for('home_team') > $self->__playball_score_for('away_team'); } elsif ($result->run_scored) { return 1 if $self->__playball_score_for('home_team') > $self->__playball_score_for('away_team'); } else { return 1 if $self->__playball_score_for('home_team') != $self->__playball_score_for('away_team'); } return; }
I try my best to avoid long names, but I will use them to clarify my code. Code should be written like it is going to be read.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Easily catalog subroutines with a synopsis comment
by BrowserUk (Patriarch) on Apr 19, 2008 at 19:43 UTC | |
by Herkum (Parson) on Apr 20, 2008 at 00:41 UTC | |
by BrowserUk (Patriarch) on Apr 20, 2008 at 00:58 UTC | |
by Herkum (Parson) on Apr 20, 2008 at 05:21 UTC |