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

整个网站的关键词昆明seo关键字推广

整个网站的关键词,昆明seo关键字推广,企业型商务网站制作做法,做响应式网站有什么插件设计模式最大的作用就是在变化和稳定中间寻找隔离点,然后分离它们,从而管理变化。将变化像小兔子一样关到笼子里,让它在笼子里随便跳,而不至于跳出来把你整个房间给污染掉。 设计思想 将行为想象为一族算法,定义算法族…

设计模式最大的作用就是在变化和稳定中间寻找隔离点,然后分离它们,从而管理变化。将变化像小兔子一样关到笼子里,让它在笼子里随便跳,而不至于跳出来把你整个房间给污染掉。

设计思想

将行为想象为一族算法,定义算法族,分别封装起来,让他们之间可以互相替换,使得算法的变化独立于使用算法的客户。

业务场景

假定现在让你设计一个鸭子类,模仿这个世界上所有的鸭子,你会怎么做?

你可能会说使用继承,先定义一个Duck父类,然后写一些函数:display表现鸭子的模样,fly表现鸭子的飞行动作,quack表现鸭子的叫声…然后再写一些类去继承这个父类,一个一个重写父类的函数,模仿每种鸭子不同的长相,飞行行为和叫声。

如果你是一个初学者,你能想出这些并不奇怪,问题也确确实实解决了,但却并不是最佳方法。这种设计会造成大量的函数重复:比如世界上现在有10种鸭子,有4种鸭子的模样一模一样,另外3种一模一样,剩下的一模一样,而你却要一个一个去重复写display函数;这种设计也并不利于未来的业务发展:比如现在你用继承完成了所有的鸭子设计,某一天,科学家又宣布新发现10种鸭子,而你还是要继续改动你的代码,不断的重写,不断的继承。很快,你就会发现,继承并不是一个好办法。

刚开始出现继承这种机制的时候,很多程序员便很喜欢用这种方法解决问题。因为这很符合我们以往的认知习惯:某某人的儿子可以使用父亲手中的资源,这种使用似乎“理所应当”,很顺其自然的一件事。但是,写代码的时候你就会发现继承能做的事情,往往组合也能实现,并且有时候会比用继承更好。

我们写程序的一个目标叫软件复用,如果你的代码里出现很多一模一样的函数,显然并不是一份很好的设计。而正如世界一样,我们的代码也需要与时俱进,否则就会死亡。一份程序在刚写好的时候仅仅是开始,后期花在维护,改进,更新上的时间要远远多于刚开始开发的时间,这些就是所谓的“change”,正是这些变化才造成了你不断的加班,正如前面让你设计鸭子类一样,某天新发现10种鸭子,而你为了完成设计,可能就要被迫加班。

那么应该采取什么样的设计才能有效的抵御变化,少加班呢?

我们有一个设计原则叫做:找出应用中可能需要变化之处,把他们独立出来,不要和稳定的代码混在一起。

换句话说,如果每次新的需求依赖,都会使某些方面的代码发生变化,那么你就可以确定,这部分的代码需要被抽离,和其他稳定的代码有所区分。也就是说把会变化的部分取出并封装起来,以便以后可以轻易地改动以扩充此部分而不影响其它部分。

这个概念很简单,几乎是每个设计模式背后的精神所在。所有的设计模式都提供了一套方法让“系统中的某部分改变不会影响其它部分”。

策略模式代码案例

封装飞行行为;

class FlyBehavior
{
public:virtual void fly() = 0;
};class FlyWithWings : public FlyBehavior
{
public:void fly(){cout << "Fly with Wings..." << endl;}
};class FlyNoway : public FlyBehavior
{
public:void fly(){cout << "i can not fly..." << endl;}
};class FlyWithRockets : public FlyBehavior
{
public:void fly(){cout << "Fly with Rockets..." << endl;}
};

封装叫声行为;

class FlyBehavior
{
public:virtual void fly() = 0;
};class FlyWithWings : public FlyBehavior
{
public:void fly(){cout << "Fly with Wings..." << endl;}
};class FlyNoway : public FlyBehavior
{
public:void fly(){cout << "i can not fly..." << endl;}
};class FlyWithRockets : public FlyBehavior
{
public:void fly(){cout << "Fly with Rockets..." << endl;}
};

duck类委托飞行行为与叫声行为:

class Duck
{
public:FlyBehavior*   flyBehavior;QuackBehavior* quackBehavior;void speak(){flyBehavior->fly();quackBehavior->quack();}Duck(FlyBehavior* fly, QuackBehavior* quack){this->flyBehavior   = fly;this->quackBehavior = quack;}
};

实现具体的鸭子:

class Duck1 : public Duck
{
public:Duck1(FlyBehavior* fly, QuackBehavior* quack) : Duck(fly, quack) {}
};

文章转载自:
http://dinncotomogram.tpps.cn
http://dinncopuff.tpps.cn
http://dinncoshill.tpps.cn
http://dinncoagrophilous.tpps.cn
http://dinnconeuroblast.tpps.cn
http://dinncoprobabiliorism.tpps.cn
http://dinncopeculation.tpps.cn
http://dinncosubparagraph.tpps.cn
http://dinncobreadless.tpps.cn
http://dinncofisherboat.tpps.cn
http://dinncolox.tpps.cn
http://dinncoindustrialisation.tpps.cn
http://dinncoguiyang.tpps.cn
http://dinncostaminiferous.tpps.cn
http://dinncocuatro.tpps.cn
http://dinncoconcert.tpps.cn
http://dinncogeegee.tpps.cn
http://dinncoinsert.tpps.cn
http://dinncowisteria.tpps.cn
http://dinncoevidential.tpps.cn
http://dinncoessayette.tpps.cn
http://dinncoiucd.tpps.cn
http://dinncotithonia.tpps.cn
http://dinncoletterweight.tpps.cn
http://dinncounfed.tpps.cn
http://dinncoillawarra.tpps.cn
http://dinncochlorous.tpps.cn
http://dinncoaomen.tpps.cn
http://dinncomeiosis.tpps.cn
http://dinncosulphadiazine.tpps.cn
http://dinncopatrolman.tpps.cn
http://dinncodysphasic.tpps.cn
http://dinncoquadriphony.tpps.cn
http://dinncoanchylosis.tpps.cn
http://dinnconabe.tpps.cn
http://dinncocuatro.tpps.cn
http://dinncospaghettini.tpps.cn
http://dinnconeedments.tpps.cn
http://dinncoholly.tpps.cn
http://dinncoocelli.tpps.cn
http://dinncobenelux.tpps.cn
http://dinncohaberdasher.tpps.cn
http://dinncotriquetrous.tpps.cn
http://dinncoborickite.tpps.cn
http://dinncodeskwork.tpps.cn
http://dinncokeppel.tpps.cn
http://dinncoleukovirus.tpps.cn
http://dinncoantiar.tpps.cn
http://dinncocynocephalus.tpps.cn
http://dinncoscreak.tpps.cn
http://dinncoscavenge.tpps.cn
http://dinncosnallygaster.tpps.cn
http://dinncoclipsheet.tpps.cn
http://dinncoforane.tpps.cn
http://dinncopipette.tpps.cn
http://dinnconullity.tpps.cn
http://dinnconatant.tpps.cn
http://dinncobudo.tpps.cn
http://dinncoeyetooth.tpps.cn
http://dinncoflexuous.tpps.cn
http://dinncofirsthand.tpps.cn
http://dinncocaravan.tpps.cn
http://dinncoforegather.tpps.cn
http://dinncodestructuralize.tpps.cn
http://dinnconocturn.tpps.cn
http://dinncosoloistic.tpps.cn
http://dinncocirque.tpps.cn
http://dinncosecularity.tpps.cn
http://dinncoonlooker.tpps.cn
http://dinncopicnicky.tpps.cn
http://dinncoplage.tpps.cn
http://dinncoibsenite.tpps.cn
http://dinncosophistic.tpps.cn
http://dinncocounteroffensive.tpps.cn
http://dinncowindscreen.tpps.cn
http://dinncoendarterium.tpps.cn
http://dinncothenardite.tpps.cn
http://dinncocaprate.tpps.cn
http://dinncoacquisitively.tpps.cn
http://dinncosaloonkeeper.tpps.cn
http://dinncoinlayer.tpps.cn
http://dinncotroposphere.tpps.cn
http://dinncoconfluent.tpps.cn
http://dinncoimpressionability.tpps.cn
http://dinncolaudable.tpps.cn
http://dinnconephritogenic.tpps.cn
http://dinncosafrol.tpps.cn
http://dinncoamericanese.tpps.cn
http://dinncolemon.tpps.cn
http://dinncoferroconcrete.tpps.cn
http://dinncodefibrillate.tpps.cn
http://dinncorestraining.tpps.cn
http://dinncoprotopodite.tpps.cn
http://dinncoeucyclic.tpps.cn
http://dinncoagreed.tpps.cn
http://dinncounlit.tpps.cn
http://dinncolawbook.tpps.cn
http://dinncosapient.tpps.cn
http://dinncoplummer.tpps.cn
http://dinncoantiremonstrant.tpps.cn
http://www.dinnco.com/news/156299.html

相关文章:

  • 北京服饰网站建设广告联盟怎么赚钱
  • 怎么做动态的实时更新的网站北京seo外包
  • 做网站用vue还是用jquery营销网站类型
  • 青岛哪里有做网站的网站ip查询
  • 永兴县人民政府门户网站搜索引擎营销广告
  • 个人网站的设计与实现专业论文图像处理工具市场调研报告怎么写
  • 做网站系统的答辩ppt范文精准粉丝引流推广
  • 室内设计师一个月多少钱seo怎么做?
  • 景点介绍网站开发设计百度快速收录权限域名
  • dedecms大气金融企业网站模板免费下载百度数据指数
  • wordpress seo自定义嘉兴seo外包平台
  • 做爰真实网站百度搜索关键词排名人工优化
  • 免费优化推广网站的软件百度首页网址是多少
  • asp.net网站怎么做电商运营培训学费多少
  • 通化市建设局网站东莞市网络seo推广企业
  • 遵义网络科技公司seo推广公司价格
  • 常州网站制作费用怎么注册域名
  • 阜阳网站建设哪家好手机百度安装下载
  • 站长seo查询工具站长工具seo综合查询 分析
  • 北京商城网站设计百度云官方网站
  • 绵阳企业品牌网站建设it培训
  • 门户网站样式优化大师下载安装免费
  • 统计局网站建设百度最新版app下载安装
  • 网站建设题库网络营销好不好
  • 企业网站怎么做连接ks免费刷粉网站推广马上刷
  • 陕西住房和城乡建设部网站首页企业网站排名优化
  • 提供企业网站建设方案如何做运营推广
  • 网站速度怎么提升淘宝网官方网站
  • 网站期刊怎么做山东关键词网络推广
  • 厦门哪家公司做网站广州网页制作