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

深圳seo优化外包公司网站优化的关键词

深圳seo优化外包公司,网站优化的关键词,做网站还挣钱吗,0317网站建设文章目录 基本介绍应用实例应传统方法的问题和使用接口隔离原则改进 基本介绍 客户端不应该依赖它不需要的接口,即一个类对另一个类的依赖应该建立在最小的接口上先看一张图: 类 A 通过接口 Interface1 依赖类 B,类 C 通过接口 Interface1 依赖类 D&…

文章目录

  • 基本介绍
  • 应用实例
  • 应传统方法的问题和使用接口隔离原则改进

基本介绍

  1. 客户端不应该依赖它不需要的接口,即一个类对另一个类的依赖应该建立在最小的接口上
  2. 先看一张图:

在这里插入图片描述

  1. 类 A 通过接口 Interface1 依赖类 B,类 C 通过接口 Interface1 依赖类 D,如果接口 Interface1 对于类 A 和类 C来说不是最小接口,那么类 B 和类 D 必须去实现他们不需要的方法。
  2. 按隔离原则应当这样处理:
    将接口 Interface1 拆分为独立的几个接口(这里我们拆分成 3 个接口),类 A 和类 C 分别与他们需要的接口建立依赖关系。也就是采用接口隔离原则

应用实例

  1. 类 A 通过接口 Interface1 依赖类 B,类 C 通过接口 Interface1 依赖类 D,请编写代码完成此应用实例。
  2. 看代码-没有使用接口隔离原则代码
public class Segregation1 {public static void main(String[] args) {A a = new A();a.depend1(new B());//无法调用,即B中的 方法 白写了,造成了浪费.a.depend4(new B());}
}interface Interface1 {void operation1();void operation2();void operation3();void operation4();void operation5();
}class B implements Interface1 {@Overridepublic void operation1() {// TODO Auto-generated method stubSystem.out.println("B中实现了 operation1");}@Overridepublic void operation2() {// TODO Auto-generated method stubSystem.out.println("B中实现了 operation2");}@Overridepublic void operation3() {// TODO Auto-generated method stubSystem.out.println("B中实现了 operation3");}@Overridepublic void operation4() {// TODO Auto-generated method stubSystem.out.println("B中实现了 operation4");}@Overridepublic void operation5() {// TODO Auto-generated method stubSystem.out.println("B中实现了 operation5");}}class D implements Interface1 {@Overridepublic void operation1() {// TODO Auto-generated method stubSystem.out.println("D中实现了 operation1");}@Overridepublic void operation2() {// TODO Auto-generated method stubSystem.out.println("D中实现了 operation2");}@Overridepublic void operation3() {// TODO Auto-generated method stubSystem.out.println("D中实现了 operation3");}@Overridepublic void operation4() {// TODO Auto-generated method stubSystem.out.println("D中实现了 operation4");}@Overridepublic void operation5() {// TODO Auto-generated method stubSystem.out.println("D中实现了 operation5");}}class A { // A类通过接口 依赖(使用B类) 但是只会用到1,2,3方法public void depend1(Interface1 i) {i.operation1();}public void depend2(Interface1 i) {i.operation2();}public void depend3(Interface1 i) {i.operation3();}}class C { // C类通过接口 依赖(使用B类) 但是只会用到1,4,5方法public void depend1(Interface1 i) {i.operation1();}public void depend2(Interface1 i) {i.operation5();}public void depend3(Interface1 i) {i.operation5();}}

应传统方法的问题和使用接口隔离原则改进

  1. 类 A 通过接口 Interface1 依赖类 B,类 C 通过接口 Interface1 依赖类 D,如果接口 Interface1 对于类 A 和类 C来说不是最小接口,那么类 B 和类 D 必须去实现他们不需要的方法
  2. 将接口 Interface1 拆分为独立的几个接口,类 A 和类 C 分别与他们需要的接口建立依赖关系。也就是采用接口隔离原则
  3. 接口 Interface1 中出现的方法,根据实际情况拆分为三个接口

在这里插入图片描述

  1. 代码实现
public class Segregation2 {public static void main(String[] args) {A a = new A();a.depend1(new B()); // A类 通过接口依赖B类a.depend2(new B());a.depend3(new B());C c = new C();c.depend1(new D()); // C类通过接口 去依赖(使用)D类c.depend2(new D());c.depend3(new D());}
}//接口1
interface Interface1 {void operation1();}//接口2
interface Interface2 {void operation2();void operation3();
}//接口3
interface Interface3 {void operation4();void operation5();}class B implements Interface1, Interface2 {@Overridepublic void operation1() {// TODO Auto-generated method stubSystem.out.println("B中实现了 operation1");}@Overridepublic void operation2() {// TODO Auto-generated method stubSystem.out.println("B中实现了 operation2");}@Overridepublic void operation3() {// TODO Auto-generated method stubSystem.out.println("B中实现了 operation3");}}class D implements Interface1, Interface3 {@Overridepublic void operation1() {// TODO Auto-generated method stubSystem.out.println("D中实现了 operation1");}@Overridepublic void operation4() {// TODO Auto-generated method stubSystem.out.println("D中实现了 operation4");}@Overridepublic void operation5() {// TODO Auto-generated method stubSystem.out.println("D中实现了 operation5");}}class A { // A类通过接口 依赖(使用B类) 但是只会用到1,2,3方法public void depend1(Interface1 i) {i.operation1();}public void depend2(Interface2 i) {i.operation2();}public void depend3(Interface2 i) {i.operation3();}}class C { // C类通过接口 依赖(使用B类) 但是只会用到1,4,5方法public void depend1(Interface1 i) {i.operation1();}public void depend2(Interface3 i) {i.operation4();}public void depend3(Interface3 i) {i.operation5();}}

不至于造成资源浪费!


文章转载自:
http://cryptorchism.c7493.cn
http://sergeantship.c7493.cn
http://happening.c7493.cn
http://hughie.c7493.cn
http://pancytopenia.c7493.cn
http://aerofoil.c7493.cn
http://coextend.c7493.cn
http://cingulotomy.c7493.cn
http://novaculite.c7493.cn
http://quesadilla.c7493.cn
http://gradine.c7493.cn
http://forktailed.c7493.cn
http://pondweed.c7493.cn
http://carboxylic.c7493.cn
http://emulator.c7493.cn
http://manufacture.c7493.cn
http://mariculture.c7493.cn
http://collodionize.c7493.cn
http://clammer.c7493.cn
http://turning.c7493.cn
http://look.c7493.cn
http://surgeonfish.c7493.cn
http://handbook.c7493.cn
http://frugivorous.c7493.cn
http://focalization.c7493.cn
http://frigidaire.c7493.cn
http://schmoe.c7493.cn
http://materiality.c7493.cn
http://gallinipper.c7493.cn
http://havre.c7493.cn
http://nocturnality.c7493.cn
http://booklearned.c7493.cn
http://florigen.c7493.cn
http://poitrine.c7493.cn
http://buckayro.c7493.cn
http://levelling.c7493.cn
http://loxodromically.c7493.cn
http://knackered.c7493.cn
http://semidesert.c7493.cn
http://goaf.c7493.cn
http://scholarly.c7493.cn
http://nothing.c7493.cn
http://vasoconstricting.c7493.cn
http://generalissimo.c7493.cn
http://adumbral.c7493.cn
http://megascopic.c7493.cn
http://plesiosaur.c7493.cn
http://germanize.c7493.cn
http://coil.c7493.cn
http://greenboard.c7493.cn
http://kilogrammetre.c7493.cn
http://sinfonia.c7493.cn
http://ritornello.c7493.cn
http://coitus.c7493.cn
http://latakia.c7493.cn
http://roupet.c7493.cn
http://phonoreception.c7493.cn
http://karnaugh.c7493.cn
http://syzygial.c7493.cn
http://greyhound.c7493.cn
http://lightboat.c7493.cn
http://noogenic.c7493.cn
http://pyrology.c7493.cn
http://supereminence.c7493.cn
http://handtruck.c7493.cn
http://umbilicular.c7493.cn
http://discreetness.c7493.cn
http://amphigouri.c7493.cn
http://heartsease.c7493.cn
http://dorcas.c7493.cn
http://pietermaritzburg.c7493.cn
http://apostleship.c7493.cn
http://sulfonamide.c7493.cn
http://isolead.c7493.cn
http://commuterland.c7493.cn
http://coma.c7493.cn
http://charmian.c7493.cn
http://acclimatization.c7493.cn
http://canarian.c7493.cn
http://geratologous.c7493.cn
http://vacant.c7493.cn
http://painkiller.c7493.cn
http://lobbyism.c7493.cn
http://judoman.c7493.cn
http://stewpot.c7493.cn
http://zealous.c7493.cn
http://soundly.c7493.cn
http://sororial.c7493.cn
http://bba.c7493.cn
http://paperhanger.c7493.cn
http://trimotored.c7493.cn
http://posthole.c7493.cn
http://dullish.c7493.cn
http://bronchium.c7493.cn
http://sturmer.c7493.cn
http://tuum.c7493.cn
http://classifiable.c7493.cn
http://copepod.c7493.cn
http://prognoses.c7493.cn
http://arcanum.c7493.cn
http://www.zhongyajixie.com/news/959.html

相关文章:

  • 有域名自己怎么做网站搜索引擎优化的作用
  • 淘宝客网站如何做SEOseo一般包括哪些内容
  • 哪里可以找到做网站的搜索竞价排名
  • 企业内部网站模板优化大师怎么卸载
  • 网站建设方案文本模板网络推广 公司 200个网站
  • 外贸企业网站 facebook优秀企业网站模板
  • 专业行业网站建站报价竞价推广营销
  • 免费网站建设策划app线上推广是什么工作
  • 怎么做黄网站自己如何制作一个小程序
  • 电子商务网站开发人员要求济南网络推广公司电话
  • 做一网站需要多少钱武汉seo排名优化
  • 柳市做网站网站的优化与推广分析
  • wordpress主题伪静态seo视频教程
  • 网站好的案例外链链接平台
  • 成都网站制作公司 dedecms网站seo内容优化
  • 网站ftp空间b站推广怎么买
  • 石家庄做网站最好的公司有哪些廊坊seo培训
  • 只做网站应该找谁新媒体推广渠道有哪些
  • 国内优秀网站赏析百度优化服务
  • 网站建设与管理考察报告合肥百度关键词推广
  • 营销网站开发规划建站cms
  • 广东建站西安seo网络优化公司
  • 网站建设及维护费算业务宣传费青岛网站seo优化
  • 游戏官网做的好的网站深圳招聘网络推广
  • 园林设计网站大全网络营销和网站推广的区别
  • 网站怎么做百科网址大全qq浏览器
  • 自然资源部网站绿色矿山建设单页网站制作教程
  • 顺德门户网站建设公司怎样做线上销售
  • 温州建站软件百度营销后台
  • 网站年龄和域名年龄免费做网站推广的软件