Lecture Systems analysis and design with UML (3 e) Chapter 9 Class and method design

36 560 0
Lecture Systems analysis and design with UML (3 e)  Chapter 9 Class and method design

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

This chapter presents a set of criteria, activities, and techniques used to design classes and methods. Together they are used to ensure the objectoriented design communicates how the system needs to be coded.

Chapter 9: Class and Method Design PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 3rd Edition Copyright © 2009 John Wiley & Sons, Inc All rights reserved Objectives • Become familiar with coupling, cohesion, and connascence • Be able to specify, restructure, and optimize object designs • Be able to identify the reuse of predefined classes, libraries, frameworks, and components • Be able to specify constraints and contracts • Be able to create a method specification PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 3rd Edition Copyright © 2009 John Wiley & Sons, Inc All rights reserved BASIC CHARACTERISTICS OF OBJECT ORIENTATION PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 3rd Edition Copyright © 2009 John Wiley & Sons, Inc All rights reserved Elements of OOSAD • • • • • • Classes Objects Attributes States Methods Messages PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 3rd Edition Copyright © 2009 John Wiley & Sons, Inc All rights reserved Encapsulation & Info Hiding • Hiding the content of the object from outside view • Communication only through object’s methods • Key to reusability PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 3rd Edition Copyright © 2009 John Wiley & Sons, Inc All rights reserved Polymorphism & Dynamic Binding • 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 PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 3rd Edition Copyright © 2009 John Wiley & Sons, Inc All rights reserved Polymorphism Example PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 3rd Edition Copyright © 2009 John Wiley & Sons, Inc All rights reserved Inheritance • Single inheritance one parent class • Multiple inheritance multiple parent classes • Redefinition and inheritance conflict • Most inheritance conflicts are due to poor classification PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 3rd Edition Copyright © 2009 John Wiley & Sons, Inc All rights reserved 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 PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 3rd Edition Copyright © 2009 John Wiley & Sons, Inc All rights reserved DESIGN CRITERIA PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 3rd Edition Copyright © 2009 John Wiley & Sons, Inc All rights reserved Define constraints • • • • Pre-conditions Post conditions Invariants How to handle violations (exceptions in C+ + and Java)? PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 3rd Edition Copyright © 2009 John Wiley & Sons, Inc All rights reserved Identify Opportunities for Reuse • • • • Patterns Framework Class libraries Components PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 3rd Edition Copyright © 2009 John Wiley & Sons, Inc All rights reserved Restructure the Design • • • • Factoring Map design to current language Normalization Assure all inheritance relationships support only generalization/specialization semantics PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 3rd Edition Copyright © 2009 John Wiley & Sons, Inc All rights reserved 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 re-computation by creating derived attributes and triggers • • • • PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 3rd Edition Copyright © 2009 John Wiley & Sons, Inc All rights reserved CONSTRAINTS AND CONTRACTS PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 3rd Edition Copyright © 2009 John Wiley & Sons, Inc All rights reserved Types of Constraints • Precondition Must be true before the method executes • Post-condition Must be true after the method finishes • Invariant Must always be true PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 3rd Edition Copyright © 2009 John Wiley & Sons, Inc All rights reserved Invariants on a Class Diagram PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 3rd Edition Copyright © 2009 John Wiley & Sons, Inc All rights reserved Contracts • Contracts document message passing between object • A contract is created for each method that is publicly visible in a class • Should contain enough information for the programmer to understand what the method is supposed to PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 3rd Edition Copyright © 2009 John Wiley & Sons, Inc All rights reserved Elements of a Contract PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 3rd Edition Copyright © 2009 John Wiley & Sons, Inc All rights reserved Sample Contract Form PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 3rd Edition Copyright © 2009 John Wiley & Sons, Inc All rights reserved METHOD SPECIFICATION PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 3rd Edition Copyright © 2009 John Wiley & Sons, Inc All rights reserved Method Specification Syntax • • • • • No formal syntax specification General information Events Message Passing Algorithm Specification PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 3rd Edition Copyright © 2009 John Wiley & Sons, Inc All rights reserved Structured English PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 3rd Edition Copyright © 2009 John Wiley & Sons, Inc All rights reserved Pseudocode Example (Get CD-info Accept Accept Accept Accept Return module) (CD_title) {Required} (CD_artist) {Required} (CD_category) {Required} (CD_length) PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 3rd Edition Copyright © 2009 John Wiley & Sons, Inc All rights reserved Summary • • • • • Basic Characteristics of Object Orientation Design Criteria Object Design Activities Constraints and Contracts Method Specification PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 3rd Edition Copyright © 2009 John Wiley & Sons, Inc All rights reserved ... Design with UML, 3rd Edition Copyright © 20 09 John Wiley & Sons, Inc All rights reserved DESIGN CRITERIA PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, ... Tegarden Systems Analysis and Design with UML, 3rd Edition Copyright © 20 09 John Wiley & Sons, Inc All rights reserved Cohesion • “Single-mindedness of a module” • Method cohesion • Class cohesion... constraints and contracts • Be able to create a method specification PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 3rd Edition Copyright © 20 09 John Wiley

Ngày đăng: 16/05/2017, 13:42

Mục lục

  • Chapter 9: Class and Method Design

  • Basic Characteristics of Object Orientation

  • Encapsulation & Info Hiding

  • Polymorphism & Dynamic Binding

  • Types of Interactive Coupling

  • Types of Method Cohesion

  • Types of Class Cohesion

  • Signatures for each method

  • Identify Opportunities for Reuse

  • Invariants on a Class Diagram

  • Elements of a Contract

Tài liệu cùng người dùng

Tài liệu liên quan