您好,欢迎访问三七文档
当前位置:首页 > 电子/通信 > 综合/其它 > 7. LabVIEW编程:面向对象编程之设计模式一
LabVIEW编程:面向对象编程之设计模式一刘亮设计模式一•策略模式•观察者模式策略模式StrategyPattern/PolicyPattern软件开发中的“常数”•在何处工作•开发什么项目•使用何种编程语言修改•无论您的应用程序设计的有多好,如果没有任何改进,久而久之它将被淘汰……策略模式Duckquack()swim()display()//Otherduck-likemethodsMallardDuckdisplay(){//lookslikemallard}RedheadDuckdisplay(){//lookslikeredhead}类策略模式Duckquack()swim()display()//Otherduck-likemethodsMallardDuckdisplay(){//lookslikemallard}RedheadDuckdisplay(){//lookslikeredhead}继承策略模式Duckquack()swim()display()//Otherduck-likemethodsMallardDuckdisplay(){//lookslikemallard}RedheadDuckdisplay(){//lookslikeredhead}抽象方法动态分配策略模式Duckquack()swim()display()//Otherduck-likemethodsMallardDuckdisplay(){//lookslikemallard}RedheadDuckdisplay(){//lookslikeredhead}实现fly()Duckquack()swim()display()//Otherduck-likemethodsDuckquack()swim()display()fly()//Otherduck-likemethods策略模式MallardDuckdisplay(){//lookslikemallard}RedheadDuckdisplay(){//lookslikeredhead}新增行为Duckquack()swim()display()fly()//Otherduck-likemethods策略模式MallardDuckdisplay(){//lookslikemallard}RedheadDuckdisplay(){//lookslikeredhead}RubberDuckdisplay(){//rubberduck}橡皮鸭子不能飞display(){//rubberduck}RubberDuckdisplay(){//rubberduck}fly(){//overridetodonothing}Duckquack()swim()display()fly()//Otherduck-likemethods策略模式MallardDuckdisplay(){//lookslikemallard}RedheadDuckdisplay(){//lookslikeredhead}重写方法继承继承的一种重要用途是实现代码的重用display(){//rubberduck}fly(){//overridetodonothing}RubberDuckDuckquack()swim()display()fly()//Otherduck-likemethods策略模式MallardDuckdisplay(){//lookslikemallard}RedheadDuckdisplay(){//lookslikeredhead}quack(){//overridetodonothing}display(){//decoyduck}fly(){//overridetodonothing}DecoyDuck重复继承新增继承继承不易维护display(){//rubberduck}RubberDuckDuckswim()display()//Otherduck-likemethods策略模式MallardDuckdisplay(){//lookslikemallard}RedheadDuckdisplay(){//lookslikeredhead}display(){//decoyduck}DecoyDuckFlyablefly()Quackablequack()策略模式•设计原则一DuckBehaviors策略模式•设计原则二fly()interfaceFlyBehaviorfly(){//implementsduckflying}FlywithWingsfly(){//donothing–can’tfly!}FlyNoWay策略模式quack()interfaceQuackBehaviorquack(){//implementsduckquacking}Quackquack(){//rubberduckiesqueak}Squeakquack(){//donothing–can’tquack!}MuteQuack策略模式DuckFlyBehaviorQuackBehaviorDuckBehaviorsperformQuack()swim()display()perfomFly()//Otherduck-likemethodsfly()quack()策略模式StrategyPattern/PolicyPattern观察者模式ObserverPattern观察者模式订阅用户观察者模式订阅用户观察者模式订阅用户观察者模式订阅用户观察者模式订阅用户观察者模式NationalInstrumentsPriceSymbolUpdate()InvestorInvestor()SendData()Investor()观察者模式NationalInstrumentsPriceSymbolUpdate()IObserverInterfaceSendData()Investor()InvestorInvestor()SendData()观察者模式NationalInstrumentsPriceSymbolAddObserver()RemoveObserver()Update()IObserverInterfaceSendData()Investor()InvestorInvestor()SendData()观察者模式StockabstractPriceSymbolAddObserver()RemoveObserver()Update()IObserverInterfaceSendData()Investor()InvestorInvestor()SendData()NationalInstrumentsUpdate()观察者模式ObserverPattern更多技术资源下载GSDZone.net/community敬请进入下一环节
本文标题:7. LabVIEW编程:面向对象编程之设计模式一
链接地址:https://www.777doc.com/doc-4546023 .html