|
|
|
|
|
by chii
998 days ago
|
|
> When you write modular code that minimizes assumptions about its context, that situation is a common occurrence. so your code isn't modular after all, because the code is _doing_ logging as a side-effect of the actual functionality. The modularity of your code should mean that the outcome of the functionality is packaged into a bundle of data, and this bundle includes information about errors (or warnings) - aka, a status result. The caller of this module will inspect this data, and they themselves will decide to log (or, if they are a module of their own, pass the data up again). This goes on, until the data goes into a logging layer - solely responsible for logging perhaps. |
|
I suppose this approach would make most sense in event-driven apps where no particular processing takes any meaningful amount of time, so you're constantly revisiting the top-level loop, where the "logging layer" could live. However, most software isn't written this way.