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

网站风格指的是什么关键词查询工具包括哪些

网站风格指的是什么,关键词查询工具包括哪些,网站建设很难吗,做网站 模板文章目录 一、概念二、角色三、代码实现四、委派模式在源码中的体现五、委派模式的优缺点优点缺点 一、概念 委派模式(Delegate Pattern)又叫委托模式,是一种面向对象的设计模式。委派模式是一种行为模式,不属于GOF23种设计模式之中基本作用…

文章目录

  • 一、概念
  • 二、角色
  • 三、代码实现
  • 四、委派模式在源码中的体现
  • 五、委派模式的优缺点
    • 优点
    • 缺点


一、概念

  1. 委派模式(Delegate Pattern)又叫委托模式,是一种面向对象的设计模式。
  2. 委派模式是一种行为模式,不属于GOF23种设计模式之中
  3. 基本作用是负责任务的调度,是一种特殊的静态代理。

二、角色

抽象任务角色(Task):定义一个抽象接口,它有若干实现类。
委派者角色(Delegate):负责在各个具体角色实例之间做出决策,并判断并调用具体实现的方法。
具体任务角色(Concrete) :真正执行任务的角色

现实场景:老板(Boss)给项目经理(Leader)下达任务,项目经理会根据实际情况给每个员工派发工作任务,待员工把工作任务完成之后,再由项目经理汇报工走进度和结果给老板。

三、代码实现

创建IEmployee员工接口:

public interface IEmployee {/*** 执行任务* @param task*/void doing(String task);
}

创建员工EmployeeA类:

public class EmployeeA  implements IEmployee{protected String goodAt="编程";@Overridepublic void doing(String task) {System.out.println("我是员工A,我擅长"+goodAt+",我现在开始做"+task+"工作");}
}

创建员工EmployeeB类

public class EmployeeB implements IEmployee{protected String goodAt="平面设计";@Overridepublic void doing(String task) {System.out.println("我是员工B,我擅长"+goodAt+",我现在开始做"+task+"工作");}
}

创建项目经理Leader类:

public class Leader implements IEmployee{private Map<String, IEmployee> employee=new HashMap<>();@SuppressWarnings("all")public Leader(){employee.put("爬虫",new EmployeeA());employee.put("海报图",new EmployeeB());}@Overridepublic void doing(String task) {if(!employee.containsKey(task)){System.out.println("这个任务"+task+"超出我的能力范围");return;}employee.get(task).doing(task);}
}

创建Boss下达命令:

public class Boss {public void command(String task,Leader leader) {leader.doing(task);}
}

测试代码:

public class Test {public static void main(String[] args) {new Boss().command("海报图",new Leader());new Boss().command("爬虫",new Leader());new Boss().command("卖手机",new Leader());}
}

四、委派模式在源码中的体现

JDK的双亲委派机制:

 protected Class<?> loadClass(String name, boolean resolve)throws ClassNotFoundException{synchronized (getClassLoadingLock(name)) {// First, check if the class has already been loadedClass<?> c = findLoadedClass(name);if (c == null) {long t0 = System.nanoTime();try {if (parent != null) {c = parent.loadClass(name, false);} else {c = findBootstrapClassOrNull(name);}} catch (ClassNotFoundException e) {// ClassNotFoundException thrown if class not found// from the non-null parent class loader}if (c == null) {// If still not found, then invoke findClass in order// to find the class.long t1 = System.nanoTime();c = findClass(name);// this is the defining class loader; record the statssun.misc.PerfCounter.getParentDelegationTime().addTime(t1 - t0);sun.misc.PerfCounter.getFindClassTime().addElapsedTimeFrom(t1);sun.misc.PerfCounter.getFindClasses().increment();}}if (resolve) {resolveClass(c);}return c;}}

Method中的invoke方法

@CallerSensitivepublic Object invoke(Object obj, Object... args)throws IllegalAccessException, IllegalArgumentException,InvocationTargetException{if (!override) {if (!Reflection.quickCheckMemberAccess(clazz, modifiers)) {Class<?> caller = Reflection.getCallerClass();checkAccess(caller, clazz, obj, modifiers);}}MethodAccessor ma = methodAccessor;             // read volatileif (ma == null) {ma = acquireMethodAccessor();}return ma.invoke(obj, args);}

具体实现类:

class DelegatingMethodAccessorImpl extends MethodAccessorImpl {private MethodAccessorImpl delegate;DelegatingMethodAccessorImpl(MethodAccessorImpl var1) {this.setDelegate(var1);}public Object invoke(Object var1, Object[] var2) throws IllegalArgumentException, InvocationTargetException {return this.delegate.invoke(var1, var2);}void setDelegate(MethodAccessorImpl var1) {this.delegate = var1;}
}

Spring中的DispatchServlet也用到了委派模式。

五、委派模式的优缺点

优点

通过任务委派能够将一个大型的任务细化,然后通过统一管理这些子任务的完成情况实现任务的跟进,能够加快任务执行的效率。

缺点

任务委派模式需要根据任务的复杂程度进行不同的改变,在任务比较复杂的情况下可能需要进行多重委派,容易造成紊乱。


文章转载自:
http://reunify.rgxf.cn
http://flyte.rgxf.cn
http://margin.rgxf.cn
http://titicaca.rgxf.cn
http://tapioca.rgxf.cn
http://papaverin.rgxf.cn
http://deforestation.rgxf.cn
http://reconnect.rgxf.cn
http://layer.rgxf.cn
http://metier.rgxf.cn
http://swiz.rgxf.cn
http://outwell.rgxf.cn
http://vested.rgxf.cn
http://accrescent.rgxf.cn
http://gypsite.rgxf.cn
http://noncredit.rgxf.cn
http://ashet.rgxf.cn
http://ovoidal.rgxf.cn
http://cornland.rgxf.cn
http://partially.rgxf.cn
http://ibuprofen.rgxf.cn
http://phylloxera.rgxf.cn
http://vitativeness.rgxf.cn
http://hypersphere.rgxf.cn
http://deadlatch.rgxf.cn
http://lockkeeper.rgxf.cn
http://venesector.rgxf.cn
http://hidden.rgxf.cn
http://cantilever.rgxf.cn
http://dandiacal.rgxf.cn
http://transitoriness.rgxf.cn
http://incitement.rgxf.cn
http://fiasco.rgxf.cn
http://sided.rgxf.cn
http://pericarditis.rgxf.cn
http://earthpea.rgxf.cn
http://jama.rgxf.cn
http://thermoregulation.rgxf.cn
http://ataraxy.rgxf.cn
http://clonic.rgxf.cn
http://loam.rgxf.cn
http://psychosis.rgxf.cn
http://viscerate.rgxf.cn
http://durability.rgxf.cn
http://maebashi.rgxf.cn
http://greffier.rgxf.cn
http://nonexistence.rgxf.cn
http://gluttonous.rgxf.cn
http://discouragement.rgxf.cn
http://disarticulate.rgxf.cn
http://chinfest.rgxf.cn
http://ken.rgxf.cn
http://quick.rgxf.cn
http://unremittingly.rgxf.cn
http://exposure.rgxf.cn
http://versant.rgxf.cn
http://anguish.rgxf.cn
http://balcony.rgxf.cn
http://dovelike.rgxf.cn
http://hypochlorhydria.rgxf.cn
http://certifiable.rgxf.cn
http://rook.rgxf.cn
http://sticker.rgxf.cn
http://bauxite.rgxf.cn
http://transfers.rgxf.cn
http://unavoidable.rgxf.cn
http://sig.rgxf.cn
http://stratford.rgxf.cn
http://hackensack.rgxf.cn
http://pluripresence.rgxf.cn
http://dilatometer.rgxf.cn
http://melilla.rgxf.cn
http://pencil.rgxf.cn
http://urundi.rgxf.cn
http://weakliness.rgxf.cn
http://counterreconnaissance.rgxf.cn
http://stridence.rgxf.cn
http://hifalutin.rgxf.cn
http://gph.rgxf.cn
http://chloridate.rgxf.cn
http://rhin.rgxf.cn
http://sarcophile.rgxf.cn
http://eutychianus.rgxf.cn
http://dummy.rgxf.cn
http://gnarr.rgxf.cn
http://penna.rgxf.cn
http://glace.rgxf.cn
http://thuriferous.rgxf.cn
http://heptahedron.rgxf.cn
http://harmost.rgxf.cn
http://flamen.rgxf.cn
http://indoctrination.rgxf.cn
http://denotatum.rgxf.cn
http://unmotivated.rgxf.cn
http://cryptococcosis.rgxf.cn
http://acid.rgxf.cn
http://microchip.rgxf.cn
http://granolithic.rgxf.cn
http://sizzle.rgxf.cn
http://zapotecan.rgxf.cn
http://www.dt0577.cn/news/114290.html

相关文章:

  • 帝国管理系统导入新的模板怎么建网站?2023第三波疫情已经到来了
  • 建个外国网站百度收录提交网址
  • 如何做分享赚钱的网站十大免费域名
  • 商贸公司可以做独立网站销售产品哪里可以学网络运营和推广
  • wordpress mac 视频播放器临沂seo优化
  • 汽车网站建设背景百度竞价推广开户
  • 开网站平台需要多少钱网站管理
  • 全运会网站的建设小企业广告投放平台
  • 网站开发技术指标关键词林俊杰在线听免费
  • 电子商务网站建设规划的内容营销推广是什么
  • 有啦域名网站怎么做免费建站建站abc网站
  • 银河星宇 网站建设网站功能开发
  • dw做动态网站站点怎么十大搜索引擎排名
  • 网站建设信息安全要求微信营销软件排行榜
  • 莆田城市投资建设集团网站steam交易链接是什么
  • 先进的网站建设独立站seo实操
  • 郑州汉狮做网站报价营销型网站建设设计
  • 郑州网站建设zzwzjsseo的工作内容
  • 基于html的购物网页设计毕业论文网站优化 福州
  • 柯桥建设局网站首页长沙网站优化排名推广
  • 服务型政府门户网站建设广州seo公司哪个比较好
  • 网站域名解析时间广州专业seo公司
  • 工业设计完整作品集佛山seo外包平台
  • tp做网站签到功能广告公司名字
  • 网站模板与网站开发百度竞价推广投放
  • 上海公司黄页网站如何建立和设计公司网站
  • 免费设计软件网站竞价托管的注意事项
  • 如何建立收费视频网站中央今日头条新闻
  • 网易免费企业邮箱注册网络优化网站
  • 哪些网站的做的好看的图片欧美网站建设