Watch your communication How communication drives design Uwe Friedrichsen (codecentric AG) – GOTO Berlin – Berlin, 13. November 2016
@ufried Uwe Friedrichsen | uwe.friedrichsen@codecentric.de | http://slideshare.net/ufried | http://ufried.tumblr.com
The “one-size-fits-all” trap
Standardization as a virtue
We see that a lot • One programming language • One framework • One build system • One type of runtime unit • One data store • One type of database access • One application server • One ... • One communication paradigm
Why are we doing it?
Reducing complexity • Avoid intellectual overload • Easier to understand • Easier to change • Faster to change • Easier to operate • Less error-prone • Cheaper
These are valid and important reasons …
... but that is just one side of the coin
The complexity of a solution must match the complexity of the problem to solve
If your task is to build a box from pre-cut boards, only using a hammer might be adequate
If your task is also to paint the box you just built, only having a hammer might be a problem …
Now imagine building a whole house just with a hammer …
Yet, in IT we often tend to build whole houses just with a hammer because boxes can be built with a hammer
Complexity mismatch means • Increased accidental complexity • Harder to understand • Harder to change • Slower to change • Harder to operate • More error-prone • More expensive
Problem complexity Essential complexity Complexity Adds direct Adds indirect accidental complexity accidental complexity Ideal solution complexity
Problem complexity Complexity More “tooling” than needed Increased accidental to get the job done well complexity Overly complex solution
Problem complexity Complexity Not enough “tooling” Increased accidental to get the job done well complexity Over- simplified solution
Overall Solution Complexity := Essential Problem Complexity + Solution Complexity Mismatch Solution Complexity Mismatch a.k.a. Accidental Complexity Be aware that mismatch in both directions adds to overall solution complexity
Problem complexity Essential complexity Complexity Aim for the least complex solution with respect to the problem you have to solve (Yes, it is about trade-offs – as always in architecture)
Communication paradigms
Communication paradigms • Dimensions of communication • Synchronous vs. asynchronous • Request/response vs. message passing • Commands, Events and Documents • Sender/Receiver dependency
Communication paradigms • Typical communication patterns • Synchronous request/response • Asynchronous commands (with known receiver) • Asynchronous events (without known receiver)
The “synchronous request/response everywhere” trap
Why are we doing it?
Remember the “one-size-fits-all” trap?
Yes, but why this paradigm?
Why synchronous R/R? • “It’s how the internet works” • “The library support is better” • “It is easier to reason about” • Matches the way we consciously think • Matches the way we learned to do design
Do not forget the other side of the coin
The flipside of the coin • HTTP was designed for a specific use case Access hypermedia content • Not an ubiquitous communication solution • • The world outside a process is different Non-determinism kills easy reasoning • Latency creep kills easy reasoning • • Solution mismatch adds complexity Compromises functional encapsulation • Changes and extensions become more complicated • Longer activation paths compromise robustness •
Designing communication
An (invidious) example …
Order fulfillment
Let us begin with the well-known synchronous request/response design ...
Order fulfillment Initial version with limited functionality • Order includes Items • Amounts • Price per item • T otal price • • Credit card payment • Only non-digital items
Online Shop Order Fulfillment Service Coordinate Payment Shipment Service Service Credit Card Warehouse Credit Card Warehouse Provider System <Own Service> <Foreign Service>
Order fulfillment Add coupons • Order additionally includes Optional coupon ID • Optional remaining coupon value • Coupon is already charged against total price • • Validate coupon
Online Shop Order Fulfillment Service Coordinate Payment Shipment Coordinate Service Service Coupon Credit Card Warehouse Coupon Credit Card Warehouse Management Provider System <Own Service> <Foreign Service>
Order fulfillment Add promotions • Order additionally includes Optional promotion ID • Promotion is already applied to order • • Notify Campaign Management System about promotion usage
Online Shop Order Fulfillment Service Coordinate Campaign Payment Shipment Promotion Coordinate Management Service Service Coupon Credit Card Warehouse Coupon Credit Card Warehouse Management Provider System <Own Service> <Foreign Service>
Order fulfillment Add customer accounts • Order additionally includes Payment type (Credit card/Account) • • Charge customer account
Online Shop Order Fulfillment Service Coordinate Campaign Payment Shipment Promotion Coordinate Management Service Service Coupon Credit Card Warehouse Coupon Account Credit Card Warehouse Management service Provider System Accounts Receivables <Own Service> <Foreign Service>
Order fulfillment Add PayPal • Order additionally includes More payment types (Credit card/PayPal/Account) • • Payment via PayPal
Online Shop Order Fulfillment Service Coordinate Campaign Payment Shipment Coordinate Management Service Service Promotion Coupon Warehouse Coupon Account Payment Warehouse Credit Card Management service provider System PayPal Accounts Credit Card Receivables Provider PayPal <Own Service> <Foreign Service>
Order fulfillment Add digital music library • New shipment method Activate music assets in digital music library • Notify customer via email including access link • • Digital music library has its own API
Online Shop Order Fulfillment E-Mail Server Service Coordinate Campaign Payment Shipment Coordinate Coordinate Notify Cust. Management Service Service Promotion Coupon Warehouse Music Coupon Account Payment Warehouse Credit Card Music Library Management service provider System PayPal Accounts Credit Card Receivables Provider PayPal <Own Service> <Foreign Service>
Order fulfillment Add digital video library • New digital shipment channel Activate video assets in digital video library • Notify customer via email including access link • • Digital video library has its own API Different from the music library API •
Online Shop Order Fulfillment E-Mail Server Service Coordinate Campaign Payment Shipment Coordinate Coordinate Notify Cust. Management Service Service Promotion Coupon Warehouse Assets Coupon Account Payment Warehouse Credit Card Music Library Video Library Management service provider System PayPal Accounts Credit Card Receivables Provider PayPal <Own Service> <Foreign Service>
Order fulfillment Add e-book library • New digital shipment channel Activate e-books in e-book library • Notify customer via email including access link • • E-Book library has its own API Different from the other asset library APIs •
Online Shop Order Fulfillment E-Mail Server Service Coordinate Campaign Payment Shipment E-Book Coordinate Coordinate Notify Cust. Management Service Service Library Promotion Coupon Warehouse Assets Coupon Account Payment Warehouse Credit Card Music Library Video Library Management service provider System PayPal Accounts Credit Card Receivables Provider PayPal <Own Service> <Foreign Service>
Order fulfillment Add bonus card • Order additionally includes Optional bonus card ID • Potential discount is already applied to order • • Notify Loyalty Management System about customer purchase
Online Shop Loyalty Order Fulfillment E-Mail Server Management Service Coordinate Campaign Payment Shipment E-Book Loyalty Coordinate Coordinate Notify Cust. Management Service Service Library Promotion Coupon Warehouse Assets Coupon Account Payment Warehouse Credit Card Music Library Video Library Management service provider System PayPal Accounts Credit Card Receivables Provider PayPal <Own Service> <Foreign Service>
Order fulfillment More requirements to come …
Recommend
More recommend