Morphir is a project to share business logic across people and technologies. By establishing a commong data structure for storing business logic, Morphir enables an ecosystem of tools to define and process business logic in useful ways. Before we get into the tutorial, it's worth considering what we mean by business logic. Take the essence of any business application, take away all of the infrastructure, concurrency, messaging, etc. What's left is the essense of the application - it's reason for being. That is the business logic. It is how the business experts would describe the application in the language of the business.
For this tutorial, we'll use the example of a surfboard rental business.
The business is simple: Rent surfboards whenever they're available.
Seems simple enough, so why would we consider doing it with Morphir. One of our goals is to optimize the feedback loop between the business and developers. Business experts tend to the think of an application in its business terms.
In this case they might be thinking something like:
where:
inventory
=
∑ items in the store
returns
=
⌊
( ∑ scheduled returns )
*
late return ratio
⌋
reserved
=
⌊
( ∑current reservations )
*
no show ratio
⌋
This specification gets handed to developers, who immediately start thinking of how to split it up to run most efficiently on the various technologies. They might view it as:
The problem comes when, inevitably, developers and business experts come and go, documentation gets stale, and other factors cause the knowledge of the application's expected behavior to get out of sync, stale, or lost over time. As that happens, individual technologies become the system of record for the application's behavior. What's left is this:
At this point, it becomes difficult to reason about the application and what changes will do to it. That's a major problem for a large application. It leads to legacy debt, higher risk, and slower delivery.
We want to get back to the business logic being the main asset of the application. The optimal efficiency is a state where the business logic is the central developer focus that gets continuosly projected onto the various technologies of the moment:
So with that out of the way, let's dive in...