From: Robert Dober Date: 2008-06-19T06:34:19+09:00 Subject: Re: Rather validate values or use exceptions? On Wed, Jun 18, 2008 at 11:11 PM, ara.t.howard wrote: > > On Jun 18, 2008, at 3:08 PM, Joshua Muheim wrote: > >> After googling for Race Condition I guess I know now what this should >> be, but I don't know how to avoid it...? Any suggestions? :-) > > try to find it, if it doesn't race an exception you're all good. rescue the > exception when not found if that makes sense. in otherwords basically your > second approach. > yes maybe it will become clearer to you if you imagine that in your first approach you would need to lock the table before executing your if statement, and that of course is a dangerous, resource consuming approach. The second approach just uses one single atomic (at least at the abstraction level we are operating here) acess. Cheers Robert -- http://ruby-smalltalk.blogspot.com/ --- Les mêmes questions qu'on se pose On part vers où et vers qui Et comme indice pas grand-chose Des roses et des orties. - Francis Cabrel