Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend best-practice list: avoid using static "global mockable state" providers/top-level functions in the favour of injectable ones #7

Open
qwwdfsad opened this issue Apr 11, 2023 · 0 comments

Comments

@qwwdfsad
Copy link
Member

It would be nice to recommend avoiding using "global" state in the libraries, that later is almost impossible to test and/or mock.

We tend to favor explicitly spelled-out APIs for the such state: datetime's Clock.System.now(), Okio's FileSystem.DEFAULT.read* as opposed to top-level now(), read(path) etc. (the most notable existing API that falls into this trap is coroutine's Dispatchers.Default)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant