Hacker News new | ask | show | jobs
by hesdeadjim 3991 days ago
Yea 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.
2 comments

How 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.
But 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.
DI is an antipattern.
who told you that? you'd better not listen to that guy anymore.
What are better alternatives? Service locator?