https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=22407
David Cook <[email protected]> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |[email protected] --- Comment #13 from David Cook <[email protected]> --- Honest question: Why do this: sub guarantor { my $self = shift; my $guarantor_rs = $self->_result->guarantorid; return unless $guarantor_rs; return Koha::Patron->_new_from_dbic($gaurantor_rs); } Instead of this: sub guarantor { my $self = shift; my $guarantor; my $guarantor_rs = $self->_result->guarantorid; if ($guarantor_rs){ $guarantor = Koha::Patron->_new_from_dbic($gaurantor_rs); } return $guarantor; } I admit that the latter has 3 more lines than the former, but the latter is way easier to read, easier to debug, and easier to add error-handling. Actually, that latter should probably double-check the output of Koha::Patron->_new_from_dbic() before returning. I've noticed a lot of Koha code directly returning the output of a method call, and it drives me crazy. We should do more data validation. It'll mean fewer bugs and easier maintenance. -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug. _______________________________________________ Koha-bugs mailing list [email protected] https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-bugs website : http://www.koha-community.org/ git : http://git.koha-community.org/ bugs : http://bugs.koha-community.org/
