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

>But lately, I've come to think it's better for code to explicitly reveal its dependencies via its public API.

The downside is that you're forcing a new dependency on the user of your API, and that dependency may be an implementation detail that the user should not be concerned with.

You could argue that the user was already depending on that singleton because singletons are effectively globals. But that's not necessarily true as the singleton could have package/module visibility.

I'm not convinced that all encapsulation should be sacrificed on the altar of TDD.



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

Search: