Improvements Overview
Learn how we can further improve the different aspects of our application.
Overview
How this application could be improved falls into two categories, namely general advice that should be applicable to any type of code and advice related to Functional Programming.
First, regarding the framework and its parameters, we should pass such parameters to as few functions as possible. We’ll want to keep everything related to receiving and responding as close as possible to the surface of the application. This content should appear in the outer layer of a hexagonal architecture. In a layered architecture, these concerns should only appear in the controller but never in the underlying service or database layers. This makes a large part of our application easier to understand and test.
FP helps with its focus on pure functions and immutability. When writing such functions, we try to avoid things like request or response parameters altogether. At a minimum, a focus on purity encourages us to use them only in a limited number of places. Immutability avoids bugs and complexity caused by mutating incoming requests and responses. So, by default, FP encourages us to avoid infecting our entire code with these framework concerns.
Get hands-on with 1200+ tech skills courses.