Task: Detail the Design
Evolve the design of individual classes by making incremental additions and refinements.
Disciplines: Development
Purpose
  • Incrementally incorporate known analysis elements or requirements into the class.
  • Incrementally incorporate new analysis elements or requirements that are identified or refined from a previous delivery of the solution.
  • Rework the class to correct problems discovered in a previous delivery of the solution.
Relationships
RolesPrimary Performer: Additional Performers:
InputsMandatory:
    Optional:
      Outputs
        Process Usage
        Main Description

        Put the "finish and polish" on a class or set of classes by adding or refining relationships, attributes, cohesion, and patterns. Any analysis classes or requirements that haven't been fully designed for the piece of functionality being worked on are completed here.

        This task is close to implementation. The developer or an automated tool should be able to create code from the completed class design.

        Steps
        Increase encapsulation

        Maintain the intention of the class's public interface. Eliminate or at least minimize publicly accessible attributes. Use methods to insulate attributes from public access. The need for class documentation beyond its public interface is an indication of encapsulation problems.

        Minimize the exposure of private instance data through public methods. Consider providing copies of private data returned from public methods to prevent corruption of an instance.

        Improve construction and utility of instances

        Minimize the number of methods required to use the class. Reduce or eliminate the need to call public methods in a specific sequence to use an instance of the class.

        Verify that class constructors prepare the class instance for use. A class's constructor should encapsulate all the work required to initialize an instance of the class. Consumers of the class instance should not need to deviate from the class's interface to prepare the object for use.

        Provide deep copy constructors and methods, and support shallow and deep copies appropriately. Generally, users desire deep copies where attribute values are copied into the new instance of the class. It should be clear when a method provides a shallow copy (the new instance refers to the attributes in the original instance of the class).

        Refine private data

        Identify additional attributes needed by the class to carry out its operations. Assure the proper state of the class is reflected by its attribute values.

        Eliminate multi-attribute private data encapsulated by the class. For example, represent an address within a Person class with an Address class instead of several simple attributes that collectively make up the address. Define a new class with the components of complex data and use that as a single attribute within a class.

        Find and convert raw numeric values used in method bodies to a class attribute. Decide if the attribute needs protection from runtime changes, e.g. a constant.

        Reduce generalization relationships

        Convert generalization relationships to associations whenever possible. Associations keep the design more flexible.

        Define a common base class that contains the behavioral contract for child classes to inherit. All child classes in the hierarchy must maintain this contract. In other words, maintain the "is-a" relationship between children and their parents. Consider moving child classes out of the hierarchy if they cannot maintain the behavioral requirements set forth in the base class.

        Reduce the depth of the generalization hierarchy. Hierarchies more than 2 levels deep begin to be difficult to maintain.

        Refactor the generalization hierarchy if its purpose has become unclear or distorted.


        Incorporate design patterns and implementation mechanisms
        Use design patterns and mechanisms as suited to the class being refined and in accordance with project design guidelines.

        Patterns and mechanisms are typically incorporated as the design evolves. They are frequently applied across a set of classes.
        Resolve concurrency collisions

        Protect objects accessed concurrently by different threads of execution. Identify the code concurrently accessed in methods and protect them from simultaneous access. Select or design appropriate access control mechanisms to prevent conflicting simultaneous access.

        Examples of these mechanisms include message queuing to serialize access, use of semaphores or tokens to allow access only to one thread at a time, or other variants of locking mechanisms. The choice of mechanism tends to be implementation dependent.

        More Information