[Date Prev][Date Next]
Sorry to resurrect this stale thread, but I have news to report. In
short, I have changed my tune and made progress in the area of
auto-incrementing identifiers. I revisited my solution to the
requirement based on Howard's feedback, and not only did I implement it
as prescribed by the best practice of storing the counter in the
directory, I made this method available to all objects in my framework
with a one-liner.
This is the open source process in action. I offer my thanks to the
To see the new algorithm work, just add a comment to the weblog:
Don't be afraid. If lightning was going to strike anyone for this
exercise, it would've surely been me :)
Looking at the archives, I'm definitely not the only one doing it like
This is an argument for mediocrity. In the midst of an excellent post, I find
this position surprising.
I agree, and I wasn't implying that because others do something it's
automatically a good idea. I'm just suggesting that this is going to be
the natural path for people who aren't shown the alternative up front.
I'm actually presenting both techniques just in case somebody still
finds cause to use a memory-resident incrementor instead.
There is a motivation I didn't mention in my original posts. An implicit
goal of my efforts was to make my code work with anyone's directory,
regardless of what they have in it. I wanted to leave all knowledge of
specific object classes, attributes, identities, and access control
rules to the implementing organization (and to the M in MVC). I suspect
a lot of other developers are responding to this same subconcious need,
too. With this requirement, I skirted the issue.
To a small extent, there is also still an issue of performance and
perhaps scalability with this best practice. In the general case, the
database vs. memory approaches for determining the next identifier
compare at roughly 20:1 in terms of speed and resources. However, with
both under a second and still only a fraction of the typical cost of
creating an entry, I would conclude this consideration is barely relevant.
Why did I use a country object for my counter? Why not; it's one of the
smallest classes in the core schema.
If this issue keeps coming up, as no doubt it will, feel free to send
people to me as well as the list archives. I consider myself indebted,
and am willing to work it off.
Yours in all humility,