Presentation is loading. Please wait.

Presentation is loading. Please wait.

PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design Copyright 2001 © John Wiley & Sons, Inc. All rights reserved. Slide 1.

Similar presentations


Presentation on theme: "PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design Copyright 2001 © John Wiley & Sons, Inc. All rights reserved. Slide 1."— Presentation transcript:

1 PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design Copyright 2001 © John Wiley & Sons, Inc. All rights reserved. Slide 1 Class and Method Design Chapter 14

2 PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design Copyright 2001 © John Wiley & Sons, Inc. All rights reserved. Slide 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 PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design Copyright 2001 © John Wiley & Sons, Inc. All rights reserved. Slide 3 REVISITING THE BASIC CHARACTERISTICS OF OBJECT-ORIENTATION

4 PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design Copyright 2001 © John Wiley & Sons, Inc. All rights reserved. Slide 4 Elements Classes Objects Attributes States Methods Messages

5 PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design Copyright 2001 © John Wiley & Sons, Inc. All rights reserved. Slide 5 Encapsulation Hiding the content of the object from outside view Communication only through object’s methods Key to reusability

6 PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design Copyright 2001 © John Wiley & Sons, Inc. All rights reserved. Slide 6 Polymorphism Same message triggers different methods in different objects Dynamic binding means specific method is selected at run time Implementation of dynamic binding is language specific Need to be very careful about run time errors Need to ensure semantic consistency

7 PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design Copyright 2001 © John Wiley & Sons, Inc. All rights reserved. Slide 7 Inheritance Single inheritance -- one parent class Multiple inheritance -- multiple parent classes Redefinition and inheritance conflict Most inheritance conflicts are due to poor classification

8 PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design Copyright 2001 © John Wiley & Sons, Inc. All rights reserved. Slide 8 Rumbaugh’s Rules Query operations should not be redefined Methods that redefine inherited ones should only restrict the semantics of the inherited ones The underlying semantics of the inherited method should never be changed The signature (argument list) of the inherited method should never be changed

9 PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design Copyright 2001 © John Wiley & Sons, Inc. All rights reserved. Slide 9 Additional Inheritance Conflicts Two inherited attributes or methods have same name and semantics Two inherited attributes or methods have different name, but same semantics Two inherited attributes or methods have same name and different semantics

10 PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design Copyright 2001 © John Wiley & Sons, Inc. All rights reserved. Slide 10 Your Turn A major university graduates about 10,000 students a year and the development office wants to build a web-based system to solicit and track donations. In such a system, name 3 examples of classes that might have one subclass; name 1 example of a subclass that might have 2 superclasses

11 PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design Copyright 2001 © John Wiley & Sons, Inc. All rights reserved. Slide 11 DESIGN CRITERIA

12 PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design Copyright 2001 © John Wiley & Sons, Inc. All rights reserved. Slide 12 Coupling Interdependency among modules Interaction coupling through message passing

13 PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design Copyright 2001 © John Wiley & Sons, Inc. All rights reserved. Slide 13 Law of Demeter Messages should be sent only by an object to itself to an object contained in an attribute of itself or a superclass to an object that is passed as a parameter to the method to an object that is created by the method to an object that is stored in a global variable

14 PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design Copyright 2001 © John Wiley & Sons, Inc. All rights reserved. Slide 14 Types of Interactive Coupling LevelType GoodNo Direct Coupling Data Stamp Control Common or Global BadContent or Pathological

15 PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design Copyright 2001 © John Wiley & Sons, Inc. All rights reserved. Slide 15 Cohesion “Single-mindedness of a module” Method cohesion Class cohesion Generalization/specialization cohesion

16 PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design Copyright 2001 © John Wiley & Sons, Inc. All rights reserved. Slide 16 Types of Method Cohesion LevelType GoodFunctional Sequential Communicational Procedural Temporal or Classical Logical BadCoincidental

17 PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design Copyright 2001 © John Wiley & Sons, Inc. All rights reserved. Slide 17 Types of Class Cohesion LevelType GoodIdeal Mixed-role Mixed-domain WorseMixed-instance

18 PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design Copyright 2001 © John Wiley & Sons, Inc. All rights reserved. Slide 18 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

19 PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design Copyright 2001 © John Wiley & Sons, Inc. All rights reserved. Slide 19 Types of Connascence Type Name Type or Class Convention Algorithm Position

20 PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design Copyright 2001 © John Wiley & Sons, Inc. All rights reserved. Slide 20 OBJECT DESIGN ACTIVITIES

21 PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design Copyright 2001 © John Wiley & Sons, Inc. All rights reserved. Slide 21 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

22 PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design Copyright 2001 © John Wiley & Sons, Inc. All rights reserved. Slide 22 Signatures for each method Name of the method Parameters or arguments to pass Type of value the method will return to the calling method

23 PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design Copyright 2001 © John Wiley & Sons, Inc. All rights reserved. Slide 23 Define constraints Pre-conditions Post conditions Invariants How to handle violations (exceptions in C++ and Java)?

24 PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design Copyright 2001 © John Wiley & Sons, Inc. All rights reserved. Slide 24 Identify Opportunities for Reuse Patterns Framework Class libraries Components

25 PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design Copyright 2001 © John Wiley & Sons, Inc. All rights reserved. Slide 25 Restructure the Design Factoring Map design to current language Normalization Assure all inheritance relationships support only generalization/specialization semantics

26 PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design Copyright 2001 © John Wiley & Sons, Inc. All rights reserved. Slide 26 Optimizing the Design Review access paths Review attributes of each class Review direct and indirect fan-out Consider execution order of statements in often-used methods Avoid recomputation by creating derived attributes and triggers

27 PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design Copyright 2001 © John Wiley & Sons, Inc. All rights reserved. Slide 27 Constraints and Contracts A set of constraints and guarantees Written in natural language, structured English, pseudocode, or formal language

28 PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design Copyright 2001 © John Wiley & Sons, Inc. All rights reserved. Slide 28 Invariants on a Class Diagram

29 PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design Copyright 2001 © John Wiley & Sons, Inc. All rights reserved. Slide 29 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:

30 PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design Copyright 2001 © John Wiley & Sons, Inc. All rights reserved. Slide 30 METHOD SPECIFICATION

31 PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design Copyright 2001 © John Wiley & Sons, Inc. All rights reserved. Slide 31 Syntax No formal syntax specification General information Events Message Passing Algorithm Specification

32 PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design Copyright 2001 © John Wiley & Sons, Inc. All rights reserved. Slide 32 Structured English

33 PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design Copyright 2001 © John Wiley & Sons, Inc. All rights reserved. Slide 33 Pseudocode Example (Get CD-info module) Accept (CD_title) {Required} Accept (CD_artist) {Required} Accept (CD_category) {Required} Accept (CD_length) Return

34 PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design Copyright 2001 © John Wiley & Sons, Inc. All rights reserved.

35 PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design Copyright 2001 © John Wiley & Sons, Inc. All rights reserved.

36 PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design Copyright 2001 © John Wiley & Sons, Inc. All rights reserved.

37 PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design Copyright 2001 © John Wiley & Sons, Inc. All rights reserved.

38 PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design Copyright 2001 © John Wiley & Sons, Inc. All rights reserved. Slide 38 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.

39 PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design Copyright 2001 © John Wiley & Sons, Inc. All rights reserved. Slide 39 Expanding the Domain The C and C++ users group is a source of unusually rich thoughts regarding OO development. Check them out at: http://www.accu.org/ http://www.accu-usa.org/


Download ppt "PowerPoint Presentation for Dennis, Wixom & Tegarden Systems Analysis and Design Copyright 2001 © John Wiley & Sons, Inc. All rights reserved. Slide 1."

Similar presentations


Ads by Google