今天讀
Adobe Flex 2: Training from the Source上面有這么一段話:"Objects consist of characteristics that describe them, called properties, and
behaviors that describe what they can do or what can be done to them, called
methods.
Properties are just variables attached to an object and methods are
functions attached to an object. "
方法是對象的責任,這一觀點我最早在《設計模式解析(第二版、中文版)》里得知的,那里引用Martin Fowler的話說,對象在概念層次上是一組責任。當時我對這一觀點大為感嘆,因為我第一次領悟了對象的這一層含義,而不是僅是對象是類的實例、類是相同屬性和行為的集合。
英語是二把刀我對"methods are
functions attached to an object"不理解。“方法就是依附在對象上的函數”,如果這樣這句話簡直和沒說沒有區別。查了function后,發現其有職責的含義。外國人應該在起funtion個名字的時候,就把職責這個含義加進去了。而我則從中學數學課中認識它后,知道函數是給它輸入了東西然后會得到個東西的東西。并沒有更深入的和功能聯系到一起。看來從外國來的東西把他直接翻譯成中文是會損失一部分東西的。比如說Rails用到Martin Fowler的Active Record被譯成活動記錄,老是覺得有著異樣。呵呵,有能力還是要看原版書。
另:
Adobe Flex 2: Training from the Source這本書,寫的太細,一句話能說的,要解釋好幾句,吱吱吖吖......真受不了