14 Business logic design
This chapter covers
- How to organize and structure both server and client applications
- How to make a web server with Servant and our application framework
- How to approach validation, and what is applicative validation
Sometimes, it’s hard to recognize what’s a part of business logic and what’s not. I can imagine some scientific code in Agda, Idris, or Coq that’s written not for serving business but for verifying some scientific ideas, and therefore it’s strange to call it “business logic.” However, in research-only companies, such code will be business logic.
In my Functional Declarative Design methodology, the term “business logic” is defined mechanistically. All code we develop and put into the Free monadic environment of the framework will count as business logic, no matter if it describes an actual domain or does something auxiliary. Explicit business logic that’s well-understood and well-written can be compared to good literature telling a complete story — a story about what really matters for your business. Not particular subsystems, not particular services, but rather sensitive data you don’t want leaked. Exposing the details of your framework seems safe, but your business logic is your commercial advantage and should be kept secret.