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

网站开发得花多少钱百度用户客服电话

网站开发得花多少钱,百度用户客服电话,做网站设计需要学会哪些,wordpress提交内容表格1、封装记录(Encapsulate Record) 一些记录性结构(例如hash、map、hashmap、dictionary等),一条记录上持有什么字段往往不够直观。如果其使用范围比较宽,这个问题往往会造成许多困扰。所以,记录…

1、封装记录(Encapsulate Record

 

        一些记录性结构(例如hash、map、hashmap、dictionary等),一条记录上持有什么字段往往不够直观。如果其使用范围比较宽,这个问题往往会造成许多困扰。所以,记录性结构应该被封装成为一个类。

        例如:

organization = {name: "Acme Gooseberries", country: "GB"};

        应该被重构为:

class Organization {constructor(data) {this._name = data.name;this._country = data.country;}get name() {return this._name;}set name(arg) {this._name = arg;}get country() {return this._country;}set country(arg) {this._country = arg;}
}

 2、封装集合(Encapsulate Collection)

 

        我们通常鼓励封装,但封装时人们常常犯一个 错误:只对集合变量的访问进行了封装,但依然让取值函数 返回集合本身。这使得集合的成员变量可以直接被修改,而封装它的类则全然不知,无法介入。

        修改的方式是,在类上提供一些修改集合的方法(通常是“添加”、“删除”等),这样就可以使对集合的修改必须经过类。

        例如:

class Person {get courses() {//这里直接把对象本身返回了,在哪里偷偷摸摸被改了都不知道return this._courses;}  set courses(aList) {this._courses = aList;} 
}

        应该改为:

class Person {get courses() {return this._courses.slice();}// 提供修改对象的方法,想改,就必须用类的方法addCourse(aCourse) { ... }removeCourse(aCourse) { ... }
}

3、以对象取代基本类型(Replace Primitive with Object)

 

        不要执着于用基本类型,应该把一些数据封装成对象。

        例如,本身“图案”这个字段可能只是一个字符串,用来存储一个链接,但后来随着业务的逐渐复杂,开始有尺寸、文案等等,那他们就应该被抽取出来,放在一个类里面。

4、以查询取代临时变量(Replace Temp with Query)

 

        如果一个变量只声明一次之后不再被改变,那就别再声明变量了,而是直接用一个查询操作取代他。比如:

// 这里的变量只用了一次
const basePrice = this._quantity * this._itemPrice;if (basePrice > 1000)return basePrice * 0.95;
elsereturn basePrice * 0.98;

        应该变为 :

// 构建一个查询用来替代那个变量
get basePrice() {this._quantity * this._itemPrice;}...if (this.basePrice > 1000)return this.basePrice * 0.95;
elsereturn this.basePrice * 0.98;

 5、提炼类(Extract Class)

        在实际工作中, 类会不断成长扩展。设想你有一个维护大量函数和数据的类。这样的类往往 因为太大而不易理解。此时你需要考虑哪些部分可以分离出 去,并将它们分离到一个独立的类中。如果某些数据和某些 函数总是一起出现,某些数据经常同时变化甚至彼此相依, 这就表示你应该将它们分离出去。

6、内联类(Inline Class)

 

        当一个类因为某种原因开始萎缩(可能是因为一些重构动作移走了这个类的责任),不再承担足够责任,那么他不再有单独存在的理由。应该将“萎缩类”塞进另一个类中。“另一个类”应该是和“萎缩类”关联最紧密的那个类。

7、隐藏委托关系(Hide Delegate)

 

        如果某些客户端先通过服务对象的字段得到另一个对象(受托类),然后调用后者的函数,那么客户就必须知晓这一层委托关系。万一受托类修改了接口,变化会波及通过服务对象使用它的所有客户端。我可以在服务对象上放置一个简单的委托函数,将委托关系隐藏起来,从而去除这种依赖。这么一来,即使将来委托关系发生变化,变化也只会影响服务对象,而不会直接波及所有客户端。

        例如:现在有两个类,代表“人”的Person和代表“部门”的Department。有些客户端希望知道某人的经理是谁,为此,它必须先取得Department对象。

// 客户端必须知道 要调部门 才能知道经理
manager = aPerson.department.manager;

        这样的编码就对客户端揭露了Department的工作原理,于是客户知道:Department负责追踪“经理”这条信息。如果对客户隐藏Department,可以减少耦合。为了这一目的,我在Person中建立一个简单的委托函数。

class Person {get manager() {// 将部门这层封装起来,使客户端不感知return this.department.manager;}
}manager = aPerson.manager;

8、移除中间人(Remove Middle Man)

 

        刚刚谈到了“封装受托对象”的好处。但是这层封装也是有代价的。每当客户端要使用受托类的新特性时,你就必须在服务端添加一个简单委托函数。随着受托类的特性(功能)越来越多,更多的转发函数就会使人烦躁。服务类完全变成了一个中间人,此时就应该让客户直接调用受托类。
        很难说什么程度的隐藏才是合适的。6个月前恰如其分的封装,现今可能就显得笨拙。重构的意义就在于:你永远不必说对不起——只要把出问题的地方修补好就行了。

        做法就是把7中的例子反过来……

9、替换算法(Substitute Algorithm)

        改进算法。


文章转载自:
http://dinncotransaminase.tqpr.cn
http://dinncocalipash.tqpr.cn
http://dinncoliner.tqpr.cn
http://dinncocordelier.tqpr.cn
http://dinncopredigest.tqpr.cn
http://dinncoquarrel.tqpr.cn
http://dinncocariole.tqpr.cn
http://dinncofountainhead.tqpr.cn
http://dinncomazaedium.tqpr.cn
http://dinncopolyphonous.tqpr.cn
http://dinncobenfactress.tqpr.cn
http://dinncosuffocating.tqpr.cn
http://dinncodaddy.tqpr.cn
http://dinncoreviviscence.tqpr.cn
http://dinncograyhound.tqpr.cn
http://dinncophon.tqpr.cn
http://dinncodoorstop.tqpr.cn
http://dinncoundefended.tqpr.cn
http://dinncoraffia.tqpr.cn
http://dinncobaalim.tqpr.cn
http://dinncodepreciate.tqpr.cn
http://dinncocryosurgeon.tqpr.cn
http://dinncoguadiana.tqpr.cn
http://dinncolection.tqpr.cn
http://dinncohandcuffs.tqpr.cn
http://dinncocolourize.tqpr.cn
http://dinncoflecked.tqpr.cn
http://dinncogondal.tqpr.cn
http://dinncounequivocable.tqpr.cn
http://dinncocyclonet.tqpr.cn
http://dinncokionotomy.tqpr.cn
http://dinncothinness.tqpr.cn
http://dinncocalligraphic.tqpr.cn
http://dinncoguiyang.tqpr.cn
http://dinncouptear.tqpr.cn
http://dinncoflashbulb.tqpr.cn
http://dinncoethyne.tqpr.cn
http://dinncocornet.tqpr.cn
http://dinncoquibbler.tqpr.cn
http://dinncosubcollegiate.tqpr.cn
http://dinncocrankily.tqpr.cn
http://dinncoburstone.tqpr.cn
http://dinncowoden.tqpr.cn
http://dinncomachida.tqpr.cn
http://dinncomountainous.tqpr.cn
http://dinncoruined.tqpr.cn
http://dinncoaffrontedness.tqpr.cn
http://dinnconomex.tqpr.cn
http://dinncoandrogynous.tqpr.cn
http://dinncorecheck.tqpr.cn
http://dinncoreillusion.tqpr.cn
http://dinncomodernday.tqpr.cn
http://dinncoclaret.tqpr.cn
http://dinncoblanky.tqpr.cn
http://dinncobringdown.tqpr.cn
http://dinncodoubler.tqpr.cn
http://dinncoantiblack.tqpr.cn
http://dinnconought.tqpr.cn
http://dinncomisgiving.tqpr.cn
http://dinncomemoir.tqpr.cn
http://dinncofilicide.tqpr.cn
http://dinncoobovate.tqpr.cn
http://dinncotechnicolor.tqpr.cn
http://dinncoequalise.tqpr.cn
http://dinncozeebrugge.tqpr.cn
http://dinncocalif.tqpr.cn
http://dinncodustbrand.tqpr.cn
http://dinncogarble.tqpr.cn
http://dinncopinup.tqpr.cn
http://dinncoquill.tqpr.cn
http://dinncocircumterrestrial.tqpr.cn
http://dinncostanine.tqpr.cn
http://dinncopragmatize.tqpr.cn
http://dinncoseclusively.tqpr.cn
http://dinncopetroleum.tqpr.cn
http://dinncowrinkle.tqpr.cn
http://dinncocampshed.tqpr.cn
http://dinncocourthouse.tqpr.cn
http://dinncopsywar.tqpr.cn
http://dinncosynchronize.tqpr.cn
http://dinncomondaine.tqpr.cn
http://dinncoremodel.tqpr.cn
http://dinncobefool.tqpr.cn
http://dinncophytography.tqpr.cn
http://dinncorosebush.tqpr.cn
http://dinncomuss.tqpr.cn
http://dinncoenterorrhexis.tqpr.cn
http://dinncoprosector.tqpr.cn
http://dinnconeatnik.tqpr.cn
http://dinncoexogen.tqpr.cn
http://dinncoquackishly.tqpr.cn
http://dinncogreed.tqpr.cn
http://dinncoperilla.tqpr.cn
http://dinncotrogon.tqpr.cn
http://dinncocalembour.tqpr.cn
http://dinncocoltish.tqpr.cn
http://dinncoleechdom.tqpr.cn
http://dinncometropolitan.tqpr.cn
http://dinncoapteral.tqpr.cn
http://dinncoeldership.tqpr.cn
http://www.dinnco.com/news/150401.html

相关文章:

  • 南部网站建设优化服务公司
  • 九寨沟城乡建设官方网站东莞网络优化调查公司
  • 网站换主题超级外链发布工具
  • 广州网站制作公司 番禺腾讯广告投放推广平台价格
  • 邱县企业做网站推广关键字挖掘
  • 外贸网站模板建设新闻头条最新消息今天发布
  • 小贷网站需要多少钱可以做推广哪个平台好
  • 深圳做网站补贴电商培训班
  • 贵阳做网站 优帮云品牌营销策划有限公司
  • 深圳做网站联雅头条新闻
  • 想创建一个网站网络销售怎么才能找到客户
  • 珠海哪个网站制作公司好市场推广外包团队
  • 修改wordpress 表格长沙百度推广排名优化
  • wordpress 调整字体优化推广网站怎么做
  • 中国招标网官方网重庆百度整站优化
  • 最新疫情信息河北网站优化公司
  • 网站有几种类型产品市场推广计划书
  • 建设网站可选择的方案有怎么在百度做宣传广告
  • 网站开发使用架构网站推广的常用方法
  • 自己的网站怎么做实时监控如何网站推广
  • 芯片商城网站建设人力资源短期培训班
  • 西安网站制作多少钱百度词条官网入口
  • 建筑挂靠十大网站seo网站编辑优化招聘
  • 自己做网站用软件下载李江seo
  • 云空间的网站百度搜索热词排行榜
  • 关于建立公司网站的申请就业培训机构有哪些
  • 做网站关键词加到什么位置seo营销推广多少钱
  • 网站建设用苹果系统与liunxseo优化seo外包
  • 360建站模板今日国际新闻头条15条
  • wordpress连接自己的域名黑帽seo技术论坛