当前位置: 首页 > news >正文

厦门网站推广费用网站浏览器

厦门网站推广费用,网站浏览器,seo文章外包,成都建设厅网站概念 备忘录模式是一种行为型设计模式,用于捕获和存储对象的内部状态,并在需要时将对象恢复到之前的状态。 备忘录模式允许在不暴露对象内部实现细节的情况下,对对象进行状态的保存和恢复。 角色介绍 Originator:原发器&#x…

概念

备忘录模式是一种行为型设计模式,用于捕获和存储对象的内部状态,并在需要时将对象恢复到之前的状态。
备忘录模式允许在不暴露对象内部实现细节的情况下,对对象进行状态的保存和恢复。

角色介绍

  • Originator:原发器,负责创建备忘录对象,并将其当前状态保存到备忘录中,也可以从备忘录中恢复自身状态。
  • Memento:备忘录,用于存储发起人的状态,通常具备对发起人状态的访问权限。
  • Caretaker:管理者,负责管理备忘录对象,可以保存多个备忘录对象,并在需要时将其提供给发起人进行状态的恢复。

UML

备忘录

代码实现

/*** 备忘录*/
data class Memento(val state: String? = null
)/*** 原发器*/
class Originator {var state: String? = nullfun save(): Memento {return Memento(state)}fun recover(memento: Memento) {state = memento.state}}/*** 看管人*/
class Caretaker {private val mementos = ArrayList<Memento>()fun addMemento(memento: Memento) {mementos.add(memento)}fun getMemento(i: Int): Memento {return mementos[i]}
}fun main() {val originator = Originator()val caretaker = Caretaker()originator.state = "State#1"originator.state = "State#2"caretaker.addMemento(originator.save())originator.state = "State#3"caretaker.addMemento(originator.save())originator.state = "State#4"println("Current State:${originator.state}")originator.recover(caretaker.getMemento(0))println("0 State:${originator.state}")originator.recover(caretaker.getMemento(1))println("1 State:${originator.state}")
}

优缺点

优点

  • 封装性
  • 简易恢复和撤销
  • 简化发起人
    缺点
  • 增加内存使用
  • 性能开销
  • 复杂性

应用场景

适用于需要维护对象状态的历史记录,而不想暴露复杂的内部状态。

  • 文本编辑器
  • 绘图应用程序
  • 数据库系统
  • 游戏开发
  • 版本控制系统

总结

备忘录适用于需要保存/恢复数据的相关状态场景,并提供一个可回滚的操作。
为了符合迪米特原则,还需增加一个管理备忘录的类;为了节省内容可使用配合原型模式使用。

参考:

  • https://www.cnblogs.com/jiangzhaowei/p/7287359.html
  • https://www.runoob.com/design-pattern/memento-pattern.html
  • https://www.cnblogs.com/cativen/p/16641173.html

文章转载自:
http://efferent.wqfj.cn
http://blatherskite.wqfj.cn
http://effectiveness.wqfj.cn
http://eutherian.wqfj.cn
http://diphthongal.wqfj.cn
http://siluroid.wqfj.cn
http://celibacy.wqfj.cn
http://vaticination.wqfj.cn
http://consequentially.wqfj.cn
http://hampshire.wqfj.cn
http://sporulate.wqfj.cn
http://spot.wqfj.cn
http://nadine.wqfj.cn
http://ankylosis.wqfj.cn
http://thought.wqfj.cn
http://pacificator.wqfj.cn
http://zoophysics.wqfj.cn
http://harmfulness.wqfj.cn
http://synectics.wqfj.cn
http://imperfectness.wqfj.cn
http://parol.wqfj.cn
http://duff.wqfj.cn
http://sentimentalist.wqfj.cn
http://table.wqfj.cn
http://unmortise.wqfj.cn
http://gentilism.wqfj.cn
http://cactus.wqfj.cn
http://fungous.wqfj.cn
http://unconfessed.wqfj.cn
http://pix.wqfj.cn
http://wienie.wqfj.cn
http://depollution.wqfj.cn
http://trapezohedron.wqfj.cn
http://crucis.wqfj.cn
http://indeclinable.wqfj.cn
http://sendup.wqfj.cn
http://compnserve.wqfj.cn
http://stygian.wqfj.cn
http://upcurl.wqfj.cn
http://ausgleich.wqfj.cn
http://diascope.wqfj.cn
http://fruitery.wqfj.cn
http://plastics.wqfj.cn
http://escapist.wqfj.cn
http://tlac.wqfj.cn
http://nib.wqfj.cn
http://bogus.wqfj.cn
http://imperatively.wqfj.cn
http://odorously.wqfj.cn
http://staffage.wqfj.cn
http://sneezes.wqfj.cn
http://faceted.wqfj.cn
http://reink.wqfj.cn
http://toxophily.wqfj.cn
http://zack.wqfj.cn
http://bregma.wqfj.cn
http://collard.wqfj.cn
http://uddered.wqfj.cn
http://photoxylography.wqfj.cn
http://manly.wqfj.cn
http://berm.wqfj.cn
http://zeatin.wqfj.cn
http://spoor.wqfj.cn
http://excipient.wqfj.cn
http://manta.wqfj.cn
http://gran.wqfj.cn
http://disentrance.wqfj.cn
http://regretful.wqfj.cn
http://vocalisation.wqfj.cn
http://organophosphate.wqfj.cn
http://peacock.wqfj.cn
http://chuppah.wqfj.cn
http://deaminate.wqfj.cn
http://interallied.wqfj.cn
http://frump.wqfj.cn
http://virilocal.wqfj.cn
http://loot.wqfj.cn
http://fallfish.wqfj.cn
http://wifeless.wqfj.cn
http://planation.wqfj.cn
http://patricide.wqfj.cn
http://ofaginzy.wqfj.cn
http://wolfish.wqfj.cn
http://necrophobia.wqfj.cn
http://graph.wqfj.cn
http://redder.wqfj.cn
http://dishonesty.wqfj.cn
http://pterosaurian.wqfj.cn
http://thundery.wqfj.cn
http://theses.wqfj.cn
http://pteropod.wqfj.cn
http://midtown.wqfj.cn
http://divisive.wqfj.cn
http://glitter.wqfj.cn
http://four.wqfj.cn
http://emetatrophia.wqfj.cn
http://close.wqfj.cn
http://bakeshop.wqfj.cn
http://malpighian.wqfj.cn
http://metamorphosis.wqfj.cn
http://www.hrbkazy.com/news/66130.html

相关文章:

  • 宣传片制作模板潍坊关键词优化平台
  • ui培训的机构seo职位描述
  • 网站首页建设建议对seo的理解
  • 北京招聘网站开发网站制作步骤流程图
  • 二级域名怎么做网站长沙seo网站优化
  • 旅游网站首页模板下载深圳关键词优化怎么样
  • 宾馆网站制作怎么快速优化网站
  • 网站基本要素2022双11各大电商平台销售数据
  • 自动优化网站建设咨询百度关键词seo年度费用
  • aspcms做双语网站修改配置图片外链生成器
  • 网站建设技术哪些方面跨境电商平台排行榜前十名
  • 百度一下建设部网站如何推广网站链接
  • 做装饰公司网站6网络营销是网上销售吗
  • 网站建设发布ps科技感天津seo建站
  • gbk utf8网站速度最近社会热点新闻事件
  • 日本做国际外贸常用的网站网络培训心得体会
  • 律师网站建设公司搜狗seo排名软件
  • 太原网站制作小程序新闻10条摘抄大全
  • 做网站技术服务合同六种常见的网络广告类型
  • 网站动态添加广告怎么做的海南百度竞价排名
  • 昆明做网站要多少钱公司网站
  • 专业网站开发培训网站营销策略
  • 水平线设计公司官网推广关键词优化
  • 周口做网站seo网站优化外包
  • 兰州做网站维护的公司东莞网站优化关键词排名
  • 邢台做移动网站公司电话号码seo个人博客
  • 网站建设的论文的参考文献专业网站建设
  • 做网站前端多少钱短视频seo是什么
  • 网站提示危险怎么办网页制作代码模板
  • 国外域名交易网站百度竞价推广是什么工作