2006年4月27日 #
今天在網(wǎng)上閑逛,發(fā)現(xiàn)了一本好書,關(guān)于JAVA和TDD的,內(nèi)容介紹如下:
Master Java 5.0 and TDD Together: Build More Robust, Professional Software Master Java 5.0, object-oriented design, and Test-Driven Development (TDD) by learning them together. Agile Java weaves all three into a single coherent approach to building professional, robust software systems. Jeff Langr shows exactly how Java and TDD integrate throughout the entire development lifecycle, helping you leverage today's fastest, most efficient development techniques from the very outset. Langr writes for every programmer, even those with little or no experience with Java, object-oriented development, or agile methods. He shows how to translate oral requirements into practical tests, and then how to use those tests to create reliable, high-performance Java code that solves real problems. Agile Java doesn't just teach the core features of the Java language: it presents coded test examples for each of them. This TDD-centered approach doesn't just lead to better code: it provides powerful feedback that will help you learn Java far more rapidly. The use of TDD as a learning mechanism is a landmark departure from conventional teaching techniques.
很早就聽說過Castle的大名了,但是一直沒有時間去研究。一方面也是自己的惰性,另一方面也關(guān)于Castle的分析文章太少了。但是不管怎么說,面對這這么優(yōu)秀的項目沒有一睹芳容,真是
![]() ![]() http://www.cnblogs.com/Terrylee/archive/2006/04/28/387503.html 近來很忙,一直沒寫 blog 了,今天晚上有點時間,聽了節(jié) MSDN 上面的一節(jié) webCast ,講的就是 Proxy 模式,本就就是這節(jié)課的筆記。 學習設計模式也有段時間了,很早也見過 Proxy 模式的,記得最開始接觸 Proxy 模式還是在著名的 JIVE 論壇( JIVE 中用 Proxy 來做權(quán)限控制)。今天算是一遍復習吧。 對復雜的軟件系統(tǒng),人們常常用的一種處理手法是在系統(tǒng)增加一層間接層,得到對系統(tǒng)靈活的、滿足特殊要求的解決方案。 使用 Proxy 模式的動機:在 OO 的開發(fā)過程中,某些對象的開銷很大(如: new 的開銷大、某些對象因為安全的原因不能被客戶直接的調(diào)用等),如果直接操作這些對象會破壞系統(tǒng)結(jié)構(gòu)。那么,我們就用代理對象來控制對象的訪問。
例子,??
一個常見的
HR
系統(tǒng): ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
現(xiàn)在要求把
Employee
做成
webService
,
HR
系統(tǒng)通過
webService
來調(diào)用
Employee
對象,代碼修改如下: ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Proxy 使用的要點: 1 、“增加一層間接層”,是軟件系統(tǒng)中常用的手段之一。 2 、具體的實現(xiàn)中, Proxy 有很大差別,有的是簡單的“ copy-on-write ”,有的是對組件模塊的抽象代理。在 JAVA 中常見的 SSH 架構(gòu)模式中( struts+spring+hibernate )中,我們可以把 spring 所在的服務層看成對 hiberate 的代理。 具體的實現(xiàn)可以參考 .NET 中的 WebService 的實現(xiàn)。
Copy-on-write
技術(shù) ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() sb1.replace("H","L"); 系統(tǒng)做的動作是, sb1 的代理對象先拷貝 ”Hello” 字符串,然后用“ L ”替換“ H ”, sb1 的代理對象重新指向新的對象。 |