1. Trang chủ
  2. » Công Nghệ Thông Tin

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

36 73 0

Đ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

Thông tin cơ bản

Định dạng
Số trang 36
Dung lượng 518,29 KB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

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

Trang 1

PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 3rd Edition

Copyright © 2009 John Wiley & Sons, Inc All rights reserved

Chapter 9:

Class and Method Design

Trang 2

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

Trang 3

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

Trang 4

PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 3rd Edition

Copyright © 2009 John Wiley & Sons, Inc All rights reserved

Trang 5

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

Trang 6

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

Trang 7

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

Trang 8

PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 3rd Edition

Copyright © 2009 John Wiley & Sons, Inc All rights reserved

• Most inheritance conflicts are

due to poor classification

Trang 9

PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 3rd Edition

Copyright © 2009 John Wiley & Sons, Inc All rights reserved

Trang 10

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

Trang 11

PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 3rd Edition

Copyright © 2009 John Wiley & Sons, Inc All rights reserved

Coupling

• Interdependency among modules

• Interaction coupling through message passing

Trang 12

PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 3rd Edition

Copyright © 2009 John Wiley & Sons, Inc All rights reserved

Trang 13

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 Interactive Coupling

Trang 14

PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 3rd Edition

Cohesion

• “Single-mindedness of a module”

• Method cohesion

• Class cohesion

Trang 15

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 Method Cohesion

Trang 16

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 Class Cohesion

Trang 17

PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 3rd Edition

Copyright © 2009 John Wiley & Sons, Inc All rights reserved

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

Trang 18

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 Connascence

Trang 19

PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 3rd Edition

Copyright © 2009 John Wiley & Sons, Inc All rights reserved

OBJECT DESIGN ACTIVITIES

Trang 20

PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 3rd Edition

Copyright © 2009 John Wiley & Sons, Inc All rights reserved

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

Trang 21

PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 3rd Edition

Copyright © 2009 John Wiley & Sons, Inc All rights reserved

Signatures for each method

• Name of the method

• Parameters or arguments to pass

• Type of value the method will return to the calling method

Trang 22

PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 3rd Edition

Copyright © 2009 John Wiley & Sons, Inc All rights reserved

Trang 23

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

Trang 24

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

Trang 25

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

Trang 26

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

Trang 27

PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 3rd Edition

Copyright © 2009 John Wiley & Sons, Inc All rights reserved

Trang 28

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

Trang 29

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 do

Trang 30

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

Trang 31

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

Trang 32

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

Trang 33

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

Trang 34

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

Trang 35

PowerPoint Presentation for Dennis, Wixom, & Tegarden Systems Analysis and Design with UML, 3rd Edition

Copyright © 2009 John Wiley & Sons, Inc All rights reserved

Return

Trang 36

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

Ngày đăng: 15/05/2020, 22:28

TỪ KHÓA LIÊN QUAN

TÀI LIỆU CÙNG NGƯỜI DÙNG

TÀI LIỆU LIÊN QUAN