I'm trying to improve the responsiveness of an app. The user indicates they want to add a Song object to a Playlist. To do so, I create a new Song object, save it to my server to set its ID, then, when the server responds successfully, I add the Song object to the Playlist.
This has the side-effect of giving the user an awkward delay between their action and the app's response.
I am wondering if it is OK to generate the GUIDs for my entities client-side instead of passing an object with an empty GUID to NHibernate (which then sets it while working with my Sql Server DB.)
I would be using this method to generate a GUID:
'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8);
return v.toString(16);
});
I am concerned about collisons, though. Should I be? Or are client-side and server-side generation of GUIDs mostly the same?