欢迎来到淘文阁 - 分享文档赚钱的网站! | 帮助中心 好文档才是您的得力助手!
淘文阁 - 分享文档赚钱的网站
全部分类
  • 研究报告>
  • 管理文献>
  • 标准材料>
  • 技术资料>
  • 教育专区>
  • 应用文书>
  • 生活休闲>
  • 考试试题>
  • pptx模板>
  • 工商注册>
  • 期刊短文>
  • 图片设计>
  • ImageVerifierCode 换一换

    面向对象系统分析与设计_观察者模式.ppt

    • 资源ID:69529874       资源大小:914.50KB        全文页数:16页
    • 资源格式: PPT        下载积分:15金币
    快捷下载 游客一键下载
    会员登录下载
    微信登录下载
    三方登录下载: 微信开放平台登录   QQ登录  
    二维码
    微信扫一扫登录
    下载资源需要15金币
    邮箱/手机:
    温馨提示:
    快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。
    如填写123,账号就是123,密码也是123。
    支付方式: 支付宝    微信支付   
    验证码:   换一换

     
    账号:
    密码:
    验证码:   换一换
      忘记密码?
        
    友情提示
    2、PDF文件下载后,可能会被浏览器默认打开,此种情况可以点击浏览器菜单,保存网页到桌面,就可以正常下载了。
    3、本站不支持迅雷下载,请使用电脑自带的IE浏览器,或者360浏览器、谷歌浏览器下载即可。
    4、本站资源下载后的文档和图纸-无水印,预览文档经过压缩,下载后原文更清晰。
    5、试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。

    面向对象系统分析与设计_观察者模式.ppt

    06 一月 2023Neusoft Computer Science and Technology Department copy right1OO System Analysis&Design【The Observer Pattern】06 一月 2023Neusoft Computer Science and Technology Department copy right2Weather Monitoring overviewStats ForecastCurrent pulls data WeatherDataobject displays Weather StationOur client providesWhat we implementinternet06 一月 2023Neusoft Computer Science and Technology Department copy right3What is WeatherData object?lIt knows how to talk to the physical Weather Station,to get updated data.(we dont care for this process.)lIt then updates its displays for the three different display elements.gets data updates o它提供了三个方法(get开头),可以分别取得实时的温度、湿度和大气压力,还有一个MeasurementsChanged()方法,当任何天气状况发生变化的时候,这个方法都会自动被触发,当前这个方法只是一个空函数,扩展的代码还需要我们自己去扩充。06 一月 2023Neusoft Computer Science and Technology Department copy right41 客户提供了获取实时的天气状况的方法2 MeasurementsChanged()方法会在天气状况变化时被自动调用。3 系统要实现三种显示模式,分别显示天气状况、天气统计和天气预测,而且这些显示的信息必须跟当前最新的天气状况实时同步。4 系统还必须支持在显示方式上的扩展性,而且使用者可以任意添加和移除不同的显示模式。06 一月 2023Neusoft Computer Science and Technology Department copy right5o/伪代码opublic class WeatherDatao o/实例化显示设备(省略)opublic void MeasurementsChanged()oofloat temp=getTemperature();/取得温度ofloat humidity=getHumidity();/取得湿度ofloat pressure=getPressure();/取得气压ocurrentConditionsDisplay.update(temp,humidity,pressure);/同步显示当前天气状况ostatisticsDisplay.update(temp,humidity,pressure);/同步显示天气统计信息oforecastDisplay.update(temp,humidity,pressure);/同步显示天气预报信息oo06 一月 2023Neusoft Computer Science and Technology Department copy right606 一月 2023Neusoft Computer Science and Technology Department copy right7Our job is:lTo create an app that uses the WheatherData object to update three displays.06 一月 2023Neusoft Computer Science and Technology Department copy right8The kernel of the problemWeatherData object to update if you requiredisplays publishers subscribers to deliver if you subscribe subject object observer objects to notify if you observe 06 一月 2023Neusoft Computer Science and Technology Department copy right9The Observer PatternlThe Observer Pattern defines a one-to-many relationship between objects so that when one object changes state,all of its dependents are notified and updated automatically.06 一月 2023Neusoft Computer Science and Technology Department copy right10Class diagram for Observer PatternEach subject canhave many observersupdate()will be called when the Subjects state changes.These methods will be called When to register as observers,remove themselves from Being observers,or update allthe observers whenever state changes.06 一月 2023Neusoft Computer Science and Technology Department copy right11To develop app from the interfaceoSubject(被观察的对象接口)(被观察的对象接口)n 规定ConcreteSubject的统一接口;n每个Subject可以有多个Observer;oConcreteSubject(具体被观察对象)(具体被观察对象)n维护对所有具体观察者的引用的列表;n状态发生变化时会发送通知给所有注册的观察者。oObserver(观察者接口)(观察者接口)n规定ConcreteObserver的统一接口;n定义了一个update()方法,在被观察对象状态改变时会被调用。oConcreteObserver(具体观察者)(具体观察者)n维护一个对ConcreteSubject的引用;n特定状态与ConcreteSubject同步;n实现Observer接口,通过update()方法接收ConcreteSubject的通知。06 一月 2023Neusoft Computer Science and Technology Department copy right12顺序图06 一月 2023Neusoft Computer Science and Technology Department copy right1306 一月 2023Neusoft Computer Science and Technology Department copy right14Designing the Weather StationExercise:A Spring Tour planoSpring tour plan manage system need to maintain a collection of the participants oNotify all members of the information about the planoEach member have their own arrival at the point of collection06 一月 2023Neusoft Computer Science and Technology Department copy right1506 一月 2023Neusoft Computer Science and Technology Department copy right16Class is overReworking the Weather Station with the Javas built-in Observer Pattern!

    注意事项

    本文(面向对象系统分析与设计_观察者模式.ppt)为本站会员(qwe****56)主动上传,淘文阁 - 分享文档赚钱的网站仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知淘文阁 - 分享文档赚钱的网站(点击联系客服),我们立即给予删除!

    温馨提示:如果因为网速或其他原因下载失败请重新下载,重复下载不扣分。




    关于淘文阁 - 版权申诉 - 用户使用规则 - 积分规则 - 联系我们

    本站为文档C TO C交易模式,本站只提供存储空间、用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。本站仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知淘文阁网,我们立即给予删除!客服QQ:136780468 微信:18945177775 电话:18904686070

    工信部备案号:黑ICP备15003705号 © 2020-2023 www.taowenge.com 淘文阁 

    收起
    展开