UML實例--HELL_WORLD(三)



This class diagram captures the basics of theHello, World! application, but it leaves out a number of things. As the preceding code specifies, two other classes----Applet andGraphics----are involved in this application and each is used in a different way. The classApplet is used as the parent ofHelloWorld , and the classGraphics is used in the signature and implementation of one of its operations,paint . You can represent these classes and their different relationships to the classHelloWorld in a class diagram, as shown in Figure 3-2.

 

圖3-1顯示的類圖捕獲的是你好,世界!應用的基礎信息,它省略了許多東西.作爲預定義,另兩個類--AppletGraphics--在這個應用被使用到,並且使用的方式不同.Applet類是HelloWorld的父類,Graphics作爲識別標誌被使用,並實現了它的一個操作paint.你可以在一個類圖中,表達這些類和它們與類HelloWorld的不同關係.如圖3-2所示.

The AppletandGraphics classes are represented graphically as rectangular icons. No operations are shown for either of them, so their icons are elided. The directed line with the hollow arrowhead fromHelloWorldtoAppletrepresents generalization, which in this case means thatHelloWorld is a child ofApplet . The dashed directed line fromHelloWorld toGraphics represents a dependency relationship, which means thatHelloWorld usesGraphics.

Applet類和Graphics類的圖形表示符號是一個矩形圖標.在這個應用中因沒有用到它們的操作,所以省略了它們的圖標.帶有空心箭頭的有向線從HelloWorld指向Applet,表示的是通用關係,含義是在這裏HelloWorld繼承自Applet.從HelloWorld指向Graphics的虛線指示線表達一種依賴關係,含義是HelloWorld使用Graphics

 

This is not the end of the framework upon whichHelloWorld is built. If you study the Java libraries forApplet andGraphics , you will discover that both of these classes are part of a larger hierarchy. Tracing just the classes thatApplet extends and implements, you can generate another class diagram, shown in Figure 3-3.

 

HelloWorld之上構建的框架並沒有結束.如果你爲了AppletGraphics而研究Java庫,將會發現這兩個類是一個大的層次的一部分.跟蹤Applet 類的擴展和實現,可以產生另一個類圖,如圖3-3所示.

 

 

Note: This figure is a good example of a diagram generated by reverse engineering an existing system. Reverse engineering is the creation of a model from code.

備註:這個圖是通過逆向工程將已存在的系統轉換成圖的非常好的例子.逆向工程的含義是從代碼創建模型.

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章