DESIGNING USE-CASE REALIZATIONS WITH GoF DESIGN PATTERNS 徐迎晓 xuyingxiao@126.com 复旦大学软件学院
DESIGNING USE-CASE REALIZATIONS WITH GoF DESIGN PATTERNS 徐迎晓 xuyingxiao@126.com 复旦大学软件学院
OUTLINE Adapter Factory Singleton e Strategy e Composition ● Facade o Observer
OUTLINE Adapter Factory Singleton Strategy Composition Facade Observer
Adapter 问题:如何解决接口不兼容问题,几个 类似的构件接口不同,如何为其提供稳 定的接口? ●解决:通过中间的适配器对象,将构件 原有接口转换成另一个接口
Adapter 问题:如何解决接口不兼容问题,几个 类似的构件接口不同,如何为其提供稳 定的接口? 解决:通过中间的适配器对象,将构件 原有接口转换成另一个接口
Client Target Adaptee Request( SpecificRequesto adaptee Adapter Request I adaptee->SpecificRequestO
8Dc0山PM sDe/20256
ER s/20 ADAPTI 个D
Client Shape Point Line Square
Shape +setLocationo location display +fillo +setcolord +undisplayO EXCircle I+setLocation( +getLocation( H+( Point Line Square -+fillet displa yo +display +display) +setts Color(() +undisplayO tundisplayo) +undisplayo Hundisplaylto
Shape Client +setLocation( geoLocation +display( +setcolor0 +undisplayo Point Line Square Circle Displays Displays display HsetLocationo +m0 +m0 getLocation( Hundisplay0 H+undisplay0 -undisplayo +display 10 loro +undisplayo EXCircle +displays +undisplaylto setLocationo geoLocation setts)
class circle extends shape i private ExCircle pxc public Circle()「 pxc= new exCircle( void public display()i pxc. displayIt ()