我只是想表态这个意思,所以就以单据作为例子,但大家认为各层之间应传递什么,只用dataset?

解决方案 »

  1.   

    各层之间具体用对象还是用一般的参数传递我想没有死的原则,
    但是在编程时一定要有面向对象的思路去编程(当然这首先要有好的面向对象的设计为前提)。比如说用户,在认证时你可以 Auth(string userID,string pwd),而不用Auth(User user),因为认证只要用到两个参数就够了,用户的其他属性根本用不到,而如果是增加用户的方法则可以用AddUser(User user),这样更清晰。我认为写中间层的时候最重要的一点是能够让类的使用者很方便的理解和使用。界面开发者应该可以不必知道具体的数据库设计,只要知道类的设计就可以进行页面开发。
    关于性能问题,面向对象的开发绝对没有面向过程的快,正像 seeyard(浣熊)说的,维护和扩展性非常重要,性能可以从硬件提升!
      

  2.   

    具体情况要看你是用asp.net还是传统windows桌面应用程序了
      

  3.   

    另外,在传统面向对象程序开发中,如果表单的对象是objOrder,那么增加该对象的方法应该包含在该对象中,如objOrder.Add(...)
      

  4.   

    cnuninet(骑马倚斜桥):
    我觉得应该是objOrder对象只包括order的属性,它的行为应该由一个管理类来操作,这样应该好一点
      

  5.   

    Returning business entity data from methods in the Data Access Logic Component.You can return the data in several different formats: as output-parametercalar values, as an XML string, as a DataSet, as a custom Business Entity Component,or as a data reader.这是ms 的介绍
    Passing Custom Business Entity Components As Inputs and Outputs
    The advantages of this option are as follows:
     Maintenance. Schema changes may not affect the Data Access Logic Component
    method signatures. However, the same issues arise as with typed DataSets if the
    Business Entity Component is held in a strong-named assembly.
     Collections of business entities. An array or a collection of custom business entity
    components can be passed to and from the methods.
    The disadvantages of this option are as follows:
     Supporting optimistic concurrency. To support optimistic concurrency easily,
    time stamp columns must be defined in the database and included as part of the
    instance data.
     Limited integration. When using custom business entity components as inputs
    to the Data Access Logic Component, the caller must know the type of business
    entity; this can limit integration for callers that are not using .NET. However, this
    issue does not necessarily limit integration if the caller uses custom business
    entity components as output from the Data Access Logic Component. For example,
    a Web method can return the custom Business Entity Component that
    was returned from a Data Access Logic Component, and the Business Entity
    Component will be serialized to XML automatically using XML serialization.
      

  6.   

    其实我觉得你的想法不错
    duwamish 和 petshop 其实都是这种结构
    duwamish 中 从DataSet继承了几个类 作为传递数据的一个结构。
    petshop 中 就时返回一些自己定义的类的实体如
    customer 的操作返回的就是 实例化的 CustomerDetails 
      

  7.   

    superkiller的说法,我觉得应该用dataset作为层之间的传输用,当然也可以是dataset的派生类。
      

  8.   

    实体类可以用“强类型的DataSet”来取代!