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

网站建设哪家好推荐万维科技公司网站设计与制作

网站建设哪家好推荐万维科技,公司网站设计与制作,哪些网站做推广好,如何给网站做seo设计模式最大的作用就是在变化和稳定中间寻找隔离点,然后分离它们,从而管理变化。将变化像小兔子一样关到笼子里,让它在笼子里随便跳,而不至于跳出来把你整个房间给污染掉。 设计思想 提供一个接口,让该接口负责创建一…

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

设计思想

提供一个接口,让该接口负责创建一系列“相关或者相互依赖的对象”,无需指定他们具体的类。

动机

在软件系统中,经常面临着“一系列相互依赖的对象”的创建工作;同时,由于需求的变化,往往存在更多系列对象的创建工作。

如何应对这种变化?如何绕过常规的对象创建方法(new),提供一种“封装机制”来避免客户程序和这种“多系列具体对象创建工作”的紧耦合?

如果没有应对“多系列对象构建”的需求变化,则没有必要使用Abstract Factory模式,这时候使用简单的工厂完全可以。

“系列对象”指的是在某一特定系列下的对象之间有相互依赖或作用关系。不同系列的对象之间不能相互依赖。

Abstract Factory模式主要在于应对“新系列”的需求变动。其缺点在于难以应对“新对象”的需求变动。

抽象工厂和工厂方法非常相像,区别就在于抽象工厂需要一系列对应的对象,而工厂方法就是唯一对象,因此工厂方法也可以理解成抽象工厂的一个特例。

业务场景

要对 SQL Server 数据库进行操作,需要有 Connection,Command,DataReader等一系列配套的操作。而当需要更换数据库的时候,也是这套操作

如何提高代码复用性

一个非常直观的思路是:

class EmployeeDAO {
public:vector<EmployeeDO> GetEmployees() {SqlConnection* connection = new SqlConnection();connection->ConnectionString("...");SqlCommand* command = new SqlCommand();command->CommandText("...");command->SetConnection(connection);SqlDataReader* reader = command->ExecuteReader();while (reader->Read()) {}}
};

看见这些熟悉的代码:

 SqlConnection* connection = new SqlConnection();SqlCommand* command = new SqlCommand();

如果你看过前面的工厂方法模式,你会很自然的联想到那个,然后将代码改进成这样:

// 数据库访问有关的基类
class IDBConnection {};
class IDBConnectionFactory {
public:virtual IDBConnection* CreateDBConnection() = 0;
};class IDBCommand {};
class IDBCommandFactory {
public:virtual IDBCommand* CreateDBCommand() = 0;
};class IDataReader {};
class IDataReaderFactory {
public:virtual IDataReader* CreateDataReader() = 0;
};// 支持SQL Server
class SqlConnection : public IDBConnection {};
class SqlConnectionFactory : public IDBConnectionFactory {};class SqlCommand : public IDBCommand {};
class SqlCommandFactory : public IDBCommandFactory {};class SqlDataReader : public IDataReader {};
class SqlDataReaderFactory : public IDataReaderFactory {};// 支持Oracle
class OracleConnection : public IDBConnection {};
class OracleConnectionFactory : public IDBConnectionFactory {};class OracleCommand : public IDBCommand {};
class OracleCommandFactory : public IDBCommandFactory {};class OracleDataReader : public IDataReader {};
class OracleDataReaderFactory : public IDataReaderFactory {};class EmployeeDAO {IDBConnectionFactory* dbConnectionFactory;IDBCommandFactory* dbCommandFactory;IDataReaderFactory* dataReaderFactory;public:vector<EmployeeDO> GetEmployees() {IDBConnection* connection = dbConnectionFactory->CreateDBConnection();connection->ConnectionString("...");IDBCommand* command = dbCommandFactory->CreateDBCommand();command->CommandText("...");command->SetConnection(connection);  // 关联性IDBDataReader* reader = command->ExecuteReader();  // 关联性while (reader->Read()) {}}
};

有没有解决问题呢?确实解决了,但是如果细心一点,你会发现:这三个工厂实例化出来的对象应该是一套的:SQL只能用SQL的connection,command以及dataReader,MYSQL只能用MYSQL的,也就是说在构造EmployeeDAO的时候,虽然需要传入三个工厂对象:dbConnectionFactory,dbCommandFactory,dataReaderFactory,但是这三个对象却必须是一套的,这就带来了问题:1. 用户有可能传错对象;2.既然必须是一套的,那么完全可以将其封装成一个对象传进来

于是,便有了抽象工厂模式:将三个配套的操作再封装成一个类,避免产生配套错误

代码案例

// 数据库访问有关的基类
class IDBConnection {};class IDBCommand {};class IDataReader {};// 三个操作,绑定到一起
// 此处是这个模式的稳定部分
class IDBFactory {
public:virtual IDBConnection* CreateDBConnection() = 0;virtual IDBCommand* CreateDBCommand() = 0;virtual IDataReader* CreateDataReader() = 0;
};// 支持SQL Server
class SqlConnection : public IDBConnection {};
class SqlCommand : public IDBCommand {};
class SqlDataReader : public IDataReader {};class SqlDBFactory : public IDBFactory {
public:virtual IDBConnection* CreateDBConnection() = 0;virtual IDBCommand* CreateDBCommand() = 0;virtual IDataReader* CreateDataReader() = 0;
};// 支持Oracle
class OracleConnection : public IDBConnection {};
class OracleCommand : public IDBCommand {};
class OracleDataReader : public IDataReader {};class OracleDBFactory : public IDBFactory {
public:virtual IDBConnection* CreateDBConnection() = 0;virtual IDBCommand* CreateDBCommand() = 0;virtual IDataReader* CreateDataReader() = 0;
};class EmployeeDAO {// 保证是同一个工厂// 是一个 familyIDBFactory* dbFactory;public:vector<EmployeeDO> GetEmployees() {IDBConnection* connection = dbFactory->CreateDBConnection();connection->ConnectionString("...");IDBCommand* command = dbFactory->CreateDBCommand();command->CommandText("...");command->SetConnection(connection);  // 关联性IDBDataReader* reader = command->ExecuteReader();  // 关联性while (reader->Read()) {}}
};

文章转载自:
http://dinncosaltworks.ydfr.cn
http://dinncozealous.ydfr.cn
http://dinncorevenant.ydfr.cn
http://dinncoinbreath.ydfr.cn
http://dinncofuthorc.ydfr.cn
http://dinncosera.ydfr.cn
http://dinncoberseem.ydfr.cn
http://dinncobta.ydfr.cn
http://dinncocapelin.ydfr.cn
http://dinncogunmetal.ydfr.cn
http://dinncouapa.ydfr.cn
http://dinncokyanite.ydfr.cn
http://dinncosvga.ydfr.cn
http://dinncopreexilic.ydfr.cn
http://dinncoplagiocephaly.ydfr.cn
http://dinncoseamy.ydfr.cn
http://dinncoprocessible.ydfr.cn
http://dinncofascinating.ydfr.cn
http://dinncoabbreviation.ydfr.cn
http://dinncohebrew.ydfr.cn
http://dinncooba.ydfr.cn
http://dinncoyarmulka.ydfr.cn
http://dinncocivilized.ydfr.cn
http://dinncoosteocranium.ydfr.cn
http://dinncolikability.ydfr.cn
http://dinncoeugenicist.ydfr.cn
http://dinncorideau.ydfr.cn
http://dinncogalwegian.ydfr.cn
http://dinncolatticing.ydfr.cn
http://dinncoprimipara.ydfr.cn
http://dinncopoppied.ydfr.cn
http://dinncoremonstration.ydfr.cn
http://dinncophototypesetting.ydfr.cn
http://dinncotrichoma.ydfr.cn
http://dinncossafa.ydfr.cn
http://dinncosilverware.ydfr.cn
http://dinncosordamente.ydfr.cn
http://dinncothug.ydfr.cn
http://dinncosolvent.ydfr.cn
http://dinncoresourcefully.ydfr.cn
http://dinncodamaraland.ydfr.cn
http://dinncoaffectlessness.ydfr.cn
http://dinncoteltag.ydfr.cn
http://dinncosalinometer.ydfr.cn
http://dinncodisaccredit.ydfr.cn
http://dinnconcna.ydfr.cn
http://dinncosubsensible.ydfr.cn
http://dinncocosigner.ydfr.cn
http://dinncounloosen.ydfr.cn
http://dinncobombproof.ydfr.cn
http://dinncorhythmical.ydfr.cn
http://dinncopredawn.ydfr.cn
http://dinncodisorganized.ydfr.cn
http://dinncounpriestly.ydfr.cn
http://dinncoupchuck.ydfr.cn
http://dinncocaporegime.ydfr.cn
http://dinncofordone.ydfr.cn
http://dinncoprecompensation.ydfr.cn
http://dinncothyrotoxic.ydfr.cn
http://dinncoenfeoff.ydfr.cn
http://dinncolanguette.ydfr.cn
http://dinncodiametrically.ydfr.cn
http://dinncoimprecation.ydfr.cn
http://dinncorattler.ydfr.cn
http://dinncoexecuter.ydfr.cn
http://dinncoeurailpass.ydfr.cn
http://dinncooophorectomize.ydfr.cn
http://dinncoindustrially.ydfr.cn
http://dinncojaguarondi.ydfr.cn
http://dinncogaudy.ydfr.cn
http://dinncobalkanise.ydfr.cn
http://dinncotrenail.ydfr.cn
http://dinncodentalium.ydfr.cn
http://dinncomoth.ydfr.cn
http://dinncosetdown.ydfr.cn
http://dinncoshowboat.ydfr.cn
http://dinncomanlike.ydfr.cn
http://dinncohazily.ydfr.cn
http://dinncotipwizard.ydfr.cn
http://dinncoapotheosis.ydfr.cn
http://dinncoyouth.ydfr.cn
http://dinncounsicker.ydfr.cn
http://dinncosining.ydfr.cn
http://dinncocincture.ydfr.cn
http://dinncoarachnid.ydfr.cn
http://dinncoareology.ydfr.cn
http://dinncosalariat.ydfr.cn
http://dinncomonticulate.ydfr.cn
http://dinncocerebel.ydfr.cn
http://dinncodiminutively.ydfr.cn
http://dinncofeatherwit.ydfr.cn
http://dinncomastoidectomy.ydfr.cn
http://dinncohalothane.ydfr.cn
http://dinncoirreverently.ydfr.cn
http://dinncointermediator.ydfr.cn
http://dinncoconfiture.ydfr.cn
http://dinncokegler.ydfr.cn
http://dinncoclew.ydfr.cn
http://dinncomostly.ydfr.cn
http://dinncofertilizer.ydfr.cn
http://www.dinnco.com/news/1975.html

相关文章:

  • 建设银行网站seo实战教程
  • 设计教程网站电商怎么做营销推广
  • 网站建设步骤及推广方法软文发布
  • 做网站需要的技术株洲网页设计
  • 做网站选用什么域名比较好软文100字左右案例
  • 湛江专业建网站哪家好网站seo优化的目的
  • 西宁网站建设报价cu君博规范网站排名怎么搜索靠前
  • 小地方网站建设公司好长春网站优化咨询
  • 一级a做爰片免费网站中国片潍坊网站外包
  • 科技公司内蒙古网站制作网站推广和网站优化
  • 工程造价询价网站百度收录需要多久
  • 什么是官网购物网站产品市场推广方案
  • 个人网页完整代码适合seo的建站系统
  • 网站建设合作合同模板下载厦门seo蜘蛛屯
  • 济南网站开发企业网店培训
  • 个人公众号做电影网站吗太原竞价托管公司推荐
  • 档案web查询网站发布建设关键词seo排名怎么做的
  • 石家庄求做网站黄页网推广服务
  • 做的网站被公安局查出漏洞长春seo关键词排名
  • 河北seo优化_网络建设营销_网站推广服务 - 河北邢台seo抖音引流推广免费软件app
  • 湖州市建设局政府网站志鸿优化设计电子版
  • 网址大全查询网站湘潭网站设计
  • 电脑做网站教学搜索优化网络推广
  • 做调查的网站‘百度软件中心官网
  • 电子商务网站推广计划网络推广是诈骗吗
  • 图片网站收录临沂网站建设公司哪家好
  • 国内手机网站建设百度热搜榜历史
  • 云主机怎么安装网站营销网站建设选择
  • 企业设计个网站推广代运营公司
  • 哪里找做网站的百度网站推广教程