`
C_J
  • 浏览: 128910 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

Design Model in 2008

阅读更多
高聚合,低偶合

为了降低对象之间的耦合度、增加灵活性,于是有了设计模式
设计师们不断地寻求一种复杂度更低的

对struts的优化,定义接口如下:
//ResultSet to Bean
public void ConvertRStoBean(Connection con,ResultSet rs,Map para,_RootBean goal);


public void ConvertRStoBean(Connection con,String sql,Map para,_RootBean goal);

//ResultSet to List
public ArrayList ConvertRStoList(Connection con,String sql,Map para,String className);


基本模块设计原则:
    1,高聚合:一模块与其他模块之间没有过多的相互作用
    2,规模适中:单个模块的成本与系统总成本成反比
    3,上下层模块的低耦合:上下层模块之间的影响关联度以及扇入扇出原则



MVC设计原则
M重点在于高内聚和低偶合

C提倡灵活性,定义框架,讲究重用性

目前我对优秀框架的判断标准是:对需求变化的快速构架能力

面向接口和面向切面
面向接口:它是比abstract更抽象的概念,关心的不是具体实现而是更强的扩充性和偶合度,一个设计方法你甚至找不到它的具体实现,这是面向接口的一个境界。

面向切面(AOP):对于非核心且烦琐的业务(如日志,事物等等),为了讲究重用性,把这些片面业务的实现抽象为一个模块,从而省去了大量繁杂的工作,让开发者专注与核心业务的开发。
    另外,引入了IOC思想,即对象的周期和对象之间的关系统一由另一容器来构件和管理,并可实现“动态绑定”。


   
23种设计模式:
看了 cbf4life大哥的写的设计模式,挺生动的。在这里写下我的简要理解。

1,策略模式(Strategy Pattern)
   策略接口------>N多策略实现
    执行者------->调用策略接口,并不关心用何种策略,可以有某种“选择机制”,组合关系

2,代理模式(Proxy Pattern)
    实现者------->做自己该做的实现
    代理人------->只接客,但不执行,给相应实现者,在外人看来,是代理者在执行,其实它只是一个“空壳”。(注意代理人和实现者需同一个interface(问题)),组合关系。
    执行者------->调用代理人为自己办事

3,单例模式
4,多例模式  这两个就不说了

5,工厂模式(Factory Pattern)
    一个工厂-------用于生产对象实例
     产品实现-------各种需要生产的产品
     产品类别-------各类产品接口
     执行者 --------通知工厂我需要什么产品,并提供规格说明书(这里有种方法可以由已知的interface找到所有实现class)

6,抽象工厂模式(Abstract Facotry Pattern)
    一个工厂--------用于生产对象实例
     多个部门--------为了适应复杂的对象构造结构,可能产品有方的,或者圆的(抽象类还是实现类,看具体应用)
     A类产品实现-----属于A类的产品所有产品(可能定义为abstract class,class)
     A类产品接口-----A类产品接口
     B类产品实现-----属于A类的产品所有产品(同上)
     B类产品接口-----A类产品接口
     ......
    执行者----------调用工厂,提供规格说明书(说明书里标明产品说明,工厂根据说明内容自动匹配叫哪个部门生产,所以单例+参数能解决这个缺点)

7,门面模式(Facade Pattern)
    实现者----------这个家伙很累,需要实现A,B,C,D....并不强调执行顺序
     实现者接口------实现类的接口
     守门人-----------这个人告诉实现者要做事了,做完后把结果告诉他,守门人叫实现者实现
     执行着-----------告诉守门人该做事,并告诉守门人这件事为谁而做
组合关系

8,适配器模式(Adapter Pattern)
    A类接口---------A类,注意Adapter是适用于不同接口中共用问题的,可能涉及到两个不同子类系统的大类系统中。
     B类接口---------B类
     一个适配器-------主要作用是把A类接口伪装成B类接口,在B类系统中当作B类对象来操作就OK了。
    不符合原有设计的时候才考虑通过适配器模式减少代码修改带来的风险。
   
9,装饰模式(Decorator Pattern)
     原始接口——————
     装饰接口——————
     装饰实现——————构造函数传递基类对象,这里是组合关系

     装饰模式解决“灵活性差”和“主体类在多方向上的扩展问题”,组合关系,对继承关系的补充,可动态地指定扩展功能。
     Son son =new AASon();
    son =new AADecorator(son);
    son =new BBDecorator(son);
son同时具有了AAD BBD两个扩展功能。

10、命令模式(Command Pattern)
    做事接口——————
     做事者——————A,B,C....
    总头头————————定义了很多做事着
     头头————————A类人的头,B类人的头,C类人的头...
    对客户的接口—————接收要谁做事
     客户—————————定义谁做事,给接口
组合关系

附录:
根据完整类名创建对象
public   class   CJMethods   {  
        public   static   void   main(String   args[])   {  
                try   {  
                        Class   c   =   Class.forName(args[0]);  
                        Method   m[]   =   c.getDeclaredMethods();
                        Field[] fieldArray=className.getDeclaredFields();

                        for   (int   i   =   0;   i   <   m.length;   i++)  
                                System.out.println(m.toString());  
                }   catch   (Throwable   e)   {  
                        System.err.println(e);  
                }  
        }  
  }  
分享到:
评论

相关推荐

    MaterialDesignInXaml.Examples-master.zip

    作为WPF开发的常见模式,Model-View-ViewModel (MVVM)在MaterialDesignInXaml库中得到了很好的支持,这使得代码与界面分离,更便于维护和测试。 10. **学习资源** 通过研究这个压缩包中的例子,开发者不仅可以...

    The business model ontology a proposition in a design science approach.pdf

    ### 商业模式本体论——设计科学方法中的一个提案 #### 背景与研究环境 本文档源自亚历山大·奥斯特瓦尔德(Alexander Osterwalder)的博士毕业论文,他是《商业模式画布》一书的作者。这篇论文主要探讨了在设计...

    Model Predictive Control, Theory, Computation, and design(James B. Rawlings)

    Model Predictive Control:Theory, Computation, and Design,2nd Edition. James B. Rawlings, David Q. Mayne, Moritz M. Diehl. Chapter 1 is introductory. It is intended for graduate students in engineering...

    Model+Predictive Control System Design and Implementation Using MATLAB

    《Model Predictive Control System Design and Implementation Using MATLAB》这本书全面地介绍了MPC的基本概念、最新进展以及如何利用MATLAB进行模拟和实现。 #### 二、MPC的特点与优势 1. **设计公式化**:MPC...

    Trade off and Optimization in Analog CMOS Design

    An interpretation of MOS modeling for the analog designer, motivated by the EKV MOS model, using tabulated hand expressions and figures that give performance and tradeoffs for the design choices of ...

    Model Predictive Control System Design and Implementation Using MATLAB

    Model predictive control (MPC) has a long history in the field of control engineering. It is one of the few areas that has received on-going interest from researchers in both the industrial and ...

    Go Design Patterns

    Go Design Patterns will provide readers with a reference point to software design patterns and CSP concurrency design patterns to help them build applications in a more idiomatic, robust, and ...

    Domain-Driven Design (Tackling Complexity in the Heart of Software

    领域驱动设计(Domain-Driven Design,简称DDD)是一种软件开发的方法论,它由Eric Evans在其2004年的同名书籍《领域驱动设计:软件核心复杂性应对之道》中提出。DDD的核心思想是,软件系统的复杂性不仅仅是由技术...

    Handbook of Model Checking

    course in Model Checking. If a reader can verify that he or she has read and studied every article, then Springer should certainly award that reader a Master’s Degree inModel Checking! Departments in...

    Mobile Game Design Essentials

    Immerse yourself in the fundamentals of mobile game design. This book is written by two highly experienced industry professionals to give real insights and valuable advice on creating games for this ...

    Design and Realization of Position Controller Based on Characteristic Model

    The recursive least square (RLS) algorithm is used to identify time-varying parameters in characteristic model. The position controller is constituted by an adaptive equivalent controller based on ...

    Machine Learning Design Patterns

    "Machine Learning Design Patterns" 《Machine Learning Design Patterns》是一本关于机器学习设计模式的书籍,作者是Valliappa Lakshmanan, Sara Robinson和Michael Munn。该书的主要内容是解决数据准备、模型...

    Model Checking-Edmund M. Clarke-模型检查PDF

    Also, if the design contains an error, model checking will produce a counterexample that can be used to pinpoint the source of the error. The method, which was awarded the 1998 ACM Paris Kanellakis ...

    Model_Predictive_Control_System_Design_and_Implementation_Using_MATLAB_2009

    标题中提到的"Model_Predictive_Control_System_Design_and_Implementation_Using_MATLAB_2009",很可能是2009年发布的关于使用MATLAB软件设计和实现模型预测控制系统的指南或教程书籍。这本书籍可能详细介绍了如何...

    Domain-Driven Design Complexity In Software.pdf

    ### 域驱动设计(Domain-Driven Design, DDD):应对软件核心复杂性 #### 概述 《域驱动设计:应对软件核心复杂性》一书由埃里克·埃文斯(Eric Evans)撰写,Addison Wesley出版社于2003年8月20日出版。该书共560...

    Radio Frequency Integrated Circuit Design

    Frequency Effects 49 as a Function of Current 51 3.6.1 f T ...in the Transistor Model 55 3.10 Bipolar Transistor Design Considerations 56 3.11 CMOS Transistors 57 3.11.1 NMOS 58 ...

Global site tag (gtag.js) - Google Analytics