200 likes | 353 Views
This chapter explores critical concepts in low-level or detailed design, emphasizing the importance of understanding pre-existing classes and the necessity of some code for instantiating new classes. It defines coupling, method cohesion, and connascence as vital criteria in evaluating design quality. Various levels and types of coupling and cohesion are discussed, alongside the significance of method specifications. Designers are encouraged to optimize designs, create constraints, and use contracts to foster collaboration among modules and ensure robust system architecture.
E N D
Class and Method Design Chapter 14
Key Concepts • Low-level or detailed design is critical despite libraries and components • Pre-existing classes need to be understood and organized • Some, if not all code, is generally still needed to instantiate new classes
Coupling • Interdependency among modules • Interaction coupling through message passing
Level Type Good No Direct Coupling Data Stamp Control Common or Global Bad Content or Pathological Types of Interactive Coupling
“Single-mindedness of a module” Method cohesion Class cohesion Generalization/specialization cohesion Cohesion
Types of Method Cohesion Level Type Good Functional Sequential Communicational Procedural Temporal or Classical Logical Bad Coincidental
Types of Class Cohesion Level Type Good Ideal Mixed-role Mixed-domain Worse Mixed-instance
Creating the need to change another module as a result of changing one Minimize overall connascence Minimize across encapsulation boundaries Maximize within encapsulation boundary Connascence
Additional Specification • First review the current set of models • Sufficient but only necessary classes to solve problem • No missing attributes or methods • No extraneous attributes or methods • Examine visibility
Signatures for each method • Name of the method • Parameters or arguments to pass • Type of value the method will return to the calling method
Identify Opportunities for Reuse • Patterns • Framework • Class libraries • Components
Method Name: Class Name: ID: Clients (Consumers): Associated Use Cases: Description of Responsibilities: Arguments Received: Type of Value Returned: Pre-Conditions: Post-Conditions: Simple Contract Format
Syntax • No formal syntax specification • General information • Events • Message Passing • Algorithm Specification
(Get CD-info module) Accept (CD_title) {Required} Accept (CD_artist) {Required} Accept (CD_category) {Required} Accept (CD_length) Return Pseudocode Example
Summary • Translating the basic elements of OO analysis into design requires attention to prevent difficulties and conflicts in execution. • Coupling, cohesion, and connascenceare proposed for criteria for evaluating design. • The designer will look for opportunities to optimize the design, will create constraints and contracts, and will specify methods.