跳至主要内容

博文

Reactive Stream (1)

本周开始复习部分 Scala 的知识,并开始学习 Akka Stream 的基础部分。Akka Stream 是 Reactive Stream + [Sources, Sinks and FlowGraphs](http://typesafe.com/blog/sources-sinks-and-flowgraphs) + [Akka Stream experimental API](http://doc.akka.io/api/akka-stream-and-http-experimental/1.0-M1) + [Reactive Stream presentation by Joshua Suereth](https://docs.google.com/presentation/d/16eITQAn4HIdD6rV_0upX8LVgDeKL4z4WGnxPPGuzj8o/edit#slide=id.p) + [Async database access with PostgreSQL, Play, Scala and Heroku](http://mauricio.github.io/2013/04/29/async-database-access-with-postgresql-play-scala-and-heroku.html) + [Reactive Stream & Akka HTTP](http://spray.io/msug/#/)

YOW 2014 集锦 (未完成)

> 刚结束的 YOW 2014 墨尔本会议,听了整整两天,各种主题演讲人的水平参差不齐—— > 口若悬河者有之;平淡无奇者亦有之。简单整理几个比较有趣的几个话题。 Andrei Alexandrescu 这次放下了 C++ 委员会成员的身份,来宣讲他自己在“非死不可”主持发展的 D language。号称在系统编程领域超过 C 和 C++,而且语法支持各种高级语言的特性。在讨论时下流行的函数式编程的时候,他举的例子是 factorial (阶乘)函数—— // version 1 - functional style, but not tail currying ulong factorial(uint n) { return n

Some video

周末看的几个视频,第一个是大牛 Douglas Crockford 在 YUIConf 上所做的 Keynote,之后的是在他的 Slides 中提及的几个视频: + Douglas Crockford: Monads and Gonads (YUIConf Evening Keynote) [Youtube Video](https://www.youtube.com/watch?v=dkZFtimgAcM) + Carl Hewitt: The Actor Model (everything you wanted to know, but were afraid to ask) [Channel9 Video](http://channel9.msdn.com/Shows/Going+Deep/Hewitt-Meijer-and-Szyperski-The-Actor-Model-everything-you-wanted-to-know-but-were-afraid-to-ask) + Mark Millers: Secure Distributed Programming with Object-capabilities in JavaScript [Video 1](http://www.youtube.com/watch?v=w9hHHvhZ_HY), [Video 2](http://www.youtube.com/watch?v=oBqeDYETXME)

Paths in Linux

无意中找到的一个帖子,讲的是Linux系统中[几个 PATH 的区别](http://unix.stackexchange.com/questions/8656/usr-bin-vs-usr-local-bin-on-linux). 1. `/bin` (and `/sbin`) were intended for programs that needed to be on a small `/` partition before the larger `/usr`, etc. partitions were mounted. These days, it mostly serves as a standard location for key programs like `/bin/sh`, although the original intent may still be relevant for e.g. installations on small embedded devices. 2. `/sbin`, as distinct from `/bin`, is for system management programs (not normally used by ordinary users) needed before `/usr` is mounted. 3. `/usr/bin` is for distribution-managed normal user programs. 4. There is a `/usr/sbin` with the same relationship to `/usr/bin` as `/sbin` has to `/bin`. 5. `/usr/local/bin` is for normal user programs not managed by the distribution package manager, e.g. locally compiled packages. You should not install them into `/usr/bin` because future distribution upgrades may modify or delete them withou...

ImplDDD 阅读笔记 - Value Objects, Part 2

在比较 Value Objects 的时候,首先比较的是两个对象的类型,其次才是对象的 attributes。如果两个或多个 value objects 是相等的,那么使用其中任意一个赋值给 Entity 的 property 都不会改变该 Entity Object 的状态。 A method of an object can be designed as a _Side-Effect-Free Function_. A function is an operation of an object that produces output but without modifying its own state. Since no modification occurs when executing a specific operation, that operation is said to be side-effect free. Value Object 的方法都是 Side-Effect-Free 的,因为一旦被创建出来就无法再修改 Value Object 的状态了。这个特性实际上跟 immutability 有很强的关联,不过作者认为有必要将其独立出来,这样可以更容易把 Value Object 当做一个可用的对象而非简单的一组 attributes 来使用。 FullName name = new FullName("Vaughn", "Vernon"); // later ... name = name.withMiddleInitial("L"); 这里调用的 `withMiddleInitial` 就可以是(也必须是)一个 function,它基于原有的 Value Object 创建了一个新的 Value Object。 public FullName withMiddleInitial(String aMiddleNameOrInitial) { if (StringUtils.isBlank(aMiddleNameOrInitial == ...

ImplDDD 阅读笔记 - Value Objects, Part 1

Values types that measure, quantify, or describe things are easier to create, test, use, optimize, and maintain. Domain model 中真正的 Value Objects 并不是业务领域中的一种物品 (thing),它是用于测量、量化或是描述物品的。例如,一个人的年龄,它并不是一件事物,而是用来量化这个人从出生到现在的年数。 如果设计正确,Value Objects 的实例在创建之后就可以被随意传递,开发者可以即刻忘记这类对象,无论它们的生命周期是长是短,更无需担心对象的值是否被修改。在解决 Ubiquitious Language 的时候,确定正在建模的 domain concept 是否适合 Value Objects 是第一要务。有这么几个标准可以用来辅助判断: + It measures, quantifies, or describes a thing in the domain. + It can be maintained as immutable. + It models a conceptual whole by composing related attributes as an integral unit. + It is completely replaceable when the measurement or description changes. + It can be compared with others using Value equality. + It supplies its collaborators with Side-Effect-Free Behavior. 在绝大多少情况下,Value Objects 都是 immutable 的,一旦它们被创建出来,就无法再修改它的值。在 Java 或是 C# 这样的语言中,开发者往往使用 constructor 来构造 Value Objects 的实例,传入的参数被用于确定该对象的全部状态。构造参数可能直接被保存为 Value Objects 的 attributes,也可能被用于推导 (derive) 出对象内的一个或是若干 attributes...

ImplDDD 阅读笔记 - Validation

讨论 Validation 的时候,不得不提及 Self encapsulation,objects 的 constructor 将成员变量的赋值代理给各自的 setter methods 来执行,而 setter 可以检查对象自身是否具有合适的 state。本书的作者并不认同将 self encapsulation 视作为 validation 的一种,因为从单一职责的角度来看,更适合由独立的 validation class 而不是 domain class 自己来执行 validation 操作。他对 self encapsulation 的看法是,assertions that follow a design-by-contract approach。所谓的 design-by-contract 是由 Bertravel Meyer 在 Eiffel 语言中所提倡的,可以具体细分为 pre-condition, post-condition 和 invariants of the components。 The primary reasons to use validation in the model are to check the correctness of + any one attribute/property, + any whole object + or, any composition of objects. Domain model 的 validation 被划分为三个层次,也就是说,即使一个 Entity 中所有的 attributes/properties 都有效,这个 Entity 还是可能由于 attributes 的组合状态无效。因此,还是要用 Specification 或是 Strategy 来对整个 Entity 的状态来执行校验。 由于整个 Entity 的 state 必须对 validation 可见,并不表示将 validation processing 内嵌在 Entity 里是个好主意。很多时候对于 domain object 的 validation 逻辑的修改比起对于 domain model 本身的业务逻辑的修改来的更为频繁!此外,从 responsibility 的角度来考虑也应当独立出 ...