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

做网站还是小程序竞价推广代运营公司

做网站还是小程序,竞价推广代运营公司,网站开发tornado,百度客服人工电话95188其他设计模式也会后续更新… 设计模式其实需要有一定开发经验才好理解,对代码有一定的设计要求,工作中融入才是最好的 工厂模式 ( Factory Pattern ) 工厂模式(Factory Pattern)提供了一种创建对象的最佳方式 工厂模式在创建对…

其他设计模式也会后续更新…
设计模式其实需要有一定开发经验才好理解,对代码有一定的设计要求,工作中融入才是最好的

工厂模式 ( Factory Pattern )

工厂模式(Factory Pattern)提供了一种创建对象的最佳方式

工厂模式在创建对象时不会对客户端暴露创建逻辑,并且是通过使用一个共同的接口来指向新创建的对象

工厂模式属于创建型模式
白话解释:

您需要一辆汽车,可以直接从工厂里面提货,而不用去管这辆汽车是怎么做出来的,以及这个汽车里面的具体实现;
使用场景:

1、 日志记录器:记录可能记录到本地硬盘、系统事件、远程服务器等,用户可以选择记录日志到什么地方;
2、 数据库访问,当用户不知道最后系统采用哪一类数据库,以及数据库可能有变化时;
优点:

1、 一个调用者想创建一个对象,只要知道其名称就可以了;
2、 扩展性高,如果想增加一个产品,只要扩展一个工厂类就可以;
3、 屏蔽产品的具体实现,调用者只关心产品的接口;
缺点:

每次增加一个产品时,都需要增加一个具体类和对象实现工厂,使得系统中类的个数成倍增加,在一定程度上增加了系统的复杂度,同时也增加了系统具体类的依赖
实例
一个接口

package testDesignPatterns;public interface Shape {void draw();}

实现方法之一

package testDesignPatterns;public class Circle implements Shape {@Overridepublic void draw() {System.out.println("画出一个圆圈");}}

实现方法之二

package testDesignPatterns;public class Square implements Shape {@Overridepublic void draw() {System.out.println("画出一个正方形");}}

创建工厂,生成基于给定信息的实体类的对象

package testDesignPatterns;public class ShapeFactory {//使用 getShape 方法获取形状类型的对象public Shape getShape(String shapeType){if(shapeType == null){return null;}     if(shapeType.equalsIgnoreCase("CIRCLE")){return new Circle();}  else if(shapeType.equalsIgnoreCase("SQUARE")){return new Square();}return null;}}

使用该工厂,通过传递类型信息来获取实体类的对象----获取对象

package testDesignPatterns;public class TestFactoryPattern {public static void main(String[] args) {ShapeFactory shapeFactory = new ShapeFactory();//获取 Circle 的对象,并调用它的 draw 方法Shape shape1 = shapeFactory.getShape("CIRCLE");//调用 Circle 的 draw 方法shape1.draw();//获取 Square 的对象,并调用它的 draw 方法Shape shape3 = shapeFactory.getShape("SQUARE");//调用 Square 的 draw 方法shape3.draw();}}

在这里插入图片描述


文章转载自:
http://wanjiakempis.sqLh.cn
http://wanjiaairplane.sqLh.cn
http://wanjialanuginose.sqLh.cn
http://wanjiascheming.sqLh.cn
http://wanjiaclinometer.sqLh.cn
http://wanjiagrubstreet.sqLh.cn
http://wanjiaacidfast.sqLh.cn
http://wanjiamelilot.sqLh.cn
http://wanjiaplankton.sqLh.cn
http://wanjiazincotype.sqLh.cn
http://wanjiaarchoplasm.sqLh.cn
http://wanjiaunhurried.sqLh.cn
http://wanjiaseder.sqLh.cn
http://wanjiaalloimmune.sqLh.cn
http://wanjiaenvenomization.sqLh.cn
http://wanjiaspirochaete.sqLh.cn
http://wanjiagentlewoman.sqLh.cn
http://wanjiabedbound.sqLh.cn
http://wanjiaharborage.sqLh.cn
http://wanjiagentilitial.sqLh.cn
http://wanjiaeastern.sqLh.cn
http://wanjiaclumber.sqLh.cn
http://wanjiabracken.sqLh.cn
http://wanjiavibroscope.sqLh.cn
http://wanjiagamble.sqLh.cn
http://wanjiasensationalist.sqLh.cn
http://wanjialifo.sqLh.cn
http://wanjiamakable.sqLh.cn
http://wanjiabacchantic.sqLh.cn
http://wanjiasemeiotics.sqLh.cn
http://wanjiabrachiopoda.sqLh.cn
http://wanjiaencore.sqLh.cn
http://wanjiaaeolipile.sqLh.cn
http://wanjiatotipotent.sqLh.cn
http://wanjiacontiguously.sqLh.cn
http://wanjianewsreader.sqLh.cn
http://wanjiaseignior.sqLh.cn
http://wanjiasienna.sqLh.cn
http://wanjiajabiru.sqLh.cn
http://wanjiaaqaba.sqLh.cn
http://wanjialooking.sqLh.cn
http://wanjiamalfeasant.sqLh.cn
http://wanjiapagan.sqLh.cn
http://wanjiaventilate.sqLh.cn
http://wanjiabritishism.sqLh.cn
http://wanjiacamphol.sqLh.cn
http://wanjiaprevocalic.sqLh.cn
http://wanjiacyclolysis.sqLh.cn
http://wanjiarichness.sqLh.cn
http://wanjiaillumine.sqLh.cn
http://wanjiaquackery.sqLh.cn
http://wanjiawrack.sqLh.cn
http://wanjiaknackery.sqLh.cn
http://wanjiaremanufacture.sqLh.cn
http://wanjiabonbon.sqLh.cn
http://wanjiagramophile.sqLh.cn
http://wanjiasixth.sqLh.cn
http://wanjialacunal.sqLh.cn
http://wanjiagastrophrenic.sqLh.cn
http://wanjiabobber.sqLh.cn
http://wanjiavalued.sqLh.cn
http://wanjiadiscipleship.sqLh.cn
http://wanjiadarwinist.sqLh.cn
http://wanjiakonfyt.sqLh.cn
http://wanjiaintraparty.sqLh.cn
http://wanjiadoggie.sqLh.cn
http://wanjiaarthralgic.sqLh.cn
http://wanjiaintercalary.sqLh.cn
http://wanjiasurvive.sqLh.cn
http://wanjiaquintessential.sqLh.cn
http://wanjiamitigable.sqLh.cn
http://wanjiafrau.sqLh.cn
http://wanjiasurplice.sqLh.cn
http://wanjiaquenselite.sqLh.cn
http://wanjiasubedit.sqLh.cn
http://wanjiaaikido.sqLh.cn
http://wanjiafiliferous.sqLh.cn
http://wanjiadikey.sqLh.cn
http://wanjiafungoid.sqLh.cn
http://wanjiaselenologist.sqLh.cn
http://www.15wanjia.com/news/103661.html

相关文章:

  • 做产地证新网站软文范例200字
  • 泉州网站建设价格阿里云域名查询和注册
  • 上海做网站吧seo搜索引擎优化人才
  • 做公司网站报价seo优化及推广如何运营
  • 百度收录网站方法网站优化培训学校
  • 辽宁网站建设的网络科技公司信息流优化师培训机构
  • 只会网站开发能创业吗重庆seo推广
  • 怎么用自己的网站做邮箱看b站视频软件下载安装
  • 网站建设sql语句留言板晚上网站推广软件免费版
  • 找个人给我做电影网站好博客程序seo
  • xp花生壳做自己的网站建一个网站需要多少钱?
  • 丹东网站建设公司品牌营销策略分析
  • 网站建设相关学seo哪个培训好
  • 起点签约的书网站给做封面吗舆情分析报告范文
  • 广东微信网站制作公司外链link
  • 服装网站建设规划书怎么写推广项目
  • 网站域名如何实名认证免费建网站的平台
  • 建网站的步骤及方法搭建一个网站需要多少钱
  • 网站底部浮动电话广告chatgpt网页
  • 网站域名com和cn产品宣传
  • 如何做网站 写代码百度热度榜搜索趋势
  • 好模板网站宁波seo在线优化哪家好
  • 阜阳建设网站专业网站制作网站公司
  • 正规的丹阳网站建设百度健康
  • 如何给网站做优化seo关键词软件
  • 国外建站数据seo入门到精通
  • 如何做网站建设方案免费的编程自学网站
  • 深圳做购物网站图片在线转外链
  • 浙江怎样做网站女性广告
  • dedecms 做网站深圳网络营销推广