What makes Espresso unique is Reactive Programming: declarative, spreadsheet-like rules. These enable you to deliver update business logic 10X faster.
While rules hold enormous promise, they operate differently than conventional programming. Shown conceptually in this video, this page shows how they work.
For more information, see
First, we declare spreadsheet-like expressions
for database columns, to formalize our Check Credit solution. The rules look very much like the infamous cocktail napkin spec, to collaborate with Business Users:
A Validation, to ensure the CreditLimit is greater than the Balance, where
The Balance is the sum of the unShipped OrderTotals
Which is the Sum of the OrderDetail Amounts
Which is the UnitPrice * Quantity
Where the UnitPrice is copied from the Product
We enter these rules directly into Espresso.
The system parses them to determine the rule dependencies, shown by the arrows. You can think of these as declarative triggers, ready to Detect and Propagate Changes to dependent data.
And that’s it. Our 5 simple rules are completely executable - no invocation logic, no persistence code.
Let’s see how rules process an Update Request
Though we might have defined the rules for Place Order, they automatically address other transactions as well. Let’s see how they react to changing a Line Item quantity.
First, the system marshalls the RESTful JSON data into row objects that encapsulate the logic. These are created automatically, when you connect and create your Project.
The system performs optimistic locking checks, and obtains the oldRow, so your logic has access to all the required data.
The quantity change triggers a change to dependent data - the amount. As a developer, this requires no explicit call - rules execute automatically when their referenced data changes.
The amount triggers an adjustment to the amountTotal. As a developer, you not be concerned about the sql, or performance matters like caching. Multi-table chaining is fully automatic.
The amountTotal triggers an adjustment to the balance. Adjustments are optimized to 1 row updates, not expensive aggregate select sum queries.
The balance triggers re-evaluation of our check-credit constraint. If it fails, the entire transaction is rolled back.
Since there are no more rows to process, the transaction is committed.
TransparencyRule operation is transparent... not a black box. You can examine the log to determine all the rules and sql that fire. Chaining is shown by nesting. You can see the full row at each execution stage.
Value: Business Agility
Our 5 simple rules were completely executable - no invocation logic, no persistence code. Our rules, perhaps conceived for Place Order, actually address these other 12 transactions, completely. All the Change Detection, Change Propagation and SQL is automated.
Rules are bound to the data, not a specific Use Case, so they apply to all in-coming transactions. In other words, the logic above automatically processes all of these transactions:
- Order inserted - balance increased
- Order deleted - balance decreased (if not paid)
- Order unshipped - balance decreased
- Order shipped - balance decreased
- Order amountTotal changed - balance adjusted
- Order reassigned to different customer - balance increased for new customer, decreased for old
- OrderDetail inserted - obtain price, adjust Order and Customer (and check credit)
- OrderDetail Deleted - reduce Order and Customer totals
- OrderDetail Quantity increased - adjust Order and Customer (and check credit)
- OrderDetail Product Changed - obtain price, adjust Order and Customer (and check credit)
- OrderDetail Quantity and Product Changed - obtain price, adjust Order and Customer (and check credit)
- Customer CreditLimit changed - check credit
This results in a meaningful improvement in quality. Reactive Programming eliminates of an entire class of programming error (e.g., balance checked when adding an order, but overlooked on unshipping an order).
If you used conventional event-based programming, these 5 lines would have required hundreds of lines of code. That’s over an order of magnitude improvement, for a significant part of your system.
Maintenance is addressed too - when you change the rules, ordering and optimizations is handled automatically. And since invocation is automatic, all your existing transactions will automatically use and adapt to the new logic.