The Template
Written by Ivan Dugalic - October 2021
A template is a simple and yet potent tool.
The simple idea is to pass data type as a parameter, so we don’t need to write the same code for different data types.
For example, a software company may need sort()
for different data types.
Rather than writing and maintaining the multiple codes, we can write one sort()
and pass data type (String
or Number
) as a parameter.
Usually, a software company1 needs more than just a simple sort().
It requires a template for modeling the flow of information in any business.
The Flow
On a higher level of abstraction, any information system is responsible for handling the intent (Command
) and, based on
the current State,
produce new facts/decisions (Events
). The system’s new State
is then evolved out of these Events .
You repeat these steps.
To illustrate the flow better, we can use event modeling.
- User submits the form on the page by clicking on the button
- The intent to change the system is explicitly captured/modeled as a Command/
C
. - Command is handled by the decider component, which State/
S
(yellow) is represented in the swimlane at the bottom. - Based on the current State and the Command it received, the Decider will make new decisions/Events/
E
- New Events will update/evolve the State of the Decider (yellow), and the View (green)
- The View state is constructed per need to serve specific pages with data. Every page can have its View.
The ‘FModel library’2 is offering implementation of this flow in a very general way. The flow is parametrized with C, E, and S parameters.
The responsibility of the business is to specialize in their case by specifying concrete Commands, Events, and State.
For example, Commands
=CreateOrder, AddItemToOrder; Events
=OrderCreated, ItemAdded, State
=Order(with list of Items).
Check out the concrete example here.
This is a foundation for all software we write to support our own business. It started as inspiration and evolved in the software library we share with you for your benefit. The idea is straightforward, and it can be implemented in almost any modern programming language which possesses a type system. Check out the TypeScript version of the library here.
Specification by example
Specification by example is a collaborative approach to defining requirements, which you should be focusing on. These specifications will just run within our abstract and general flow, guaranteeing the correctness of the program. Essentially, you need both generalization and specialization to design an information system effectively.
The Event Modeling exercise result is a blueprint of the overall solution, describing the system and how it changes over time.
By pivoting the blueprint by 90 degrees, you would practice specification by example
to collaborate on the scenarios in more detail.
By following this approach, you will be able to postpone important design decisions. This is a sign of good and cost-effective architecture.
In the following blog posts, we are going to discuss these decisions in more detail.