3 ms·
This post is chock-full of antipatterns. Both the singleton pattern and double checked locking should be avoided.
by hendzen 11y ago
This post is chock-full of antipatterns. Both the singleton pattern and double checked locking should be avoided.
- hesdeadjim 11y agoYea it's easy enough to use dependency injection to satisfy these supposedly "global" requirements. About the only global state I can tolerate is read-only constants, but even then you are much better off with DI just because of testing.
- bkeroack 11y agoDI is an antipattern.
- vhost- 11y agoHow do handle configuration? Your program starts up, generates some settings, then those need to be shared across all threads to avoid incurring the cost of regenerating during every call to a function.
- ajankovic 11y agoBut in that case config values are to be treated as constants (read only). You don't have concurrency issues for code that doesn't change.