concept module in category system administration

This is an excerpt from Manning's book Functional and Reactive Domain Modeling.
Model behaviors as functions in modules, where a module represents a coarse unit of business functionality (for example, a domain service). This way, you separate state from behavior. Behaviors compose better than states; therefore, keeping related behaviors in modules enables more compositionality. Keep in mind that behaviors in modules operate on types that the ADTs represent.
Cohesive— A module is strongly cohesive and has loose coupling with other modules. Published contract— A module never exposes its implementation details and publishes only well-formed algebra to its clients. First class— A module is implemented in terms of a first-class construct of the language and can be composed to form larger modules.[1] 1Not all languages offer support for first-class modules. Those that do have definite advantages over those that don’t. Scala offers first-class support for modules.
1Not all languages offer support for first-class modules. Those that do have definite advantages over those that don’t. Scala offers first-class support for modules.
Vocabulary— A module must have a proper name, and all module behaviors must have names—all of which form part of the ubiquitous language of the domain model.
You have the class Account and then you define a module that defines the algebra for the Show protocol for the domain elements. The next step is to provide implementation for each of these protocol elements:
trait DomainShowProtocol extends ShowProtocol { implicit val showAccount: Show[Account] = new Show[Account] { def shows(a: Account) = Success(a.toString) } implicit val showCustomer: Show[Customer] = new Show[Customer] { def shows(c: Customer) = Success(c.toString) } //.. } object DomainShowProtocol extends DomainShowProtocol
In this section, you’ll take a deep look inside the meatiest module. You’ll explore all parts of the implementation that make it organized as a module and see how they interact with the other modules and data structures of our model. From our implementation, you’ll consider AccountService as the candidate module to elaborate on. You’re familiar with most of the implementation of this module by now.[2] Still, we’ll introduce new types in this implementation, make it more domain-friendly, and integrate many of the concepts introduced separately in earlier chapters. This is a detailed exercise, and you’ll explore this module incrementally through the next few sections.
Figure 5.3 annotates the various parts of a module definition for AccountService. It elides the operations, but highlights the issues that you need to remember when you define a module on your own.