UML user guide, chapter 4 Classes - UML用戶手冊第四章 類

Classes are the most important building block of any object-oriented system. A class is a description of a set of objects that share the same attributes, operations, relationships, and semantics. A class implements one or more interfaces.

You use classes to capture the vocabulary of the system you are developing. These classes may include abstractions that are part of the problem domain, as well as classes that make up an implementation.

類是面向對象系統裏面的最重要的基石, 類是對擁有相同的屬性,操作,關係,語義的一組對象的描述.

 

 

Every class must have a name that distinguishes it from other classes. A name is a textual string. That name alone is known as a simple name; a qualified name is the class name prefixed by the name of the package in which that class lives.  For example java::awt.Retangle, however it's pity that I can not draw it with the tool of Star UML.

 

 

 

 

Attributes

An attribute is a named property of a class that describes a range of values that instances of the property may hold. A class may have any number of attributes or no attributes at all. An attribute represents some property of the thing you are modeling that is shared by all objects of that class.  

 

Operations

An operation is the implementation of a service that can be requested from any object of the class to affect behavior. In other words, an operation is an abstraction of something you can do to an object that is shared by all objects of that class. A class may have any number of operations or no operations at all.

Organizing Attributes and Operations

When drawing a class, you don't have to show every attribute and every operation at once. In fact, in most cases, you can't (there are too many of them to put in one figure) and you probably shouldn't (only a subset of these attributes and operations are likely to be relevant to a specific view). For these reasons, you can elide a class, meaning that you can choose to show only some or none of a class's attributes and operations. You can indicate that there are more attributes or properties than shown by ending each list with an ellipsis ("..."). You can also suppress the compartment entirely, in which case you can't tell if there are any attributes or operations or how many there are.

To better organize long lists of attributes and operations, you can also prefix each group with a descriptive category by using stereotypes, as shown in Figure 4-7.

WOW, 或者我們應該畫出一些重要的方法或屬性.

 

 

Responsibilities

A responsibility is a contract or an obligation of a class. When you create a class, you are making a statement that all objects of that class have the same kind of state and the same kind of behavior. At a more abstract level, these corresponding attributes and operations are just the features by which the class's responsibilities are carried out

Oops, Star UML似乎不能畫職責描述。。

 

Hints and Tips

When you model classes in the UML, remember that every class should map to some tangible or conceptual abstraction in the domain of the end user or the implementer. A well-structured class

每個類圖 對於終端用戶或實現者域來說, 應該是對一些切實或有概念的良好抽象。

  • Provides a crisp abstraction of something drawn from the vocabulary of the problem domain or the solution domain.從問題域的語義或解決方案中 提供一個乾脆的事務的抽象

  • Embodies a small, well-defined set of responsibilities and carries them all out very well.嵌入簡單的良好定義的一系列職責, 並用圖的形式較好的表達出來

  • Provides a clear separation of the abstraction's specification and its implementation.提供娘好的抽象和實現。。 。人人都那樣想:p

  • Is understandable and simple, yet extensible and adaptable. 簡單且容易理解, 可擴展, 可適配的。。。

When you draw a class in the UML,

  • Show only those properties of the class that are important to understanding the abstraction in its context. 只畫出那些 在環境上下文當中, 對於理解抽象顯得重要的屬性。

  • Organize long lists of attributes and operations by grouping them according to their category. 出現大量屬性和操作時對於他們進行歸類

  • Show related classes in the same class diagrams. 畫圖關聯的類圖

 

 

 

。。。 bto be continued....

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