4 ms·
Pattern 1 you can pass in a logger there or a noop logger and not have any duplication.
by hitsthings 8y ago
Pattern 1 you can pass in a logger there or a noop logger and not have any duplication.
- rini17 8y agoThis means to interrupt whatever you're doing and implement the logger and do the associated refactoring.
- d--b 8y agoWell, I could do operations for logging that are otherwise not required... if(log) { logger.write(computestuff()); }
- meheleventyone 8y agoDepending on language if you have first class functions you could also do: logger.write(computestuff); Or for parameterized functions: logger.write(() => computestuff(a, b, c)); Then all that logging policy stuff can live with the logging and doesn't need to be checked explicitly throughout the codebase.
- pavel_lishin 8y agoIt's not my job to pass a logger to some given class method. Should I pass in a database handle and a DNS resolver, too?