第七章节模块化架构.pptVIP

  • 3
  • 0
  • 约1.26万字
  • 约 45页
  • 2017-03-19 发布于四川
  • 举报
7.4循环依赖的必要性(3) 可以看到有两个独立的包,它们之间存在着相互调用的关系。 Encryptor,不需要进行修改,因为不管是编译还是具体运行的时候,它都是依赖于MutableArray所地的模块,可以直接使用MutableArray类。但MutableArray类在编译的时候不能直接使用Encryptor类了。 Evaluation only. Created with Aspose.Slides for .NET 3.5 Client Profile . Copyright 2004-2011 Aspose Pty Ltd. 分成两个模块的应用 Lookup MutableArray Encryptor DoEncode DoEncodelmpl 查找DoEncode的实现 实现 通过META-INF/SERVERS注册DoEncodelmpl 调用 Evaluation only. Created with Aspose.Slides for .NET 3.5 Client Profile . Copyright 2004-2011 Aspose Pty Ltd. 7.5 满城尽是Lookup 优点只有真正Lookup机制的时候才能体会得到。与JDK提供的ServiceLoader相比,NetBeans提供的Lookup可以有多个实例,每个实例都是有自己的缓存池。“Lookup就象一个缓存池,对象可以随意进出“。 Public interface ExtIcon extends Icon ,Lookup.Provider { Public void paintIcon(Component c,Graphics g,int x ,int y); Public int getIconWidth(); Public int getIconHeight(); Public Lookup getlookup();} Evaluation only. Created with Aspose.Slides for .NET 3.5 Client Profile . Copyright 2004-2011 Aspose Pty Ltd. 满城尽是Lookup(2) ExtIcon这个接口继承了lookup.Provider,这就表示这个类可以提供一个自己的lookup,这样就可以提供一个额外的功能,或者临时标记图标使之看上去具有某些功能。 Public static Image toImage(ExtIcon icon) { Image img=icon.getLookup().lookup(Image.class); If (img!=null) { Return img ; } bufferedImage buf=new BufferedImage( icon.getIconWidth(),icon.getIconHeight(), bufferedImage.TYPE_INT_RGB); icon.paintIcon(null,buf.getGraphics(),0,); return buf; } Evaluation only. Created with Aspose.Slides for .NET 3.5 Client Profile . Copyright 2004-2011 Aspose Pty Ltd. 模块化架构 7 第七 章 Evaluation only. Created with Aspose.Slides for .NET 3.5 Client Profile . Copyright 2004-2011 Aspose Pty Ltd. 操作系统及其之上的应用程序都是基于模块化的开发方式完成的。最终产品由独立组件组装完成,从而使得异地协作开发可以以相当可靠的方式进行。 随着复复杂度的提高,单个应用也在转向基于独立开发的块组装完成。达到此目的办法就是模块化开发。 Evaluation only. Created with Aspose.Slides for .NET 3.5 Client Profile . Copyright 2004-2011 Aspose Pty Ltd. 随着软件规模的增大以及功能复杂性的提高,越来越有必要将单个应用拆分为独立的块、组件、模块或者插件。每个这样的部件都是模块化架构的有机组成单元。每个部件都应该是独立的,并提供定义良好的对外接口供外部调用。符合此类标准的部件也称为模块。 简单的面向对象编程在某些方面类似于结构化编程确立之前的情况:一个

文档评论(0)

1亿VIP精品文档

相关文档