2 ms·
I would say that logging and memory allocation are special cases. They're things that need to be done by literally ALL your code. I agree it would be complete
by chubot 9y ago
I would say that logging and memory allocation are special cases. They're things that need to be done by literally ALL your code.
I agree it would be completely silly to change the signatures for a bunch of methods just to print something.
But sometimes you absolutely DO want to inject dependencies for things. The Lua VM is parameterized by the allocator it uses, which is useful in practice.
And I would distinguish between logging and program output. Logging can be an exception, because it doesn't need to tested. You probably don't want your unit tests to fail if your debug logs change.
But maybe in some situations you have some really critical logging, and you want to test that part. Then you can parameterize that code by the logger.
Although honestly I would usually just write a shell scripts and invoke "diff".
So yeah I don't agree with absolutely pure DI or pure functional programming. But I definitely think the ideas there will help you structure better programs.