[Rod Johnson] 大胆地使用存储过程,但不能在里面放业务逻辑
他说存储过程有很多好处,固执地避免存储过程,就会浪费RDBMS提供的很多很多特性;但是要注意,决不能把业务逻辑放到存储过程中,否则的话分层就会被破坏。
他说存储过程有很多好处,固执地避免存储过程,就会浪费RDBMS提供的很多很多特性;但是要注意,决不能把业务逻辑放到存储过程中,否则的话分层就会被破坏。
优点: 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的阻抗更大。
以下是我的总结: 可以有两种办法实现异步调用 1.JMS — 功能十分强大,而且可靠性很高(比如消息的持久化)。但是这个东西复杂性很高,难维护,并且有额外的性能开销。 2.另起一个线程,在新线程里执行被调用的方法,并通过Observer模式在两个线程之间通讯。– 比较简单,实现容易。但是没有JMS的附加优点,并且集群环境下很无能。
他说: 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 …
我的观点和考虑到的地方几乎和他一样。但当我在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 …
"Static inner classes can be instantiated without the creation of an object of the enclosing type; non-static inner classes are linked to an instance of the enclosing type."
1. 他说Method要的Visibility要尽量地窄,可以private的就不要把它public. 这有很多好处,不过我印象最深的是对重构的好处。的确,public方法越多,调用它的地方就可能越多,refactor时就要小心得多。 2. protected 只应该用于抽象方法上。如果具体的方法用了protected以让子类覆盖,那这就是一种concrete inheritance,这种感觉是很不舒服的。 3.包可见性的方法基本用不上,除了一种情形:该方法不是契约级的方法(实际上是private),但它又要进行单元测试。为了单元测试这个方法,可以把它置为包可见性,然后在同一个包下写它的单元测试类进行测试。 ——我不喜欢这种用法,但我承认它是封装性跟简单性的一个比较好的折衷。
其中最核心的一点就是:Singleton类不是Interface-Friendly的类,它的类名在调用者代码里被硬编码了,这就导致了调用者对具体类的依赖。 另外,Singleton没法派生子类,这对单元测试非常不利。
"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 …