3 ms·
Depending on the language used sometimes you can even hide the type of the singleton instance in a function body (also assuming the PL support local static decl
by sixthDot 2y ago
Depending on the language used sometimes you can even hide the type of the singleton instance in a function body (also assuming the PL support local static decls), so instead of having `TypeX.instance()` you can just have `xInstance()`.
Otherwise, the article does not mention the problem of race conditions but sometimes it might be better to use static constructors instead of performing lazy construction in the instance getter.