Services and modules

There has been some debate in my team about how to define and differentiate between a “service” and a “module”.

Here is my proposal: A module exists to fulfill some technical purpose. (A good module exists to fulfill one and only one technical need, aka separation of concerns) A service, on the other hand, exists to fulfill some business purpose.

For example, I wrote a job scheduler (Sorcerer) that we brought into our system as a module. This module has a well defined technical purpose: to schedule and execute workflows. One of the use cases of this module has been to process audience-related data for our customers. This use case is fulfilled by a service that runs a specific set of jobs and tasks (using the Sorcerer module) in order to achieve the aforementioned business need.

I think having these definitions as guidelines helps me structure my code because one of the most difficult decisions to make while designing and developing a system is knowing the right level of abstraction and encapsulation in order to give a proper balance of indirection and simplicity.