日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程资源 > 编程问答 >内容正文

编程问答

UML精粹--标准对象建模语言简明教程

發(fā)布時(shí)間:2025/1/21 编程问答 21 豆豆
生活随笔 收集整理的這篇文章主要介紹了 UML精粹--标准对象建模语言简明教程 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

今天借了一本《UML精粹--標(biāo)準(zhǔn)對(duì)象建模語(yǔ)言簡(jiǎn)明教程》(Uml Distilled: A Brief Guide to the Standard Object Modeling Language)。徐家福先生譯過(guò)來(lái)的。總體上感覺(jué):把一本好書(shū)糟蹋了。之乎者也的序自不待言。諸如“如果萬(wàn)一有人不小心面陷入我的陷阱,控制器對(duì)象終止,于是我就需要把兔子關(guān)入籠內(nèi),擦擦地板,重新啟動(dòng)系統(tǒng)。”之類(lèi)的翻譯(我查了下原著,if someone should be so careless as to fall for my trap,the controller object terminates,so I would need to put the rabbit in its cage,mop the floor,and reboot the system.),讓原著中風(fēng)趣的比喻變得艱澀而索然無(wú)味。而“讓強(qiáng)制屬性闕如或者示明抽象類(lèi)別的例規(guī)約都是合法的。(it's legal to leave mandatory attributes empty or to show instance specifications of abstract classes.)”我不得不查看原著才明白。
盡管如此,書(shū)中(我是說(shuō)原著)。還是有不少不錯(cuò)的內(nèi)容的。于是做了些尋章摘句的工作。并附了英文原著。鍵盤(pán)摸得不熟,有打錯(cuò)的擔(dān)待一下。謝謝!
  泛化(generalization):
泛化的一個(gè)典型例子是涉及業(yè)務(wù)的個(gè)人客戶(hù)和公司客戶(hù)。個(gè)人客戶(hù)和公司客戶(hù)二者既有區(qū)別又有很多的類(lèi)似之處。可以把類(lèi)似之處放入一個(gè)通用客戶(hù)類(lèi)(超類(lèi)型),它以個(gè)人客戶(hù)類(lèi)及其公司客戶(hù)類(lèi)為其子類(lèi)型。對(duì)軟件來(lái)說(shuō),明顯的解釋是“繼承”:公司客戶(hù)類(lèi)是客戶(hù)類(lèi)的子類(lèi)。
聚合與組合(aggregation and composition):
聚合是整體-部分關(guān)系。就如同說(shuō),一輛車(chē)以引擎和車(chē)輪為其兩部分。它聽(tīng)起來(lái)很好,但困難的是什么是聚合與關(guān)聯(lián)的區(qū)別。UML包含了聚合,但幾乎沒(méi)有任何語(yǔ)義。(aggregation is the part-of relationship.it's like saying that a car has an engine and wheels as its parts. This sounds good, but the? difficult thing is considering what the difference is between aggregation and association. The UML included aggregation but with hardly any semantics.)

除聚合外UML具有另外定義的組合特性。點(diǎn)的一個(gè)實(shí)例可以是多邊形的部分也可以是圓心,但不能二者兼是。通則是,雖然一個(gè)類(lèi)可以是多個(gè)其它類(lèi)的成分,任一實(shí)例卻必須只能是一個(gè)擁有者的成分。類(lèi)圖可以示明可能擁有者的多重類(lèi),但是,每個(gè)實(shí)例卻只能有單獨(dú)一個(gè)對(duì)象為其擁有者。(as well as aggregation,the UML has the more defined proerty of composition. an instance of Point may be part of a polygon or may be the center of a circle, but it cannot be both.The class diagram may show multiple classes of potential owners, but any instance has only a single object as its owner.)
組合是示明按值擁有的特性、值對(duì)象的特性,或者對(duì)其它特定成分具有強(qiáng)烈并稍有排它的擁有性等特性的好方法。聚合是完全沒(méi)有意義的。(Composition is a good way of showing properties that own by value, properties to value objects, or properties that have a strong and somewhat exclusive ownership of particular other components. Aggregation is strictly meaningless.)
分類(lèi)與泛化(classification and generalization)
我常聽(tīng)人把子類(lèi)型稱(chēng)為“是一(is a )”關(guān)系。我敦促你要提防這種思考方式。問(wèn)題是“是一”這一短語(yǔ)可有不同的含義。
考察如下短語(yǔ):
1.Shep 是一只牧羊犬。
2.牧羊犬是一只犬。
3.犬是一種動(dòng)物。
4.牧羊犬是一屬(Breed).。
5.犬是一種(species)。
現(xiàn)在試圖把這些短語(yǔ)加以組合。如組合短語(yǔ)1 和2,便得"Shep 是一只犬";組合2,3得“牧羊犬是一種動(dòng)物”;組合1、2、3得“Shep 是一種動(dòng)物”。到目前為止,都很好。現(xiàn)在試1和4,便得“Shep 是一屬”。組合2、5 得“牧羊犬是一種”,這就不太好了。(?? Now try combining the phrases. If I combine phrases 1 and 2, I get "Shep is a Dog"; 2 and 3 taken together yield "Border Collies are Animals." And 1 plus 2 plus 3 gives me "Shep is an Animal." So far, so good. Now try 1 and 4: "Shep is a Breed." The combination of 2 and 5 is "A Border Collie is a Species." These are not so good.)
為什么我可以組合其中某些短語(yǔ),而不可以組合別的短語(yǔ)?理由是,有些是分類(lèi)(classification)(對(duì)象Shep是牧羊犬類(lèi)型的一個(gè)實(shí)例),有些是泛化(generalization)(牧羊犬類(lèi)型是犬類(lèi)型的一個(gè)子類(lèi)型)。泛化是傳遞的,分類(lèi)則不然。我可以組合后接泛化的分類(lèi),反之則不然。(Why can I combine some of these phrases and not others? The reason is that some are classification—the object Shep is an instance of the type Border Collie—and some are generalization—the type Border Collie is a subtype of the type Dog. Generalization is transitive; classification is not. I can combine a classification followed by a generalization but not vice versa.)
我提出這一點(diǎn)是使你對(duì)“是一(is a)”謹(jǐn)慎對(duì)待。使用起子類(lèi)不合適以及職責(zé)混淆。在這種情形,子類(lèi)型更好的檢驗(yàn)是如下一些短語(yǔ):“犬是動(dòng)物的種類(lèi)”和“牧羊犬的每一實(shí)例都是犬的一個(gè)實(shí)例”。(? I make this point to get you to be wary of is a. Using it can lead to inappropriate use of subclassing and confused responsibilities. Better tests for subtyping in this case would be the phrases "Dogs are kinds of Animals" and "Every instance of a Border Collie is an instance of a Dog.")
附:英文原版可從fixdown下載。http://fixdown.com/soft/14631.asp

總結(jié)

以上是生活随笔為你收集整理的UML精粹--标准对象建模语言简明教程的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。