11.18.2008

The Elements of UML 2.0 Style

這可以說是一本學習UML的必備書籍,裡面不是教你UML怎麼畫,而是告訴你用槍時機跟用槍要領。

umlstyle 作者是Scott W. Ambler,裏面有17個章節,308條準則。

不過這308條準則並不是每一條都適用的,有些甚至是廢話,有些則是因為工具的緣故,不用太去理會。
(除非有專案都是純手繪UML......)

當然也有可能是出書的時期(May 9, 2005),多數的工具尚未完備。

舉例來說:
100. Center Class Names
122. Center Names on Associations
165. Avoid Activation Boxes
......

這幾條都是tool會自動加上的,無須操心太多。

廢話則是像:(這是我個人認定啦!)
129. Make Associations Bidirectional Only When Collaboration Occurs in Both Directions
130. Indicate Direction Only on Unidirectional Associations
132. Redraw Inherited Associations Only When Something Changes
......

有些關於命名的準則,其實只要一開始準備好Glossary即可,無需於準則中贅言。

我們在書中也可以看出一些ICONIX開發論的準則,像是:
161. Include a Prose Description of the Logic
185. Apply Robustness Diagram Visual Stereotypes
......

當然,好的準則絕對也不少:
159. Layer Object Lifelines (Layering is a common approach to object-oriented design.)
169. Focus on Critical Interactions
178. Model a Return Value Only When You Need to Refer to It Elsewhere in a Diagram
186. Do Not Use Communication Diagrams to Model Process Flow
.......

總歸來說,這確實是一本好書,光就每個章節前面的用槍時機,告訴你何時該用這個圖表達,這就相當值得閱讀了。
像sequence diagram 通常用在:
Validate and flesh out the logic and completeness of a usage scenario.
Give you a feel for which classes in your application are going to be complex, which in turn is an indication that you may need to draw state machine diagrams for those classes.
......

Communication Diagrams 通常被用在:
provide a bird’s-eye view of a collection of collaborating objects, particularly within a real-time environment;
explore the roles that objects take within a system, as well as the different relationships in which they are involved when in those roles.
......

State Machine:
UML state machine diagrams depict the dynamic behavior of an entity based on its response to events,
showing how the entity reacts to various events based on its current state.
explore the complex behavior of a class, actor, subsystem,or component;
......

再寫下去可能會影響著作權,不過,既然我們寫code時都需要有Coding Style,那麼畫 UML 想當然爾也需要UML Style啦!
這本書絕對是具參考價值的。

沒有留言: