in reply to MVC Catalyst Architecture - City, State Zip locator
When something goes from working to not working and you think you didn't change anything significant, you usually just made one dumb little mistake. If you want debugging to be easy, put lots of feedback in your code to report when it's used incorrectly (and write tests for it). Try this for starters-
use Carp; sub get_zip { my $self = shift; my $city = uc(+shift) || croak "No city given"; my $state = uc(+shift) || croak "No state given"; my $zip = $self->single({ city_name => $city, state_abbr => $state }, { columns => [qw/zip_code/] } ); if ( $zip ) { return $zip->zip_code; } else { carp "No ZIP found for city_name:$city and state_abbr:$state"; } return undef; }
I'm a fan of the die early, die often edict (hence the croaks) but you can tone it down or adapt. The main idea is just to never assume that your code will be called as designed and account for that. See also Params::Validate.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: MVC Catalyst Architecture - City, State Zip locator
by Anonymous Monk on Jul 21, 2008 at 19:02 UTC | |
by Your Mother (Archbishop) on Jul 21, 2008 at 23:40 UTC | |
by Anonymous Monk on Jul 22, 2008 at 13:36 UTC |