prototypes vs classes的爭論

 Wed, 03 Sep 2008 18:00:41 +0800

Mock Objects/JMock的作者們(Steve Freeman、Nat Pryce)正在寫一本測試驅動開發的書,逐章修改並在網路上討論發表: Growing Object-Oriented Software, Guided by Tests - Table of Contents

書還在成型中,所以不時會去瞄一眼。今天注意到,文獻目錄已經先出來了,就進去看一下,有一個連結引起我的注意: Bibliography。 裡面有一個連結是: [Kay1998] Prototypes vs Classes. Alan Kay. 1998. 好奇之下,就點進去看了。

頭兩段話馬上吸引我的視線:(黑體字是Freeman跟Pryce文中引用的句子)

Just a gentle reminder that I took some pains at the last OOPSLA to try to remind everyone that Smalltalk is not only NOT its syntax or the class library, it is not even about classes. I'm sorry that I long ago coined the term "objects" for this topic because it gets many people to focus on the lesser idea.

The big idea is "messaging" -- that is what the kernal of Smalltalk/Squeak is all about (and it's something that was never quite completed in our Xerox PARC phase). The Japanese have a small word -- ma -- for "that which is in between" -- perhaps the nearest English equivalent is "interstitial". The key in making great and growable systems is much more to design how its modules communicate rather than what their internal properties and behaviors should be. Think of the internet -- to live, it (a) has to allow many different kinds of ideas and realizations that are beyond any single standard and (b) to allow varying degrees of safe interoperability between these ideas.

從討論串看出來,儘管苦口婆心,還是有很多人沒弄明白Kay的意思。不過至少Freeman跟Pryce引這段話是很有深意的:Chapter 4. Test-Driven Development with Objects

到底Alan Kay是誰(我知道我孤陋寡聞)?上google找一下,wikipedia有他的資料:Alan Kay。嗯嗯,1997年圖靈獎得主,OOP跟GUI先驅(嗯嗯,簡單地說,Object Orient Programming這個名詞是他發明的,他是Smalltalk重要成員,曾經在全錄的PARC實驗室工作,開發GUI系統,這後來被Apple搶去用了......換句話說,我能在這裡打這篇文章,都是他的成果囉)。

另外,這篇討論串的出處,是一個叫Squeak的動態媒體軟體的maillist。這個計畫操作介面的後續計畫叫做Tweak,在內部設計上採用classes base,但是使用者操作(撰寫程式)上,卻使用prototypes base的物件系統。