Comment by commandlinefan

3 years ago

> lies in the context preparation

The right fix here is to simplify the context preparation - make the functions more self contained and less dependent on external scope.

This is not always in your control - especially if you're using libraries and frameworks. But also there are sometimes complex functions that (need to) combine lots complex data (say from multiple APIs) together to produce results, and there is not much that can be done about it.

Take a structured document diff for example - its seemingly simple, diff(documentRepresentation1, documentRepresentation2) -> diffDocument. But in actual reality it has to handle all kinds of edge cases in the structure of the inner documents, and preparing the structure of those documents is hard enough that you actually need to build helper functions to make it easier to make a variety of them.