Where do we put "asking the world" code when we separate computation from side effects?

Posted by Alexey on Programmers See other posts from Programmers or by Alexey
Published on 2013-11-02T13:38:41Z Indexed on 2013/11/02 16:00 UTC
Read the original article Hit count: 328

According to Command-Query Separation principle, as well as Thinking in Data and DDD with Clojure presentations one should separate side effects (modifying the world) from computations and decisions, so that it would be easier to understand and test both parts.

This leaves an unanswered question: where relatively to the boundary should we put "asking the world"? On the one hand, requesting data from external systems (like database, extental services' APIs etc) is not referentially transparent and thus should not sit together with pure computational and decision making code. On the other hand, it's problematic, or maybe impossible to tease them apart from computational part and pass it as an argument as because we may not know in advance which data we may need to request.

© Programmers or respective owner

Related posts about functional-programming

Related posts about domain-driven-design