The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

nimbus154 (1) [Avatar] Offline
#1
I’m attempting to apply the concept of functional domain modeling to a web application. Below is a breakdown of an HTTP request/response cycle. Could I be so bold as to ask for thoughts on whether this breakdown accurately reflects the structure presented in the book?

UI Layer:
User fills out a web form and submits it to the server.

Application Layer:
An HTTP route handler receives the form, extracts fields, and passes the parameters to a service function in the domain layer. Once the service method returns, this layer returns a new view to the client.

Domain Layer:
A service function does any of the following as needed:

  • creates an aggregate with a factory

  • invokes other service methods to perform business logic on an aggregate

  • persists and retrieves aggregates with a repository

  • validates aggregates

  • emits events

  • In this understanding, service functions provide an interface into the domain layer, a role which, I think, is supposed to be played by the aggregate root.

    Thank you so much for your thoughts and time.
    Debasish Ghosh (116) [Avatar] Offline
    #2
    The steps that you have listed are quite intuitive and works with minor variations across various web applications. The challenge is to model the steps that you have listed under Domain Layer in a functional way. The fact that you have listed them in sequence implies that you are thinking of them as sequential steps. Now you map how to model them using pure expressions in a functional way. Hint: Think in terms of monads and Kleislis.

    Thanks.