Many problems in your application architecture will disappear when you push IO operations to the beginning and end of an operation, while keeping the middle free of any IO.
Software exists to support humans on specific tasks, yet most software is designed in a inappropriate way. This article will explore how to make software more task-oriented.