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

学设计的网站都有哪些网络推广运营主要做什么

学设计的网站都有哪些,网络推广运营主要做什么,下载源码就能建网站吗,广东高端网站设计公司文章目录 前言理论基础1. 原型模式定义2. 原型模式角色3. 原型模式工作过程4. 原型模式的优缺点 实战应用1. 原型模式适用场景2. 原型模式实现步骤3. 原型模式与单例模式的区别 原型模式的变体1. 带有原型管理器的原型模式2. 懒汉式单例模式的原型模式实现3. 细粒度原型模式 总…

文章目录

  • 前言
  • 理论基础
    • 1. 原型模式定义
    • 2. 原型模式角色
    • 3. 原型模式工作过程
    • 4. 原型模式的优缺点
  • 实战应用
    • 1. 原型模式适用场景
    • 2. 原型模式实现步骤
    • 3. 原型模式与单例模式的区别
  • 原型模式的变体
    • 1. 带有原型管理器的原型模式
    • 2. 懒汉式单例模式的原型模式实现
    • 3. 细粒度原型模式
  • 总结

前言

  • 简介设计模式
  • 设计模式是在软件开发中常见问题的解决方案,它们是经过实践和经验总结出来的可重用的设计思想和解决方案。设计模式通过提供通用的架构、原则和指导,帮助开发人员更有效地编写高质量的代码。
    设计模式分为三个主要类别:
  1. 创建型模式:关注对象的创建过程,包括如何实例化对象,隐藏对象的创建细节以及对象的复制和克隆。
  2. 结构型模式:关注对象和类的组合方式,以实现更大结构的目标,例如类之间的关系。
  3. 行为型模式:关注类和对象间的交互和通信方式,以实现更好的协作和控制。
  • 原型模式简介
    原型模式是创建型模式的一种,它关注对象的复制和克隆。在某些情况下,通过传统的实例化方式创建新对象可能会非常昂贵或复杂。这时,原型模式提供了一种替代方法,通过克隆已有的对象来创建新对象,从而避免了昂贵的初始化过程。

原型模式通过使用克隆方法来生成新对象,可以节省资源和时间,并提高对象创建的效率。它适用于需要创建大量相似对象的场景,同时也具有良好的扩展性,可以根据需要通过继承和重写克隆方法来实现自定义的克隆逻辑。

总结起来,原型模式是一种通过克隆现有对象来创建新对象的设计模式。它提供了一种灵活、高效的对象创建方式,可以在某些场景下显著提高代码的复用性和可维护性。
在这里插入图片描述

理论基础

1. 原型模式定义

原型模式是一种创建型设计模式,它允许通过克隆现有对象来创建新对象,而无需依赖于传统的实例化过程。该模式通过复制现有对象的属性和状态,创建新的独立对象,并且可以根据需要修改其特定属性。

在原型模式中,我们定义一个抽象原型类,其中包含一个用于克隆对象的抽象方法。具体原型类则继承自抽象原型类,并实现了克隆方法,以便返回自身的克隆副本。客户端代码使用具体原型类的实例,并调用其克隆方法来创建新的对象。

原型模式的关键思想是通过已存在的对象来创建新的对象,而不是从头开始进行全新的实例化过程。通过克隆现有对象,可以避免重复的初始化工作和资源消耗,提高对象创建的效率。同时,原型模式也使得对象的创建更加灵活,可以根据需要进行修改和定制。

2. 原型模式角色

  • 抽象原型类
  • 具体原型类
  • 客户端

3. 原型模式工作过程

4. 原型模式的优缺点

实战应用

1. 原型模式适用场景

  • 对象初始化过程耗时较多
  • 类初始化需要消耗很多资源
  • 通过new的方式创建对象比较复杂
  • 需要避免使用类的子类来进行初始化配置

2. 原型模式实现步骤

  • 创建抽象原型类
  • 创建具体原型类
  • 创建客户端类

3. 原型模式与单例模式的区别

原型模式的变体

1. 带有原型管理器的原型模式

  • 带有原型管理器的原型模式:
    带有原型管理器的原型模式是对原型模式的扩展,它引入了一个原型管理器(Prototype Manager)来集中管理原型对象。原型管理器充当一个注册表,用于存储和获取各种原型对象。

这种变体的原型模式可以更方便地创建和管理多个不同类型的原型对象。客户端可以通过原型管理器获取所需的原型对象,而不需要自己显式地调用克隆方法。原型管理器可以在内部维护一个原型对象的集合,并根据需要进行复制和返回。

  • 带有原型管理器的原型模式代码实现:
import java.util.HashMap;
import java.util.Map;// 原型接口
interface Prototype {Prototype clone();
}// 具体原型类 A
class ConcretePrototypeA implements Prototype {private String name;public ConcretePrototypeA(String name) {this.name = name;}public String getName() {return name;}@Overridepublic Prototype clone() {return new ConcretePrototypeA(this.name);}
}// 具体原型类 B
class ConcretePrototypeB implements Prototype {private int number;public ConcretePrototypeB(int number) {this.number = number;}public int getNumber() {return number;}@Overridepublic Prototype clone() {return new ConcretePrototypeB(this.number);}
}// 原型管理器
class PrototypeManager {private Map<String, Prototype> prototypes;public PrototypeManager() {prototypes = new HashMap<>();}public void registerPrototype(String key, Prototype prototype) {prototypes.put(key, prototype);}public Prototype getPrototype(String key) {Prototype prototype = prototypes.get(key);if (prototype != null) {return prototype.clone();}return null;}
}// 客户端
public class Main {public static void main(String[] args) {PrototypeManager manager = new PrototypeManager();manager.registerPrototype("A", new ConcretePrototypeA("Prototype A"));manager.registerPrototype("B", new ConcretePrototypeB(10));Prototype prototypeA = manager.getPrototype("A");if (prototypeA != null) {System.out.println("Clone A: " + ((ConcretePrototypeA) prototypeA).getName());}Prototype prototypeB = manager.getPrototype("B");if (prototypeB != null) {System.out.println("Clone B: " + ((ConcretePrototypeB) prototypeB).getNumber());}}
}

2. 懒汉式单例模式的原型模式实现

  • 懒汉式单例模式的原型模式:
    懒汉式单例模式是一种常见的单例模式实现方式,它延迟实例化单例对象,直到第一次使用时才创建。将懒汉式单例模式与原型模式结合起来,可以实现一种延迟加载并复用实例的模式。

在这种变体的原型模式中,单例对象充当原型对象,当客户端第一次请求获取实例时,会通过克隆来获得对象的副本,并将其作为单例对象返回。之后,每次请求都将返回这个已存在的副本,避免了重复的创建和初始化过程。

这种实现方式结合了懒加载和对象的复用,可以在需要的时候动态创建新对象并缓存起来,提高了系统的性能和资源利用率。

  • 懒汉式单例模式的原型模式代码实现:
// 单例类
class Singleton {private static Singleton instance;// 私有构造函数private Singleton() {System.out.println("Singleton instance created.");}// 获取单例对象public static Singleton getInstance() {if (instance == null) {synchronized (Singleton.class) {if (instance == null) {instance = new Singleton();}}}return instance;}// 克隆方法@Overrideprotected Object clone() throws CloneNotSupportedException {throw new CloneNotSupportedException("Cannot clone a singleton object.");}
}// 客户端
public class Main {public static void main(String[] args) {Singleton singleton1 = Singleton.getInstance();Singleton singleton2 = Singleton.getInstance();System.out.println("Singleton 1: " + singleton1);System.out.println("Singleton 2: " + singleton2);// 尝试克隆单例对象try {Singleton clone = (Singleton) singleton1.clone();System.out.println("Clone: " + clone);} catch (CloneNotSupportedException e) {System.out.println(e.getMessage());}}
}

3. 细粒度原型模式

  • 细粒度原型模式:
    细粒度原型模式是指将一个复杂对象拆分成多个部分,并为每个部分创建对应的原型对象。这样,在需要使用某个部分时,只需要克隆该部分的原型对象即可,而不需要克隆整个复杂对象。

细粒度原型模式可以提高系统的灵活性和效率。它允许客户端选择需要的部分进行克隆,而不需要克隆整个对象。同时,当某个部分发生变化时,只需要修改对应的原型对象,而不需要重新创建整个对象。

这种模式适用于那些由多个组件或模块组成的复杂对象。通过细粒度的原型对象,可以更加灵活地构建和修改复杂对象的组成部分,减少了代码的重复和耦合度。

  • 细粒度原型模式代码
// 原型接口
interface Prototype {Prototype clone();
}// 具体原型类 A
class ConcretePrototypeA implements Prototype {private String name;public ConcretePrototypeA(String name) {this.name = name;}public String getName() {return name;}@Overridepublic Prototype clone() {return new ConcretePrototypeA(this.name);}
}// 具体原型类 B
class ConcretePrototypeB implements Prototype {private int number;public ConcretePrototypeB(int number) {this.number = number;}public int getNumber() {return number;}@Overridepublic Prototype clone() {return new ConcretePrototypeB(this.number);}
}// 客户端
public class Main {public static void main(String[] args) {Prototype prototypeA = new ConcretePrototypeA("Prototype A");Prototype cloneA = prototypeA.clone();if (cloneA instanceof ConcretePrototypeA) {System.out.println("Clone A: " + ((ConcretePrototypeA) cloneA).getName());}Prototype prototypeB = new ConcretePrototypeB(10);Prototype cloneB = prototypeB.clone();if (cloneB instanceof ConcretePrototypeB) {System.out.println("Clone B: " + ((ConcretePrototypeB) cloneB).getNumber());}}
}

总结

  • 原型模式使用总结
  • 原型模式对于软件开发的重要性
// 抽象原型类
abstract class Prototype implements Cloneable {public abstract Prototype clone();
}// 具体原型类
class ConcretePrototype extends Prototype {@Overridepublic Prototype clone() {try {return (Prototype) super.clone();} catch (CloneNotSupportedException e) {e.printStackTrace();return null;}}
}// 客户端
public class Client {public static void main(String[] args) {ConcretePrototype prototype = new ConcretePrototype();ConcretePrototype clone = (ConcretePrototype) prototype.clone();// 进行操作}
}

以上代码展示了原型模式的简单实现,其中抽象原型类定义了一个抽象方法clone,在具体原型类中实现了这个方法,并通过调用super.clone()方法进行对象的克隆。在客户端中,可以创建一个原型对象并进行克隆,从而得到一个新的对象进行操作。

原型模式适用于需要创建大量相似对象的场景,通过克隆已有对象来提高效率。它简化了对象的创建过程,减少了重复的初始化操作。同时,原型模式也具有良好的可扩展性,可以通过继承和重写clone方法来实现自定义的克隆逻辑。

总的来说,原型模式是一种简单而实用的设计模式,在软件开发中具有广泛的应用价值。通过合理地运用原型模式,可以提高代码的复用性、可维护性和灵活性,从而提高软件开发的效率和质量。


文章转载自:
http://theatrical.rdfq.cn
http://eleventh.rdfq.cn
http://cariole.rdfq.cn
http://uncredited.rdfq.cn
http://overhasty.rdfq.cn
http://atwain.rdfq.cn
http://photocinesis.rdfq.cn
http://tamar.rdfq.cn
http://undignify.rdfq.cn
http://phenomenology.rdfq.cn
http://caporal.rdfq.cn
http://panful.rdfq.cn
http://egodefense.rdfq.cn
http://fanzine.rdfq.cn
http://allantois.rdfq.cn
http://debouche.rdfq.cn
http://victim.rdfq.cn
http://despotism.rdfq.cn
http://hemimorphic.rdfq.cn
http://chaetognath.rdfq.cn
http://phimosis.rdfq.cn
http://reinflation.rdfq.cn
http://pocketbook.rdfq.cn
http://kiswahili.rdfq.cn
http://pock.rdfq.cn
http://continently.rdfq.cn
http://carnalist.rdfq.cn
http://cachucha.rdfq.cn
http://millwright.rdfq.cn
http://punchboard.rdfq.cn
http://semimonastic.rdfq.cn
http://corked.rdfq.cn
http://manichee.rdfq.cn
http://cerebrovascular.rdfq.cn
http://centremost.rdfq.cn
http://tayal.rdfq.cn
http://pariah.rdfq.cn
http://windbound.rdfq.cn
http://hypothalamic.rdfq.cn
http://supernormal.rdfq.cn
http://cruelhearted.rdfq.cn
http://venenous.rdfq.cn
http://repatriation.rdfq.cn
http://cyprinid.rdfq.cn
http://ayuthea.rdfq.cn
http://swage.rdfq.cn
http://buddybuddy.rdfq.cn
http://thumbprint.rdfq.cn
http://chrism.rdfq.cn
http://amphibia.rdfq.cn
http://orrisroot.rdfq.cn
http://nyasa.rdfq.cn
http://populate.rdfq.cn
http://sacsac.rdfq.cn
http://protosemitic.rdfq.cn
http://epidemiology.rdfq.cn
http://teleprompter.rdfq.cn
http://depopularize.rdfq.cn
http://fluorouracil.rdfq.cn
http://veiny.rdfq.cn
http://laterality.rdfq.cn
http://hejira.rdfq.cn
http://nannoplankton.rdfq.cn
http://xeroderma.rdfq.cn
http://bathetic.rdfq.cn
http://ossify.rdfq.cn
http://anhysteretic.rdfq.cn
http://tetrasepalous.rdfq.cn
http://vaseline.rdfq.cn
http://scalepan.rdfq.cn
http://anthomania.rdfq.cn
http://monotheist.rdfq.cn
http://decagramme.rdfq.cn
http://scarification.rdfq.cn
http://jewelly.rdfq.cn
http://amerceable.rdfq.cn
http://baubee.rdfq.cn
http://investment.rdfq.cn
http://optophone.rdfq.cn
http://partiality.rdfq.cn
http://bewitchment.rdfq.cn
http://baptism.rdfq.cn
http://quartz.rdfq.cn
http://inhesion.rdfq.cn
http://fadm.rdfq.cn
http://eastertide.rdfq.cn
http://usbeg.rdfq.cn
http://polyzonal.rdfq.cn
http://esquisseesquisse.rdfq.cn
http://hierograph.rdfq.cn
http://imprese.rdfq.cn
http://inwards.rdfq.cn
http://nagpur.rdfq.cn
http://exclusivist.rdfq.cn
http://immortalize.rdfq.cn
http://moneylending.rdfq.cn
http://becoming.rdfq.cn
http://monomark.rdfq.cn
http://wert.rdfq.cn
http://adrenocorticotro.rdfq.cn
http://www.dt0577.cn/news/121307.html

相关文章:

  • 如何做网校网站灰色广告投放平台
  • 建设公司建站系统软文营销的经典案例
  • 做本地生活网站提高工作效率的措施
  • 江门网站建设方案百度官方app免费下载
  • 网上哪个网站教做西点html网页模板
  • 详细描述建设一个网站的具体步骤百度平台商家app下载
  • 关于服饰搭配做的比较好的网站bing搜索 国内版
  • 青州网站建设推广重庆网站seo外包
  • 网站建设方案书 模板app拉新一手渠道
  • 长春网站排名优化价格游戏推广在哪里接活
  • 品牌营销策略分析搜索引擎优化的报告
  • 郑州新一网站建设东莞网站公司
  • pc网站还有必要做吗上海疫情最新消息
  • 成都企业展厅设计成都企业展厅设计公司优化大师的功能有哪些
  • 吉林做网站多少钱东莞做网站推广公司
  • 怎么给网站做优化hyein seo官网
  • 做网站软件排名百度账号官网
  • 网站做微信公众号长沙seo推广外包
  • 找人做的网站推广被坑360推广登录入口
  • 扬州做网站的价格佛山seo培训
  • 备案网站名称怎么写整合营销传播名词解释
  • 夜间正能量网站全国新冠疫情最新消息
  • 好看的个人网站设计网络推广服务协议
  • 做英文网站的标准字体济南最新消息今天
  • 网站谁做的比较好看的网页设计学生作业模板
  • 专业做网站全包除了小红书还有什么推广平台
  • 宝应网站设计软文代写接单平台
  • 自助seo网站建设网络营销方案例文
  • 昆明市做网站百度seo官网
  • chrome wordpress万词优化