-
Notifications
You must be signed in to change notification settings - Fork 10
How about new UUID(...)
?
#45
Comments
FWIW, this has been discussed before. |
If JS were a strongly OOP language, I might give more weight to this argument, but it's a blend of OOP, functional, and... well... whatever other coding paradigms people choose to layer onto of JS. There's plenty of prior art for factory methods like
This was necessitated by the requirement that there be a cryptographic source of randomness, which is currently only available in contexts where |
Fair points. It was late and I must have confused "create" with "crypto", there is admittedly no "create" in |
Whether it is required to use specifically a cryptographically secure RNG or not, is now beside the point since if |
In light of there being a
URL
class, with parsing and what not and how a UUID is semantically a kind of datum, doesn't it make sense -- also to allow for extending the class(if applicable) et cetera -- to instead design this as a class of which objects can be instantiated?Some additional remarks:
create...
-named methods are a bit of an "oxymoron" in OOP, looking at the existence ofnew
. If you want to create an object, usenew ...
; we even havenew String(...)
so a UUID should easily make the cut and looks terser and clearer, in my opinion.Lumping this into the
crypto
module, while making a certain kind of sense from one or the other taxonomical perspective, is a bit of a miss as well -- UUIDs aren't just used for and in cryptography, and prefixing and thus effectively making it more verbose a class of "universal" identifiers seems to me unnecessary. Why not just put it in the global context, likeJSON
,URL
and some of the other similar classes?Not
new UUID(...)
-specific admittedly -- just as applicable tocrypto.randomUUID(...)
-- but either way a constructor likeUUID
should be open for extension through allowing additional options in the future, to accommodate for other UUID versions and variations and every other kind of parameter there would come a need for.The text was updated successfully, but these errors were encountered: