<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Philippe Marschall wrote:
<blockquote
cite="mid:66666f210712301329i6a6222bpf9392570d79f7c00@mail.gmail.com"
type="cite">
<pre wrap="">2007/12/30, Nevin Pratt <a class="moz-txt-link-rfc2396E" href="mailto:nevin@bountifulbaby.com"><nevin@bountifulbaby.com></a>:
</pre>
<blockquote type="cite">
<pre wrap="">John M McIntosh wrote:
</pre>
<blockquote type="cite">
<pre wrap="">Assuming you want a unique value, and you don't care if it's in order
then you can just do
UUID new
-> e0090895-4a12-4ef6-82e0-9acefc76ff9c -> asString36 ->
'9alvh9w807elbql3xdq6l05pc'
that will be unique.
buf if you must start at 1 and go to infinity then you need to bother
with
Semaphore forMutualExclusion
and do things like remember what the last number was...
more code and options to get it wrong.
</pre>
</blockquote>
<pre wrap="">Thread safety might not matter.
For example, my site bountifulbaby.com uses the technique Tom suggests,
via a class variable and a #newID class method, to generate product item
numbers whenever we add a new product for sale on the website.
Adding a new product for sale is only done via the Administrator page.
The risk of two different people here at Bountiful Baby both adding a
new product to the website at the exact same time is virtually nil.
</pre>
</blockquote>
<pre wrap=""><!---->
Yeah right. Kinda remembers me of "that vulnerability is completely
theoretical".
Cheers
Philippe
</pre>
</blockquote>
<br>
DTSTTCPW<br>
<br>
Do The Simplest Thing That Could Possibly Work.<br>
<br>
For a long time, I was the only person that even had the password to
the Bountiful Baby admin page. <br>
<br>
And even with a few more people now, I would still maintain that the
risk of two different people here at Bountiful Baby both adding a new
product to the website at the exact same time is virtually nil. And
even if it happened (which it won't), the only harm done is the second
item would have to be added again.<br>
<br>
So again, I would say that whether or not a sequential ID needs the
overhead of a protection semaphore depends on what it is being used for.<br>
<br>
Nevin<br>
<br>
</body>
</html>