CRC卡

CRC卡

在CRC建模中,用戶、設計者、開發人員都有參與,完成對整個面向對象工程的設計。

CRC卡是一個標準索引卡集合,每一張卡片表示一個類。

類名在最上方,類的職責在左側,類的協作關係放在右側。

基本介紹

  • 中文名:CRC卡
  • 外文名:Class-Responsibility-Collaborator
  • 解釋:比較流行的面向對象分析建模方法
  • 分類:類名、類的職責、類的協作關係
類 代表一系列對象的集合,這些對象是對系統設計的抽象建模,可以是一個人、一件物品等等,類名寫在整個CRC卡的最上方。
職責 包括這個類對自身信息的了解,以及這些信息將如何運用。諸如,一個人,他知道他的電話號碼、地址、性別等屬性,並且他知道他可以說話、行走的行為能力。這個部分在CRC卡的左邊。
協作 指代另一個類,我們通過這個類獲取我們想要的信息或者相關操作。這個部分在CRC卡的右邊。
CRC卡片的背面往往記載著這個類的詳細描述和在CEC設計中的一些注意事項。
Definition : One common way of checking for a good design andguiding its refinement is to use CRC cards.
CRC stands for Classes, Responsibilities, Collaborations. 類名,類的職責,類的協作關係
Although CRC is not part of UML, they add some very useful insights throughout a development.
Creating CRC Cards 建立一個CRS卡
The name of a class, at the top 類名在最上方
The responsibilities of the class, on the left-hand side 類的職責在左側
The collaborators of the class, which help to carry outeach responsibility, on the right-hand side of the card.類的協作關係放在右側
  • In general there should be one or two responsibilities perclass and usually no more than four. Too manyresponsibilities often signals low cohesion (i.e., a badlevel of abstraction) in the system.
  • Too many collaborators can signify high coupling in thesystem (the class is connected to too many other classes).
    Since we aim to have systems with high cohesion and lowcoupling, we should aim to find a compromise betweenthese values which is still conceptually sound.
    講求高內聚低耦合
耦合性:也稱塊間聯繫。指軟體系統結構中各模組間相互聯繫緊密程度的一種度量。模組之間聯繫越緊密,其耦合性就越強,模組的獨立性則越差。模組間耦合高低取決於模組間接口的複雜性、調用的方式及傳遞的信息
內聚性:又稱塊內聯繫。指模組的功能強度的度量,即一個模組內部各個元素彼此結合的緊密程度的度量。若一個模組內各元素(語名之間、程式段之間)聯繫的越緊密,則它的內聚性就越高。
所謂高內聚是指一個軟體模組是由相關性很強的代碼組成,只負責一項任務,也就是常說的單一責任原則。
耦合:一個軟體結構內不同模組之間互連程度的度量。
一個完整的系統,模組與模組之間,儘可能的使其獨立存在。也就是說,讓每個模組,儘可能的獨立完成某個特定的子功能。模組與模組之間的接口,儘量的少而簡單。如果某兩個模組間的關係比較複雜的話,最好首先考慮進一步的模組劃分。這樣有利於修改和組合。

相關詞條

熱門詞條

聯絡我們