CAP理论

分布式网络环境中,时间和顺序是无法预估的,要保证得到的数据正确,我们需要一些折衷的选择。

2000年7月19号,Eric Brewer在ACM研讨会上关于分布式计算的原则(Principlesof Distributed Computing,PODC)所做的开题演讲中,提出了一个猜想(后来的成为著名的Brewer猜想):

applications become more web-based we should stop worrying about data consistency, because if we want high availability in these new distributed applications, then guaranteed consistency of data is something we cannot have, thus giving anyone with three servers and a keen eye for customer experience permission to start an internet scale business.

2年后,2002年,麻省理工(MIT)的Seth Gilbert和NancyLynch,理论上证明了Brewer猜想是正确的,就此Brewer定理(Theorem)诞生了。

Read more

Monoids and Monads

Haskell由于使用了Monad这种较费解的概念来控制副作用而遭到了一些批评意见。Wadler试图平息这些质疑,他解释说:“一个单子(Monad)说白了不过就是自函子范畴上的一个幺半群而已,这有什么难以理解的?”
A monad is just a monoid in the category of endofunctors, what’s the problem?

这一句话包含了好几个概念:单子(monad),自函子(Endo-Functor),幺半群(Monoid),范畴(category)。

Read more

Command Query Responsibility Segregation Pattern

在面向对象设计中,常常忽略了一个概念,对象是用于描述一个单一职责的,它要求我们:一个对象包含自身属性、行为、内在调用等行为。对象间通过相互调用完成一项工作。因此,我们在做面向对象设计时,应该分清一个对象应该包含多少东西,对象的属性是否 belong to它自身。如果一个对象的行为模糊不清,是否该对象设计合理?

Read more