Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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.



Consider applying for YC's Winter 2027 batch! Applications are open till November 2.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: