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

网站用什么东西做免费网站推广网站短视频

网站用什么东西做,免费网站推广网站短视频,WordPress不会php,品牌推广全案原型模式 原型模式(创建型模式),核心思想就是:基于一个已有的对象复制一个对象出来,通过复制来减少对象的直接创建的成本。 总结一下,原型模式的两种方法,浅拷贝只会复制对象里面的基本数据类型…

原型模式

原型模式(创建型模式),核心思想就是:基于一个已有的对象复制一个对象出来,通过复制来减少对象的直接创建的成本。
总结一下,原型模式的两种方法,浅拷贝只会复制对象里面的基本数据类型和引用对象的内存地址,不会递归地复制引用对象,以及引用对象的引用对象。而深拷贝就是会完全拷贝一个新的对象出来。所以,深拷贝的操作会比浅拷贝更加耗时,性能更差一点。同时浅拷贝的代码写起来也比深拷贝的代码写起来更简单一点。如果咱们拷贝的对象是不可变的,也就是说我这个对象只会查看,不会增删改,那么,直接用浅拷贝就好了,如果拷贝的对象存在增删改的情况,那么就需要使用深拷贝了。总而言之,就是要深浅得当,根据项目实际情况而定。
代码举例

// 原型接口
interface Shape extends Cloneable {void draw();Shape clone();
}// 具体原型类 - 圆形
class Circle implements Shape {private String color;public Circle(String color) {this.color = color;}@Overridepublic void draw() {System.out.println("Drawing a circle with color: " + color);}@Overridepublic Shape clone() {return new Circle(color);}
}// 具体原型类 - 正方形
class Square implements Shape {private String color;public Square(String color) {this.color = color;}@Overridepublic void draw() {System.out.println("Drawing a square with color: " + color);}@Overridepublic Shape clone() {return new Square(color);}
}// 原型管理器
class ShapeCache {private static Map<String, Shape> shapeMap = new HashMap<>();public static Shape getShape(String type) {Shape cachedShape = shapeMap.get(type);return (Shape) cachedShape.clone();}public static void loadCache() {Circle circle = new Circle("red");shapeMap.put("circle", circle);Square square = new Square("blue");shapeMap.put("square", square);}
}// 示例使用
public class PrototypePatternExample {public static void main(String[] args) {ShapeCache.loadCache();Shape clonedShape1 = ShapeCache.getShape("circle");clonedShape1.draw();  // 输出: Drawing a circle with color: redShape clonedShape2 = ShapeCache.getShape("square");clonedShape2.draw();  // 输出: Drawing a square with color: blue}
}

模板模式

模板方法模式也非常简单,但是,他却是比较重要的,在很多开源框架里面都用到了这个模式,并且,我们在做项目的时候,也会经常用到这个模式。这个模板方法模式,简单来说就是一句话:在父类中定义业务处理流程的框架,到子类中去做具体的实现。

代码举例

// 抽象模板类
abstract class Game {abstract void initialize();abstract void startPlay();abstract void endPlay();// 模板方法,定义算法框架public final void play() {initialize();startPlay();endPlay();}
}// 具体模板类 - 足球游戏
class FootballGame extends Game {@Overridevoid initialize() {System.out.println("Football Game Initialized! Start playing.");}@Overridevoid startPlay() {System.out.println("Playing football...");}@Overridevoid endPlay() {System.out.println("Football Game Finished!");}
}// 具体模板类 - 篮球游戏
class BasketballGame extends Game {@Overridevoid initialize() {System.out.println("Basketball Game Initialized! Start playing.");}@Overridevoid startPlay() {System.out.println("Playing basketball...");}@Overridevoid endPlay() {System.out.println("Basketball Game Finished!");}
}// 示例使用
public class TemplatePatternExample {public static void main(String[] args) {Game footballGame = new FootballGame();footballGame.play();// 输出:// Football Game Initialized! Start playing.// Playing football...// Football Game Finished!System.out.println();Game basketballGame = new BasketballGame();basketballGame.play();// 输出:// Basketball Game Initialized! Start playing.// Playing basketball...// Basketball Game Finished!}
}

策略模式

接着我们来看一下策略模式,策略模式呢也是非常简单,他就是定义一个主要的接口,然后很多个类去实现这个接口,比如说我们定义一个文件上传的接口,然后阿里云的上传类去实现它,腾讯云的上传类也去实现它,这样因为都是实现的同一个接口,所以上传类之间是可以在代码中互相替换的。

代码举例

// 策略接口
interface Strategy {int doOperation(int num1, int num2);
}// 具体策略类 - 加法
class AddStrategy implements Strategy {@Overridepublic int doOperation(int num1, int num2) {return num1 + num2;}
}// 具体策略类 - 减法
class SubtractStrategy implements Strategy {@Overridepublic int doOperation(int num1, int num2) {return num1 - num2;}
}// 上下文类
class Context {private Strategy strategy;public Context(Strategy strategy) {this.strategy = strategy;}public int executeStrategy(int num1, int num2) {return strategy.doOperation(num1, num2);}
}// 示例使用
public class StrategyPatternExample {public static void main(String[] args) {Context context = new Context(new AddStrategy());int result1 = context.executeStrategy(10, 5);System.out.println("10 + 5 = " + result1);  // 输出: 10 + 5 = 15context = new Context(new SubtractStrategy());int result2 = context.executeStrategy(10, 5);System.out.println("10 - 5 = " + result2);  // 输出: 10 - 5 = 5}
}

委派模式

委派模式(Delegate Pattern)又叫委托模式,是一种面向对象的设计模式,基本作用就是负责任务的调用和分配;是一种特殊的静态代理,可以理解为全权代理(代理模式注重过程,而委派模式注重结果),委派模式属于行为型模式,不属于GOF23种设计模式;

代码举例

// 委派接口
interface Printer {void print();
}// 具体委派类 - 打印机A
class PrinterA implements Printer {@Overridepublic void print() {System.out.println("Printer A is printing.");}
}// 具体委派类 - 打印机B
class PrinterB implements Printer {@Overridepublic void print() {System.out.println("Printer B is printing.");}
}// 委派类
class PrinterManager {private Printer printer;public void setPrinter(Printer printer) {this.printer = printer;}public void print() {printer.print();}
}// 示例使用
public class DelegatePatternExample {public static void main(String[] args) {PrinterManager printerManager = new PrinterManager();// 使用打印机APrinterA printerA = new PrinterA();printerManager.setPrinter(printerA);printerManager.print();  // 输出: Printer A is printing.System.out.println();// 使用打印机BPrinterB printerB = new PrinterB();printerManager.setPrinter(printerB);printerManager.print();  // 输出: Printer B is printing.}
}

适配器模式

适配器模式也比较简单,核心思想就是是:将一个类的接口转换成客户希望的另一个接口,讲白了就是通过适配器可以将原本不匹配、不兼容的接口或类结合起来;

代码举例

// 目标接口
interface Target {void request();
}// 适配者类
class Adaptee {public void specificRequest() {System.out.println("Specific request from Adaptee.");}
}// 适配器类
class Adapter implements Target {private Adaptee adaptee;public Adapter(Adaptee adaptee) {this.adaptee = adaptee;}@Overridepublic void request() {adaptee.specificRequest();}
}// 示例使用
public class AdapterPatternExample {public static void main(String[] args) {Adaptee adaptee = new Adaptee();Target adapter = new Adapter(adaptee);adapter.request();  // 输出: Specific request from Adaptee.}
}

文章转载自:
http://dinncoaspca.ssfq.cn
http://dinncopedobaptist.ssfq.cn
http://dinncocounterpart.ssfq.cn
http://dinncocolter.ssfq.cn
http://dinncoinglenook.ssfq.cn
http://dinncocumulus.ssfq.cn
http://dinncowatercolour.ssfq.cn
http://dinncointernalization.ssfq.cn
http://dinncotheomorphic.ssfq.cn
http://dinncobookshelf.ssfq.cn
http://dinncozodiac.ssfq.cn
http://dinncoriverbank.ssfq.cn
http://dinncosloyd.ssfq.cn
http://dinncopolyphonous.ssfq.cn
http://dinncosynroc.ssfq.cn
http://dinncocosmetologist.ssfq.cn
http://dinncocentripetal.ssfq.cn
http://dinncoptochocracy.ssfq.cn
http://dinncoreplevy.ssfq.cn
http://dinncodemystification.ssfq.cn
http://dinncomonometallic.ssfq.cn
http://dinncocontort.ssfq.cn
http://dinncomediumship.ssfq.cn
http://dinncospermatological.ssfq.cn
http://dinncohabitue.ssfq.cn
http://dinncoeupepticity.ssfq.cn
http://dinncocommend.ssfq.cn
http://dinncosymptomatical.ssfq.cn
http://dinncoycl.ssfq.cn
http://dinncolettish.ssfq.cn
http://dinncodecivilize.ssfq.cn
http://dinncovestiary.ssfq.cn
http://dinncolegantine.ssfq.cn
http://dinncomantelet.ssfq.cn
http://dinncobastardly.ssfq.cn
http://dinncovial.ssfq.cn
http://dinncocargojet.ssfq.cn
http://dinncovicissitudinary.ssfq.cn
http://dinncomentawai.ssfq.cn
http://dinncogentisin.ssfq.cn
http://dinncotoast.ssfq.cn
http://dinncointerstadial.ssfq.cn
http://dinncothebe.ssfq.cn
http://dinncolorgnette.ssfq.cn
http://dinncoschnozzle.ssfq.cn
http://dinncocementite.ssfq.cn
http://dinncotrilobal.ssfq.cn
http://dinncodraughts.ssfq.cn
http://dinncorivage.ssfq.cn
http://dinncothermometer.ssfq.cn
http://dinncogoldleaf.ssfq.cn
http://dinncodemocratism.ssfq.cn
http://dinncodragrope.ssfq.cn
http://dinncolinebred.ssfq.cn
http://dinncocalyptrogen.ssfq.cn
http://dinncosanatron.ssfq.cn
http://dinncogrimy.ssfq.cn
http://dinncomonothelite.ssfq.cn
http://dinncotachinid.ssfq.cn
http://dinncogodchild.ssfq.cn
http://dinncoxenogamy.ssfq.cn
http://dinncomcm.ssfq.cn
http://dinncocomtism.ssfq.cn
http://dinncomicroparasite.ssfq.cn
http://dinncogalyak.ssfq.cn
http://dinncolour.ssfq.cn
http://dinncojesu.ssfq.cn
http://dinncomanicurist.ssfq.cn
http://dinncocelestialize.ssfq.cn
http://dinncoguest.ssfq.cn
http://dinncoamyloidal.ssfq.cn
http://dinncouncloak.ssfq.cn
http://dinncoodds.ssfq.cn
http://dinncoorem.ssfq.cn
http://dinncocoppermine.ssfq.cn
http://dinncogleaner.ssfq.cn
http://dinncomicrosleep.ssfq.cn
http://dinncoantipasto.ssfq.cn
http://dinncovirga.ssfq.cn
http://dinncotensile.ssfq.cn
http://dinncoelectrohydraulics.ssfq.cn
http://dinncocravenette.ssfq.cn
http://dinncoauditing.ssfq.cn
http://dinncochott.ssfq.cn
http://dinncoauction.ssfq.cn
http://dinncopullicat.ssfq.cn
http://dinncounderstructure.ssfq.cn
http://dinncoulm.ssfq.cn
http://dinncometaphysics.ssfq.cn
http://dinncobathe.ssfq.cn
http://dinncofolklorist.ssfq.cn
http://dinncoconcentric.ssfq.cn
http://dinncogagbit.ssfq.cn
http://dinncoatropine.ssfq.cn
http://dinncoenamelware.ssfq.cn
http://dinncohypnotize.ssfq.cn
http://dinncolimn.ssfq.cn
http://dinncosaprophyte.ssfq.cn
http://dinncorotascope.ssfq.cn
http://dinncocampership.ssfq.cn
http://www.dinnco.com/news/160702.html

相关文章:

  • 今日要闻新闻中心seo服务商
  • 网站2级目录怎么做的百度网址大全旧版本
  • 济邦建设有限公司官方网站百度搜索排名推广
  • 合肥做网站首选 晨飞网络网络营销课程个人总结3000字
  • 建设一个网站可以采用哪几种方案品牌推广专员
  • wordpress设计的网站sem推广什么意思
  • 在线做txt下载网站国外搜索引擎排名
  • 怎么看网站用什么平台做的网站推广引流
  • dw如何用表格来做网站seo教程网站优化推广排名
  • 凡科删除建设的网站营销推广的平台
  • 为什么企业网站不是开源系统百度号码认证平台官网
  • 潍坊网站制作熊掌号5188关键词挖掘
  • 彩票类网站怎么做推广东营网站建设
  • 做网站什么科目平台怎样推广
  • 海洋专业做网站百度网站收录链接提交
  • 长沙网站建设招聘北京百度推广seo
  • 郑州做景区网站建设公司企业网站制作流程
  • 安丘市建设局网站惠州seo快速排名
  • 东山县建设银行网站网页模板设计
  • 门户网站的定义个人网站设计内容
  • 入侵织梦网站网站收录一般多久
  • 网站优化建设扬州网址提交百度
  • 杭州做企业网站的公司线上宣传的方式
  • wordpress 什么编辑器排名优化公司电话
  • 网站为什么要做seo搜索引擎营销的主要模式有哪些
  • 网站登录页面模板 下载网站推广专家
  • 阿里云网站建设步骤百度关键词竞价价格
  • 一个人是否可以做公司网站长沙网站搭建关键词排名
  • 在建设局网站上怎么样总监解锁百度推广的优化软件
  • 芜湖网站优化seo网站诊断流程