Skip to main content

Create GUID From Your Front End.


The Problem Statement
GUID is synonym with .Net platforms, Instantiating it from the normal C# syntax in .Net environment is relatively easy, but instantiating it at the front end using Typescript/Javascript is somehow quite tricky, Assuming that we have a frontend logging/crashreport mechanism that is reporting directly to our data store, and to differentiate each logging/crashreport, we have standardized it to use GUID. We are how required to create a GUID generator before assigning its value alongside with our logging/CrashReport.

The Code Snippet
From the code above, We are making use of Math.Random functions to perform such actions, Note this is totally different from GUID generation using .Net Framework ( where it involves more algorithm to generate one ) But, somehow it will generate something similar to one,

The Consideration
Based on StackOverflow, The code snipped does not follow the RFC4122 compliance in generating an UUID. To meet the Compliance we might need to tweak our code like below
From the code above, taken from Stack Overflow We make use of date function to generate the UUID, with this implementation, we somehow reduce the possibility that there might be some id collusion at our data store.

Conclusion
From the article, we may conclude that there are many ways to generate an unique identifier for our system, There are certain criteria that has to follow to make it compliance with the industry standard. We may understand more on the discussion on any changes at the Stack Overflow link.
Published on : 4-Jan-2019
Ref no : DG-WPUB-000004

About Author

My photo
Wan Mohd Adzha MCPD,MCSD,MCSE
I am passionate about technology and of course love Durians. Certified by Microsoft as MCP Since 2011. Blogging from Malaysia

Comments