Tuesday, 24 April 2012

Enterprise Architecture Design

The best practice for Enterprise Architecture - NHibernate

Domain Driven Design 

Enterprise Notes


  1. Seperated Interface
    1. Also known as Dependency Inversion
      1. Technique for establishing a clean separation of concerns between application tiers.
      2. Often use for separating the Data Access Layer and the Domain Object.
    2. There are 2 ways to do this
      1. Same projects but separate by Folder named 
        1. Domain and Data folder
        2. Cons
          1. Layers shared a bi-directional dependency with each others.
          2. Can't prevent the dependency on each entity
          3. Difficult to do a unit test since the data access layer will depend on the real database.
            1. If include the database, it will slow down the test speed.
      2. Separate assemblies
        1. Project.Core or Project.Domain and Project.Data
          1. Project.Core
            1. Contains the domain object
            2. Data Access Object (DAO) Interface
          2. Project.Data
            1. Contains concrete implementation of DAO Interface
        2. Cons
          1. DAO can be a mock object for easy unit test.
  2. Dependency Injection (DI) or Inversion of Control (IOC)
    1. By doing the Separated Interface, the Domain Layer only known the interface
    2. DI will help to manage the concrete class for Domain Layer
      1. There are multiple IoC framework available
        1. Castle Windsor
        2. Unity
        3. NInject
        4. Autofac
        5. Structuremap
        6. Spring.Net
    3. Principle -  http://www.objectmentor.com/resources/articles/dip.pdf
  3. Design by Contract (DBC)
    1. Explained here -  http://devlicio.us/blogs/billy_mccafferty/archive/2006/09/22/Design_2D00_by_2D00_Contract_3A00_-A-Practical-Introduction.aspx
    2. And here -  http://www.codeproject.com/Articles/1863/Design-by-Contract-Framework

Defining the Domain Layer

  1. Separated the Interface and Implementation
    1. Design consideration for a unit test.
      1. Abstract Factory -  http://www.dofactory.com/Patterns/PatternAbstract.aspx
      2. Mock Object -  http://www.betgenius.com/mockobjects.pdf
  2. Collection Generic Examined
  3. Mapping to the database
    1. 2 ways
      1. HBM-XML files
      2. Attribute Mapping
  4. NHibernate support the stored procedure.

Defining the DAO Layer

  1. Able to retrieving the data from Stored Procs
  2. Handling the NHibernate Session
  3. DAO Explaination -  http://java.sun.com/blueprints/corej2eepatterns/Patterns/DataAccessObject.html 

NHibernate Performance Tuning

Reference:

Web:

No comments:

Post a Comment