Greg Stein wrote:
> Is there a lot of code duplication around those next-key columns and
> generation? Could you write a utility function that manages all of
> them in the same way? The initialization, the fetching and increment,
> etc? "Here is a table. Do your thing."
I looked into this. There is some duplication, yes.
Certainly the creation of the initial `next-key' row looks the same across
the various tables. But there's not much to be gained by trading one
function call (DB->put) for another.
As for the more complex logic of fetching the next-key value and bumping it
to a new value, different tables do this different ways. Some just
get-then-bump as an atomic operation. Some get-then-do-something-then-bump
(to avoid burning up keys, perhaps). And a naive abstraction for those bits
that are identical in behavior would either need to have generic error
messages that don't reveal the table being operated on (bad), or dynamically
allocated error strings which may never be used (not ideal), or be passed in
a collection of static error strings for possible use (ugly). So, again,
I'm not sure the abstraction is really worth it at this stage.
C. Michael Pilato <cmpilato_at_collab.net>
CollabNet <> www.collab.net <> Distributed Development On Demand
Received on 2008-10-29 15:16:42 CET