Task Descriptor: Detail the Design |
Evolve the design of individual classes by making incremental additions and refinements.
Based on Method Task: Detail the Design
Relationships
Roles | Primary: Developer | Additional: | Assisting:
Inputs | Mandatory: Design | Optional: [Technical Specification] | External: None
Outputs | 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, for example, 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.
Properties
Multiple Occurrences |
Event Driven |
Ongoing |
Optional |
Planned |
Repeatable |