Chen Jian

[Rod Johnson] O/R Mapping 的优点与缺点

优点:    1.程序员不用写SQL代码。写SQL很浪费时间的。    2.基于O/R Mapping可以实现domain object model 缺点:    1.complex deployment descriptors    2.reduced control over that access — 深有同感。我一向对半自动化的持久化持怀疑态度。一项数据在何时持久化,应该由程序员通过编码显式地控制。    3. 性能,尤其是批量删改的时候。    4. 迷信O/R Mapping的人往往会采用database-driven data modeling. 这会使object与relation的阻抗更大。

[Rod Johnson] 异步调用的两种方案:JMS和另起线程

以下是我的总结:     可以有两种办法实现异步调用        1.JMS — 功能十分强大,而且可靠性很高(比如消息的持久化)。但是这个东西复杂性很高,难维护,并且有额外的性能开销。        2.另起一个线程,在新线程里执行被调用的方法,并通过Observer模式在两个线程之间通讯。– 比较简单,实现容易。但是没有JMS的附加优点,并且集群环境下很无能。

[Rod Johnson] 框架的设计没必要太XP

他说: The XP advice of "Writing the simplest thing that could possibly work" isn ‘t always appropriate It’s impossible to refactor the interfaces exposed by a framework without breaking code that uses it and severely reducing its usefulness. Even within an organization, the cost of incompatible changes to a framework can be very large (on …

[Rod Johnson] 框架的设计没必要太XP Read More »

[Rod Johnson] 要写代码注释

我的观点和考虑到的地方几乎和他一样。但当我在javaeye论坛里表达这些观点时,别人反而觉得好笑! Remember that documentation should serve to:      1. Provide a contract for objects and methods. Test cases for an object are also valuable specifications, and documentation and test cases should be kept synchronized.      2. Save developers the trouble of needing to read code before they use it. There should be no need to …

[Rod Johnson] 要写代码注释 Read More »

[Rod Johnson] 关于 Method Visibility

1. 他说Method要的Visibility要尽量地窄,可以private的就不要把它public. 这有很多好处,不过我印象最深的是对重构的好处。的确,public方法越多,调用它的地方就可能越多,refactor时就要小心得多。 2. protected 只应该用于抽象方法上。如果具体的方法用了protected以让子类覆盖,那这就是一种concrete inheritance,这种感觉是很不舒服的。 3.包可见性的方法基本用不上,除了一种情形:该方法不是契约级的方法(实际上是private),但它又要进行单元测试。为了单元测试这个方法,可以把它置为包可见性,然后在同一个包下写它的单元测试类进行测试。 ——我不喜欢这种用法,但我承认它是封装性跟简单性的一个比较好的折衷。

[Rod Johnson] 反射会使程序变慢,但可以忽略不计

"Code that uses reflection is usually slower than code that uses normal Java object creation and method calls. However, this seldom matters in practice, and the gap is narrowing with each generation of JVMs. The performance difference is slight, and the overhead of reflection is usually far outweighed by the time taken by the operations …

[Rod Johnson] 反射会使程序变慢,但可以忽略不计 Read More »