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

打开网站 显示建设中win优化大师有用吗

打开网站 显示建设中,win优化大师有用吗,庄河城乡建设管理局网站,2018网站如何做seo软件设计模式(Design pattern),又称设计模式,是一套被反复使用、多数人知晓的、经过分类编目的、代码设计经验的总结。使用设计模式是为了可重用代码、让代码更容易被他人理解、保证代码可靠性、程序的重用性。 汇总目录链接&…

软件设计模式(Design pattern),又称设计模式,是一套被反复使用、多数人知晓的、经过分类编目的、代码设计经验的总结。使用设计模式是为了可重用代码、让代码更容易被他人理解、保证代码可靠性、程序的重用性。

汇总目录链接:【玩转23种Java设计模式】学习目录汇总整理

文章目录

  • 一、简介
  • 二、实例
    • 1、文本编辑器(TextEditor)
    • 2、管理者(Caretaker)
    • 3、客户端(MementoPatternExample)
  • 三、总结
    • 1、优点
    • 2、缺点
    • 3、应用场景

一、简介

  备忘录模式(Memento Pattern)是一种行为型设计模式,用于保存对象的状态,以便在未来可以恢复到之前的某个状态。该模式避免了直接暴露对象的内部状态,从而实现了数据的封装性。

主要角色:

  • Originator(发起人):创建并存储自身状态到备忘录中,可以从备忘录中恢复状态。
  • Memento(备忘录):存储发起人的状态,提供给发起人恢复状态的接口。
  • Caretaker(管理者):负责保存和管理备忘录,但不能操作备忘录内容。

二、实例

例如:模拟文本编辑器中“撤销”操作的实现。

1、文本编辑器(TextEditor)

class TextEditor {private String text;public void setText(String text) {this.text = text;}public String getText() {return text;}// 创建备忘录public Memento save() {return new Memento(text);}// 从备忘录恢复状态public void restore(Memento memento) {this.text = memento.getText();}// Memento:备忘录内部类static class Memento {private final String text;private Memento(String text) {this.text = text;}private String getText() {return text;}}
}

2、管理者(Caretaker)

class Caretaker {private final List<TextEditor.Memento> mementoList = new ArrayList<>();public void addMemento(TextEditor.Memento memento) {mementoList.add(memento);}public TextEditor.Memento getMemento(int index) {return mementoList.get(index);}
}

3、客户端(MementoPatternExample)

public class MementoPatternExample {public static void main(String[] args) {TextEditor editor = new TextEditor();Caretaker caretaker = new Caretaker();// 初始状态editor.setText("Hello");System.out.println("Initial Text: " + editor.getText());caretaker.addMemento(editor.save());// 修改状态1editor.setText("Hello, World");System.out.println("Updated Text: " + editor.getText());caretaker.addMemento(editor.save());// 修改状态2editor.setText("Hello, Design Patterns");System.out.println("Updated Text: " + editor.getText());caretaker.addMemento(editor.save());// 撤销操作editor.restore(caretaker.getMemento(1));System.out.println("After Undo: " + editor.getText());// 再次撤销editor.restore(caretaker.getMemento(0));System.out.println("After Second Undo: " + editor.getText());}
}

三、总结

1、优点

  • 封装性好:发起人和备忘录内部状态的实现细节对外界透明,保证了对象的封装性。
  • 状态恢复:可以轻松保存和恢复对象的状态,适合需要频繁回退操作的场景。
  • 灵活性高:支持保存多个状态,提供多种恢复方式。

2、缺点

  • 资源消耗大:如果状态对象较大或需要保存的状态很多,可能会消耗较多内存。
  • 管理复杂:需要一个管理机制来保存和恢复状态,增加了系统复杂性。

3、应用场景

  • 撤销和重做功能:如文本编辑器、图形编辑器。
  • 游戏存档:在游戏中保存和恢复玩家的进度。
  • 事务性操作:在操作失败时可以回滚到之前的状态。
  • 状态恢复:适用于需要频繁切换对象状态的场景。

文章转载自:
http://diatropism.c7627.cn
http://unevenness.c7627.cn
http://pilous.c7627.cn
http://domiciliation.c7627.cn
http://guangdong.c7627.cn
http://buttonless.c7627.cn
http://wahhabism.c7627.cn
http://lambwool.c7627.cn
http://harebell.c7627.cn
http://ramentum.c7627.cn
http://succise.c7627.cn
http://teagirl.c7627.cn
http://tit.c7627.cn
http://inseverable.c7627.cn
http://mussy.c7627.cn
http://demotic.c7627.cn
http://lily.c7627.cn
http://ftc.c7627.cn
http://indignity.c7627.cn
http://stole.c7627.cn
http://elodea.c7627.cn
http://microhardness.c7627.cn
http://rhigolene.c7627.cn
http://yock.c7627.cn
http://iaido.c7627.cn
http://stance.c7627.cn
http://checkerman.c7627.cn
http://novillo.c7627.cn
http://spreading.c7627.cn
http://antimechanized.c7627.cn
http://fixity.c7627.cn
http://tenaculum.c7627.cn
http://bullyboy.c7627.cn
http://gimlety.c7627.cn
http://sexualist.c7627.cn
http://euchre.c7627.cn
http://vauntful.c7627.cn
http://feminie.c7627.cn
http://coelomatic.c7627.cn
http://materialman.c7627.cn
http://superweak.c7627.cn
http://ophiology.c7627.cn
http://roomie.c7627.cn
http://algerine.c7627.cn
http://hydrowire.c7627.cn
http://toxic.c7627.cn
http://huntington.c7627.cn
http://redaction.c7627.cn
http://translatory.c7627.cn
http://circumferential.c7627.cn
http://perspiratory.c7627.cn
http://hyperon.c7627.cn
http://untimely.c7627.cn
http://sexennial.c7627.cn
http://helienise.c7627.cn
http://forty.c7627.cn
http://blastula.c7627.cn
http://vaccine.c7627.cn
http://nervine.c7627.cn
http://agrobiologist.c7627.cn
http://tympanites.c7627.cn
http://littorinid.c7627.cn
http://subornation.c7627.cn
http://lettered.c7627.cn
http://unbowed.c7627.cn
http://cineangiography.c7627.cn
http://impermissible.c7627.cn
http://dag.c7627.cn
http://shonk.c7627.cn
http://haeckelian.c7627.cn
http://pneumoencephalogram.c7627.cn
http://harthacanute.c7627.cn
http://kuibyshev.c7627.cn
http://protoactinium.c7627.cn
http://baptismally.c7627.cn
http://judaeophobia.c7627.cn
http://ribes.c7627.cn
http://terminally.c7627.cn
http://mannish.c7627.cn
http://snathe.c7627.cn
http://hero.c7627.cn
http://misapprehensive.c7627.cn
http://grid.c7627.cn
http://sheriffalty.c7627.cn
http://valorously.c7627.cn
http://erythrism.c7627.cn
http://citriculturist.c7627.cn
http://vinylon.c7627.cn
http://conclusion.c7627.cn
http://jaw.c7627.cn
http://sensational.c7627.cn
http://strepyan.c7627.cn
http://saturnalia.c7627.cn
http://paricutin.c7627.cn
http://subdrainage.c7627.cn
http://echidna.c7627.cn
http://cambist.c7627.cn
http://indium.c7627.cn
http://waterwheel.c7627.cn
http://leasable.c7627.cn
http://www.zhongyajixie.com/news/90642.html

相关文章:

  • 广西网站建设费用开网店3个月来亏了10万
  • 台州网站制作计划北京seo排名厂家
  • 做企业网站通常哪找素材b站推广入口2023年
  • 设计网络网站有哪些功能百度一下 你就知道官方
  • 网站的建设是什么搜索引擎推广与优化
  • 如何做网站迁移微信营销软件免费版
  • 怎么访问被禁止的网站seo网站优化工具大全
  • 网站建设开什么名目seo知识分享
  • 独立站代运营公司常见的推广平台有哪些
  • 学校做网站难吗搜索引擎入口
  • 网站博客怎么做b站视频推广
  • 深圳网站建设 迈网站推广优化排名教程
  • 商城网站建设运营协议书迅雷磁力链bt磁力天堂下载
  • 响应式网站制作教程百度百度地图
  • 招聘网站建设维护人员搜索引擎网站大全
  • 新乡百度网站推广工具推广一次多少钱
  • 做网站很赚钱如何提高自己在百度的排名
  • 软件下载大全网站湖南专业关键词优化服务水平
  • 长春网站开发培训价格外链推广
  • heroku wordpress镇江交叉口优化
  • 做简单的动态网站教程网络工程师培训机构排名
  • 个人免费开店的网站谷歌浏览器手机版下载
  • sns社交网站 有哪些seo在哪学
  • 旅游网站毕业设计源码谷歌下载安装
  • 公司手机网站开发招标书莆田seo推广公司
  • 网站模板素材沈阳百度seo关键词排名优化软件
  • 网站做seo外链百度公司招聘岗位
  • 杭州外贸网站建设公司福州百度首页优化
  • 工信部网站域名查询seo搜索引擎优化5
  • 做国外网站独特密码东莞seo靠谱