《7. LabVIEW编程:面向对象编程之设计模式一.ppt》由会员分享,可在线阅读,更多相关《7. LabVIEW编程:面向对象编程之设计模式一.ppt(33页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。
1、LabVIEW编程:面向对象编程之设计模式一刘亮设计模式一策略模式观察者模式策略模式策略模式Strategy Pattern/Policy Pattern软件开发中的“常数”在何处工作开发什么项目使用何种编程语言修改无论您的应用程序设计的有多好,如果没有任何改进,久而久之它将被淘汰策略模式Duckquack()swim()display()/Other duck-like methodsMallard Duckdisplay()/looks like mallardRedhead Duckdisplay()/looks like redhead类策略模式Duckquack()swim()dis
2、play()/Other duck-like methodsMallard Duckdisplay()/looks like mallardRedhead Duckdisplay()/looks like redhead继承策略模式Duckquack()swim()display()/Other duck-like methodsMallard Duckdisplay()/looks like mallardRedhead Duckdisplay()/looks like redhead抽象方法动态分配策略模式Duckquack()swim()display()/Other duck-like
3、 methodsMallard Duckdisplay()/looks like mallardRedhead Duckdisplay()/looks like redhead实现fly()Duckquack()swim()display()/Other duck-like methodsDuckquack()swim()display()fly()/Other duck-like methods策略模式Mallard Duckdisplay()/looks like mallardRedhead Duckdisplay()/looks like redhead新增行为Duckquack()s
4、wim()display()fly()/Other duck-like methods策略模式Mallard Duckdisplay()/looks like mallardRedhead Duckdisplay()/looks like redheadRubber Duckdisplay()/rubber duck橡皮鸭子不能飞display()/rubber duckRubber Duckdisplay()/rubber duckfly()/override to do nothingDuckquack()swim()display()fly()/Other duck-like metho
5、ds策略模式Mallard Duckdisplay()/looks like mallardRedhead Duckdisplay()/looks like redhead重写方法继承继承的一种重要用途是实现代码的重用display()/rubber duckfly()/override to do nothingRubber DuckDuckquack()swim()display()fly()/Other duck-like methods策略模式Mallard Duckdisplay()/looks like mallardRedhead Duckdisplay()/looks like
6、 redheadquack()/override to do nothingdisplay()/decoy duckfly()/override to do nothingDecoy Duck重复继承新增继承继承不易维护display()/rubber duckRubber DuckDuckswim()display()/Other duck-like methods策略模式Mallard Duckdisplay()/looks like mallardRedhead Duckdisplay()/looks like redheaddisplay()/decoy duckDecoy DuckF
7、lyablefly()Quackablequack()策略模式设计原则一Duck Behaviors策略模式设计原则二fly()Fly Behaviorfly()/implements duck flyingFly with Wingsfly()/do nothing cant fly!Fly No Way策略模式quack()Quack Behaviorquack()/implements duck quackingQuackquack()/rubber duckie squeakSqueakquack()/do nothing cant quack!Mute Quack策略模式DuckFl
8、y BehaviorQuack BehaviorDuck BehaviorsperformQuack()swim()display()perfomFly()/Other duck-like methodsfly()quack()策略模式策略模式Strategy Pattern/Policy PatternDEMO观察者模式察者模式Observer Pattern观察者模式订阅用户观察者模式我要订阅订阅用户观察者模式订阅用户观察者模式订阅用户我不订阅了观察者模式订阅用户观察者模式National InstrumentsPriceSymbolUpdate()InvestorInvestor()Se
9、nd Data()Investor()观察者模式National InstrumentsPriceSymbolUpdate()IObserverSend Data()Investor()InvestorInvestor()Send Data()观察者模式National InstrumentsPriceSymbolAdd Observer()Remove Observer()Update()IObserverSend Data()Investor()InvestorInvestor()Send Data()观察者模式StockPriceSymbolAdd Observer()Remove Observer()Update()IObserverSend Data()Investor()InvestorInvestor()Send Data()National InstrumentsUpdate()观察者模式察者模式Observer PatternDEMO更多技术资源下载GSDZ