Saturday, September 30, 2006

读书计划: Applying UML and Pattern

VOCABULARY
=====================
OCL : Object Contraint Language, one specification of UML
R&D : Research and Development
SSD : System Sequence Diagram
LRG : low representational gap
GRASP: General Responsibility Assignment Software Principle
DCD : Design Class Diagram

Read Log
=====================
[ 2006/10/08 ]
- Coupling Level
  • TypeX has an attribute (data member or instance variable) that refers to a TypeY instance, or TypeY itself.

  • A TypeX object calls on services of a TypeY object.

  • TypeX has a method that references an instance of TypeY, or TypeY itself, by any means. These typically include a parameter or local variable of type TypeY, or the object returned from a message being an instance of TypeY.

  • TypeX is a direct or indirect subclass of TypeY.

  • TypeY is an interface, and TypeX implements that interface

[ 2006/10/09 ]
- Cohesion Level
  1. Very low cohesion A class is solely responsible for many things in very different functional areas.

    • Assume the existence of a class called RDB-RPC-Interface which is completely responsible for interacting with relational databases and for handling remote procedure calls. These are two vastly different functional areas, and each requires lots of supporting code. The responsibilities should be split into a family of classes related to RDB access and a family related to RPC support.

  2. Low cohesion A class has sole responsibility for a complex task in one functional area.

    • Assume the existence of a class called RDBInterface which is completely responsible for interacting with relational databases. The methods of the class are all related, but there are lots of them, and a tremendous amount of supporting code; there may be hundreds or thousands of methods. The class should split into a family of lightweight classes sharing the work to provide RDB access.

  3. High cohesion A class has moderate responsibilities in one functional area and collaborates with other classes to fulfill tasks.

    • Assume the existence of a class called RDBInterface that is only partially responsible for interacting with relational databases. It interacts with a dozen other classes related to RDB access in order to retrieve and save objects.

  4. Moderate cohesion A class has lightweight and sole responsibilities in a few different areas that are logically related to the class concept but not to each other.

    • Assume the existence of a class called Company that is completely responsible for (a) knowing its employees and (b) knowing its financial information. These two areas are not strongly related to each other, although both are logically related to the concept of a company. In addition, the total number of public methods is small, as is the amount of supporting code.

No comments: