面向对象设计准则 ● 以设计元素的耦合性、内聚性以及复用性为主要准 则(既有对传统方法的借鉴,又有创新)。 ● 耦合性(Coupling) 一交互耦合:成分之间通过消息交互,越松散越好。 一继承耦合:成分之间有继承关系,越紧密越好。 ●内聚性(Cohension) 一操作内聚:完成单一功能的操作的内聚最高。 一类内聚:每个操作也是高内聚的。 ●复用性 一执行代码、源代码级、分析和设计结果、体系结构 的复用和继承
Slide 8A.16 16/44 面向对象设计准则 ⚫ 以设计元素的耦合性、内聚性以及复用性为主要准 则(既有对传统方法的借鉴,又有创新) 。 ⚫ 耦合性(Coupling) – 交互耦合:成分之间通过消息交互,越松散越好。 – 继承耦合:成分之间有继承关系,越紧密越好。 ⚫ 内聚性(Cohension) – 操作内聚:完成单一功能的操作的内聚最高。 – 类内聚:每个操作也是高内聚的。 ⚫ 复用性 – 执行代码、源代码级、分析和设计结果、体系结构 的复用和继承
OO Design Concepts Abstraction-data,procedure,control door open manufacturer walk to door, model number type reach for swing direction open dee repeatuntildooropens inserts walk thro tum knob clockwise; lights if knob doesn'ttum,then close doa type take key out number find comectkey; weight insertin lock; endif opening mechanism pullpush door move out of way; implemented w end repeat implemented as a data structure object that is a_ Refinement-top-down design strategy
Slide 8A.17 17/44 OO Design Concepts
Design Concepts Sizing Modules:Two Views What's How big inside?? is it?? 00 MODULE
Slide 8A.18 18/44 Design Concepts
OO Design Concepts Modularity module development cost cost of software module integration cost optimal number number of modules of modules
Slide 8A.19 19/44 OO Design Concepts
OO Design Concepts Information Hiding module algorithm controlled interface ·data structure details of external interface resource allocation policy clients "secret" reduces the likelihood of “side effects” limits the global impact of local design decisions a specific design decision √emphasizes leads to encapsulation an attribute of communication through high quality design controlled interfaces results in higher quality software discourages the use of global data
Slide 8A.20 20/44 OO Design Concepts