1 / 19

Class and Method Design

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. DESIGN CRITERIA. Coupling.

margo
Download Presentation

Class and Method Design

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Class and Method Design Chapter 14

  2. 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

  3. DESIGN CRITERIA

  4. Coupling • Interdependency among modules • Interaction coupling through message passing

  5. Level Type Good No Direct Coupling Data Stamp Control Common or Global Bad Content or Pathological Types of Interactive Coupling

  6. “Single-mindedness of a module” Method cohesion Class cohesion Generalization/specialization cohesion Cohesion

  7. Types of Method Cohesion Level Type Good Functional Sequential Communicational Procedural Temporal or Classical Logical Bad Coincidental

  8. Types of Class Cohesion Level Type Good Ideal Mixed-role Mixed-domain Worse Mixed-instance

  9. 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

  10. OBJECT DESIGN ACTIVITIES

  11. 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

  12. Signatures for each method • Name of the method • Parameters or arguments to pass • Type of value the method will return to the calling method

  13. Identify Opportunities for Reuse • Patterns • Framework • Class libraries • Components

  14. 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

  15. METHOD SPECIFICATION

  16. Syntax • No formal syntax specification • General information • Events • Message Passing • Algorithm Specification

  17. Structured English

  18. (Get CD-info module) Accept (CD_title) {Required} Accept (CD_artist) {Required} Accept (CD_category) {Required} Accept (CD_length) Return Pseudocode Example

  19. 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.

More Related