Presentation is loading. Please wait.

Presentation is loading. Please wait.

Class and Method Design

Similar presentations


Presentation on theme: "Class and Method Design"— 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 Types of Interactive Coupling
Level Type Good No Direct Coupling Data Stamp Control Common or Global Bad Content or Pathological

6 Cohesion “Single-mindedness of a module” Method cohesion
Class cohesion Generalization/specialization 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 Connascence Creating the need to change another module as a result of changing one Minimize overall connascence Minimize across encapsulation boundaries Maximize within encapsulation boundary

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 Simple Contract Format
Method Name: Class Name: ID: Clients (Consumers): Associated Use Cases: Description of Responsibilities: Arguments Received: Type of Value Returned: Pre-Conditions: Post-Conditions:

15 METHOD SPECIFICATION

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

17 Structured English

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

19 Summary Translating the basic elements of OO analysis into design requires attention to prevent difficulties and conflicts in execution. Coupling, cohesion, and connascence are 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.


Download ppt "Class and Method Design"

Similar presentations


Ads by Google