eXpressApp Framework 之DC技術入門系列(1)

來源:互聯網
上載者:User

好久沒有寫部落格了,一個是工作忙的原因,二一個就是自己這兩年的生活方面發生了太多的事情,導致自己沒有精力寫,最近,隨著Devexpress公司的ORM架構工具XAF v20011.1的即將發布,隨XAF的一個新的技術----DomainComponent(下文簡稱DC)也將正式發布.

以前我們用XAF開發實體物件的時候,用的最多的就是Domain Object(下文簡稱DO),但是,我們在使用的過程中會發現,DO有明顯的局限性,比如在拓展複用方面就很是不盡如人意,特別是DO不能脫離XAF運行,這給我們的實際開發帶來了成本方面的困擾,而DC在這方面就做了非常大膽的嘗試,下面我們來瞭解下DC技術.

在這系列文章中,我將全部盡量使用DC技術進行介紹其使用方面的入門知識,並將會以一個簡單採購系統作為介紹切入點,用執行個體讓大家感受下DC能給我帶來怎樣的震撼

注:更多的詳細資料,大家可以訪問Devexpress 的官方網站http://www.devexpress.com/去瞭解,官網可以下載到xaf的30天試用版本,聲明:提供此資訊只是為了方便感興趣的同行,僅此而已.

本次我們先來瞭解什麼是DC?看看官方是怎麼定義的:

Domain Components technology is designed to simplify data management and
reusability by providing a much more flexible and abstracted approach to
business object design. You can compose an application from reusable blocks,
abstracted away from a particular persistence layer.

With Domain Components you define interfaces instead of regular business
objects inherited from XPO classes. These interfaces will declare required
properties or data fields. The way this data is to be processed ( Domain Logic)
is then defined by creating special classes that determine how interface members
behave when an object is constructed, when properties are changed, etc. Actual
business classes are automatically implemented by XAF at runtime based on the
provided logic and interfaces. You can package interfaces and domain logic in an
assembly, and use it as a domain library. If you then create a new XAF
application, you can reference the domain library and reuse domain components.
Since interfaces support multiple inheritance, required business objects can be
combined into new domain components. With interfaces you can make your domain
model independent of implementation.

Benefits of the Domain Components Technology

Domain Components Technology is not by any means a replacement for the
regular business classes approach for defining
domain entities. The main advantage of the technology is the ability to create
reusable domain libraries containing components that can be combined in any way.
If you do not need the ability to create reusable components and combine them,
most probably you will not need to use Domain Components. The following list
describes the benefits of the Domain Components technology and should help you
decide whether or not the approach is right for your task.

  • You can create reusable domain libraries.

    Most likely, each new XAF application you develop is not unique. The most
    common objects, such as Person, Phone, Address, etc., are always used. The Business Class Library provides you with
    a set of classes that you will need most frequently. But implementing your own
    reusable library is not a simple task. With Domain Components you can easily
    package an assembly and reference it in your applications.

  • You can use multiple inheritance.

    Since Domain Components are represented by interfaces and not by classes, you
    can use multiple inheritance to combine several previously defined components
    into a new one. The new Domain Component will expose the properties of all its
    ancestors and utilize their Domain Logic. Of course you can add new properties
    and apply additional logic.

  • You do not need to inherit from Base Persistent Classes when implementing
    Domain Components.

    Each regular business class is derived from one of the Base Persistent Classes in XAF. The
    behavior of these classes differs. For instance, a base class can either expose
    an auto-generated primary key property of an integer or Guid type, or not. The
    choice of the base class is made once a class is implemented. With Domain
    Components, you can use a specific base class in each new scenario (see the ITypesInfo.AddEntityToGenerate
    method overload that takes the baseClass parameter). However, attributes
    applicable to regular business classes and their properties can also be used
    with Domain Components. And of course, an object implemented via Domain
    Components does not differ from an object implemented in a standard way from the
    end-user or application administrator point of view.

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.