Welcome to the Real World

Welcome to the Real World
Gregor Hohpe
EnginEERS liKE pRECiSion, especially software engineers who live in the realm of ones and zeros. They are used to working with binary decisions, one or zero, true or false, yes or no. Everything is clear and consistent, guaranteed by foreign key constraints, atomic transactions, and checksums.
Unfortunately, the real world is not quite that binary. Customers place orders, only to cancel them a moment later. Checks bounce, letters are lost, payments delayed, and promises broken. Data entry errors are bound to happen every so often. Users prefer “shallow” user interfaces, which give them access to many functions at once without being boxed into a lengthy, one-dimensional “pro- cess,” which is easier to program and seems more “logical” to many developers. Instead of the call stack controlling the program flow, the user is in charge.
Worse yet, widely distributed systems introduce a whole new set of inconsis- tencies into the game. Services may not be reachable, change without prior notice, or do not provide transactional guarantees. When you run applica- tions on thousands of machine, failure is no longer a question of “if,” but of “when.” These systems are loosely coupled, asynchronous, concurrent, and do not adhere to traditional transaction semantics. You should have taken the blue pill!
As computer scientists’ brave new world is crumbling, what are we to do?
As is so often the case, awareness is a first important step toward a solution.

Say goodbye to the good old predictive call-stack architecture, where you get to define what happens when and in what order. Instead, be ready to respond to events at any time in any order, regaining your context as needed. Make asynchronous requests concurrently instead of calling methods one by one. Avoid complete chaos by modeling your application using event-driven pro- cess chains or state models. Reconcile errors through compensation, retry, or tentative operations.
Sounds scary and more than you bargained for? Luckily, the real world has to deal with the same issues for a long time: delayed letters, broken prom- ises, messages crossing in transit, payments posted to the wrong account—the examples are countless. Accordingly, people had to resend letters, write off bad orders, or tell you to ignore the payment reminder in case you already sent a payment. So don’t just blame the real world for your headaches, but also use it as a place to look for solutions. After all, Starbucks does not two-phase com- mit, either.1 Welcome to the real world.
Gregor Hohpe is a software architect with Google, Inc. Gregor is a widely rec- ognized thought leader on asynchronous messaging architectures and service- oriented architectures. He coauthored the seminal book Enterprise Integration Patterns (Addison-Wesley Professional) and speaks regularly at technical conferences around the world.
随机推荐
- 3个不常用的HTML标签
html标签众多,在HTML手册里你可以都查到.但有的HTML标签你可能从未使用过.不是因为你欠缺学习精神,而是它们确实用处不大.如果你有探索精神,那就接着往下看吧. 第一个:<abbr> ...
- Python 35 线程(1)线程理论、开启线程的两种方式
一:线程理论 1 什么是线程 进程其实一个资源单位,而进程内的线程才是cpu上的执行单位 线程其实指的就是代码的执行过程2 为何要用线程 线程vs进程 1. 同一进程下的多个线程共享该进程 ...
- mysql行列转置
--创建行转列表及插入数据 create table tb_RowConvertToColumn ( username nvarchar(100) null, course nvarchar(100) ...
- angular的directive指令的link方法
比如 指令标签 <mylink myLoad="try()"></mylink> link:function(scope,element,attr){ el ...
- python 9:list.reverse()(倒置原列表,可恢复改变)
bicycles = ['trek', 'cannondale', 'redline', 'specialized'] print(bicycles) bicycles.reverse() #倒置原列 ...
- BZOJ 4698 差分+后缀数组
思路: 对所有序列差分一下 公共串的长度+1就是答案了 二分 扫一遍height即可,.. //By SiriusRen #include <cstdio> #include <cs ...
- Dijkstra TYVJ 1031热浪 Dijkstra测试数据
测试用邻接表写得Dijkstra 代码写得很烂. 描述 德克萨斯纯朴的民眾们这个夏天正在遭受巨大的热浪!!!他们的德克萨斯长角牛吃起来不错,可是他们并不是很擅长生產富含奶油的乳製品.Farmer Jo ...
- Android媒体解码MediaCodec MediaExtractor学习
Android提供了MediaPlayer播放器播放媒体文件,其实MediaPlyer只是对Android Media包下的MediaCodec和MediaExtractor进行了包装,方便使用.但是 ...
- 经典实用SQL Server语句大全总结(一)
简要介绍基础语句:1.说明:创建数据库CREATE DATABASE database-name2.说明:删除数据库drop database dbname3.说明:备份sql server--- 创 ...
- 2、scala条件控制与循环
1. if表达式 2. 句终结符.块表达式 3. 输入与输出 4. 循环 5. 高级for循环 1. if表达式 if表达式的定义:scala中,表达式是有值的,就是if或者else中最后 ...