in reply to Refactor method calls or not?
Of course you have to change your method calls, and maybe this is a problem for you.%ALLOWED_TABLES = map {$_ => 1} qw(company financialDiary); sub add_data { my ( $self, $table, $data ) = @_; die "bad table!" unless $ALLOWED_TABLES{$table}; my $data = $self->_generic_insert( $data, $table ); $self->{ _dbh }->commit if ! $self->{ _error }; return $data; }
Regarding transactions, I think the transaction control belongs in the code that is calling these methods, not in the methods themselves. These data access methods don't know anything about the context they are being called in.
UPDATE: fixed array name mismatch and changed to hash
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
(Ovid) Re: Re: Refactor method calls or not?
by Ovid (Cardinal) on Jan 19, 2002 at 00:00 UTC | |
by mpeppler (Vicar) on Jan 19, 2002 at 04:45 UTC | |
by perrin (Chancellor) on Jan 19, 2002 at 01:26 UTC | |
|
Re: Re: Refactor method calls or not?
by Juerd (Abbot) on Jan 19, 2002 at 00:04 UTC | |
by perrin (Chancellor) on Jan 19, 2002 at 01:13 UTC | |
|
Re: Re: Refactor method calls or not?
by Anonymous Monk on Jan 19, 2002 at 00:06 UTC | |
by ichimunki (Priest) on Jan 19, 2002 at 04:27 UTC | |
by Ovid (Cardinal) on Jan 19, 2002 at 11:20 UTC |