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

单页产品网站源码带后台户外网站设计

单页产品网站源码带后台,户外网站设计,seo排名咨询,wordpress添加作者信息很好#xff01;你现在已经开始接触设计模式了#xff0c;而**抽象工厂模式#xff08;Abstract Factory Pattern#xff09;是一种常用于“创建一系列相关产品”**的经典设计模式。 我会一步步帮你理解#xff1a; #x1f9e0; 一句话解释 抽象工厂模式#xff1a;提…很好你现在已经开始接触设计模式了而**抽象工厂模式Abstract Factory Pattern是一种常用于“创建一系列相关产品”**的经典设计模式。 我会一步步帮你理解 一句话解释 抽象工厂模式提供一个接口用于创建一系列相关或相互依赖的对象而无需指定它们的具体类。 为什么需要它 当你面对以下场景时它就很有用 “我有多个产品按钮、窗口、菜单而且这些产品有不同的风格比如 Mac 风格、Windows 风格希望能在不改代码的前提下切换整套产品风格。” ✅ 举个生活类比 你要布置房间选一整套家具。你不能桌子 IKEA 风、椅子中式风格应该风格统一。 工厂1生产一整套「现代风」家具现代风沙发 现代风桌子工厂2生产一整套「中式风」家具中式风沙发 中式风桌子 → 你只选工厂不关心家具内部怎么造。 Python 完整代码示例 Step 1: 抽象产品类 from abc import ABC, abstractmethodclass Button(ABC):abstractmethoddef click(self):passclass Window(ABC):abstractmethoddef open(self):passStep 2: 具体产品类 class MacButton(Button):def click(self):print(Mac Button clicked!)class WinButton(Button):def click(self):print(Windows Button clicked!)class MacWindow(Window):def open(self):print(Mac Window opened!)class WinWindow(Window):def open(self):print(Windows Window opened!)️ Step 3: 抽象工厂类 class GUIFactory(ABC):abstractmethoddef create_button(self) - Button:passabstractmethoddef create_window(self) - Window:passStep 4: 具体工厂类 class MacFactory(GUIFactory):def create_button(self):return MacButton()def create_window(self):return MacWindow()class WinFactory(GUIFactory):def create_button(self):return WinButton()def create_window(self):return WinWindow()️ Step 5: 客户端代码 def render_ui(factory: GUIFactory):button factory.create_button()window factory.create_window()button.click()window.open()# 使用 Mac 风格 render_ui(MacFactory()) # 使用 Windows 风格 render_ui(WinFactory())流程图Mermaid #mermaid-svg-HdC442c8VtOVhELe {font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:#333;}#mermaid-svg-HdC442c8VtOVhELe .error-icon{fill:#552222;}#mermaid-svg-HdC442c8VtOVhELe .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-HdC442c8VtOVhELe .edge-thickness-normal{stroke-width:2px;}#mermaid-svg-HdC442c8VtOVhELe .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-HdC442c8VtOVhELe .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-HdC442c8VtOVhELe .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-HdC442c8VtOVhELe .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-HdC442c8VtOVhELe .marker{fill:#333333;stroke:#333333;}#mermaid-svg-HdC442c8VtOVhELe .marker.cross{stroke:#333333;}#mermaid-svg-HdC442c8VtOVhELe svg{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-HdC442c8VtOVhELe g.classGroup text{fill:#9370DB;fill:#131300;stroke:none;font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:10px;}#mermaid-svg-HdC442c8VtOVhELe g.classGroup text .title{font-weight:bolder;}#mermaid-svg-HdC442c8VtOVhELe .nodeLabel,#mermaid-svg-HdC442c8VtOVhELe .edgeLabel{color:#131300;}#mermaid-svg-HdC442c8VtOVhELe .edgeLabel .label rect{fill:#ECECFF;}#mermaid-svg-HdC442c8VtOVhELe .label text{fill:#131300;}#mermaid-svg-HdC442c8VtOVhELe .edgeLabel .label span{background:#ECECFF;}#mermaid-svg-HdC442c8VtOVhELe .classTitle{font-weight:bolder;}#mermaid-svg-HdC442c8VtOVhELe .node rect,#mermaid-svg-HdC442c8VtOVhELe .node circle,#mermaid-svg-HdC442c8VtOVhELe .node ellipse,#mermaid-svg-HdC442c8VtOVhELe .node polygon,#mermaid-svg-HdC442c8VtOVhELe .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-svg-HdC442c8VtOVhELe .divider{stroke:#9370DB;stroke:1;}#mermaid-svg-HdC442c8VtOVhELe g.clickable{cursor:pointer;}#mermaid-svg-HdC442c8VtOVhELe g.classGroup rect{fill:#ECECFF;stroke:#9370DB;}#mermaid-svg-HdC442c8VtOVhELe g.classGroup line{stroke:#9370DB;stroke-width:1;}#mermaid-svg-HdC442c8VtOVhELe .classLabel .box{stroke:none;stroke-width:0;fill:#ECECFF;opacity:0.5;}#mermaid-svg-HdC442c8VtOVhELe .classLabel .label{fill:#9370DB;font-size:10px;}#mermaid-svg-HdC442c8VtOVhELe .relation{stroke:#333333;stroke-width:1;fill:none;}#mermaid-svg-HdC442c8VtOVhELe .dashed-line{stroke-dasharray:3;}#mermaid-svg-HdC442c8VtOVhELe #compositionStart,#mermaid-svg-HdC442c8VtOVhELe .composition{fill:#333333!important;stroke:#333333!important;stroke-width:1;}#mermaid-svg-HdC442c8VtOVhELe #compositionEnd,#mermaid-svg-HdC442c8VtOVhELe .composition{fill:#333333!important;stroke:#333333!important;stroke-width:1;}#mermaid-svg-HdC442c8VtOVhELe #dependencyStart,#mermaid-svg-HdC442c8VtOVhELe .dependency{fill:#333333!important;stroke:#333333!important;stroke-width:1;}#mermaid-svg-HdC442c8VtOVhELe #dependencyStart,#mermaid-svg-HdC442c8VtOVhELe .dependency{fill:#333333!important;stroke:#333333!important;stroke-width:1;}#mermaid-svg-HdC442c8VtOVhELe #extensionStart,#mermaid-svg-HdC442c8VtOVhELe .extension{fill:#333333!important;stroke:#333333!important;stroke-width:1;}#mermaid-svg-HdC442c8VtOVhELe #extensionEnd,#mermaid-svg-HdC442c8VtOVhELe .extension{fill:#333333!important;stroke:#333333!important;stroke-width:1;}#mermaid-svg-HdC442c8VtOVhELe #aggregationStart,#mermaid-svg-HdC442c8VtOVhELe .aggregation{fill:#ECECFF!important;stroke:#333333!important;stroke-width:1;}#mermaid-svg-HdC442c8VtOVhELe #aggregationEnd,#mermaid-svg-HdC442c8VtOVhELe .aggregation{fill:#ECECFF!important;stroke:#333333!important;stroke-width:1;}#mermaid-svg-HdC442c8VtOVhELe .edgeTerminals{font-size:11px;}#mermaid-svg-HdC442c8VtOVhELe :root{--mermaid-font-family:"trebuchet ms",verdana,arial,sans-serif;} GUIFactory create_button() create_window() MacFactory create_button() create_window() WinFactory create_button() create_window() Button click() Window open() MacButton click() WinButton click() MacWindow open() WinWindow open() ✅ 优点 ✅ 保证产品族之间的一致性按钮 窗口风格一致✅ 封装创建逻辑符合开闭原则✅ 易于切换产品系列换工厂即可 ❌ 缺点 ❌ 类和接口数量增加每种产品都要写抽象 实现❌ 扩展“新产品”不方便比如新增菜单→ 要修改所有工厂 总结口诀 ✅ 抽象工厂负责生产“产品系列”只换工厂不动逻辑。适用于“同一风格的多组件系统”。 如果你希望我可以把这个例子替换成游戏皮肤工厂、汽车工厂、手机UI工厂来帮助你更贴近生活。你想试试哪个
http://www.pierceye.com/news/582015/

相关文章:

  • 领手工在家做的网站2019网页设计与实现论文
  • 兰州微信信息平台网站建设绍兴本地网站建设
  • 关于旅游网站策划书千锋前端培训多少钱
  • 温州网站建设结构做代练网站能备案
  • 零基础学习做网站第三方装修评估公司
  • 基础微网站开发动态网站彩票投注员做啥的
  • 西安做网站设计公司爱做网站免费版
  • 效果图网站接单重庆一般建一个网站需要多少钱
  • 网站建设征求意见稿辅料企业网站建设费用
  • 上海网站建设公司服务沅江网站制作
  • 公司网站开发费用计入什么科目虚拟主机怎么建网站
  • 天津网站建设技术网页设计与制作教程版徐洪亮课后答案
  • 旅游网站建设方案简介用asp做的网站打开页面很慢
  • 做影视网站 片源从哪里来做自媒体的上那些网站
  • 邢台网站开发百度云 做网站
  • 淘宝优惠劵网站建设wordpress主题 简洁
  • 自己做电影资源网站揭阳新闻最新消息
  • 北碚免费建站哪家做得好佛山网站建设设计
  • 怎么做网站拍卖的那种wordpress主题搜索图标
  • 三亚网站建设平台查数据的权威网站
  • html网站制作答辩ppt网站备份和备案的区别
  • 网站开发需要工具免费的ps软件
  • 常州网站建设优质商家重庆互联网怎么样
  • 做网站发广告动漫网页设计报告
  • 求职招聘网站建设投标书沈阳网站建设的公司哪家好
  • 做导航网站有发展吗南京企业网站制作哪家好
  • 千万pv网站开发成本招聘网站数建设
  • 吐鲁番大型网站建设平台找客户去哪个平台
  • 权威网站有哪些给个网站可以在线
  • 优化网站专题北京海淀网站建设公司