Search the articles  
  

• Structuring .NET application architecture

Monday, August 03, 2009

download :
1) Christopher Thant's Application Architecture (PDF)
2) Ready to use sample project (Visual Studio 2005)
3) Microsoft's Application Architecture (PDF)

Application Architecture

The core architecture of my web applications is designed based on layer model which can also be adapted to all kind of web and window applications.

In approach to engineering the core architecture, Microsoft’s proven theory of pattern and practice factory class models are constructed and molded on top of the existing layer model.


By having different layers in implementing the core architecture, it provides the advantages of
- Flexibility to reuse the existing controls, modules and codes
- Easy Maintenance
- Rapid Development
- Security Enhancement

Data Object Layer
Namespace : CHRISTOPHERTHANT.WEB.DO

Data object layer represents a logical presentation of physical database tables. One data object can represent one database table and map all the database table fields with appropriate .Net data types. Relational model between multiple database tables can also be desingned in each data objects by embedding one data object into another and relating different data objects.

Relational model of data objects in data object layer also decides capability to providing business requirements. If necessary, logical data object can be created without needing to create a new database table, and then defined appropriate relationship with other data objects.

Example : the following data object relationship can provides multi shipping and multi merchant.


All the data object classes are inherited from BaseDO class in which fundamental methods are defined. The definitions of enum data type can also be defined in BaseDO class.


The most fundamental methods defined in BaseDO class are
1. IsDirty
IsDirty method determines whether inheriting data object is currently in use or not.
2. ModifiedBy
ModifiedBy method is a basic data field for every data object to accept the name of user who modified the data.
3. ModifiedDate
ModifiedDate is the date that data is modified
4. Clear
Clear method clears and reset the currently existing data value from IsDirty, ModifiedBy and ModifiedData method.

Data Access Layer
Namespace : CHRISTOPHERTHANT.WEB.DAL

Data access layer is a place where actual database store procedure calls take place. Basically, each potential business modules can have one or more data access files, and those data access files can reference to one or more data objets from data object layer.

For example:
Order module has OrderInfoDA and OrderDetailDA data access file.

OrderInfoDA data access file references to OrderInfoDO, OrderInquiryDO.
OrderDetailDA data access file references to OrderDetailDO, ShipDetailDO, MessageDO.

Business Layer
Namespace : CHRISTOPHERTHANT.WEB.BL

Business layer provides data returned from data access layer and has only standard data sources and raw data for business needs. Data in business layer are unclean, unformatted and not ready yet to easily plug into the application layer, but all the data required for application layer are loaded into business layer.

Suggested practice in business layer is to have one business layer file for one business module in order to avoid complication but maintain the standard business rules.

For example, order module should have only one business layer file, i,e OrderInfoBL. One business layer file can call methods from multiple data access layer files and also reference to multiple data objects.

Module Factory Layer
Namespace : CHRISTOPHERTHANT.WEB.ML

Module factory layer is an application oriented layer and designed to minimize the codes required to include in the application layer. Instead of application layer directly access to data object layer, data access layer and business layer, module factory layer intercepts between application layer and business layer, and guarantee the application layer that if only the provide clean, secured and reliable data sources for the whole application.

Module factory layer is also tied to the application and only necessary business modules shall be included in the module factory project library. Each business modules can be accessed through proper factory class model. The purpose of having factory classes to access to the required data source is that if the data object is already crated for the requested data source in the memory, it won’t create the duplicated same data object in the memory again and return the existing data object.


Physical file structure of module factory layer

Classes in module factory layer are inherited from BaseObject static parent class. All the potential common methods shall be defined in BaseObject static class, and so it can be called from either inheriting class or call the method independently as BaseObject.MethodName().

As module factory layer is application oriented, it is required to have the ability to access to the application configuration setting which is defined in different application project. In order to obtain the necessary configuration data from another application project, interface for site configuration class is defined and cast the methods from inheriting site configuration class.


Application Layer
Namespace : CHRISTOPHERTHANT.WEB.UI

Application layer has the following group of functionalities
- GUI layouts
- Graphics
- Animation
- Control components
- Events
- Manipulation
- Business logics
and each functionality has to specifically implement stage by stage.

Model-View-Controller (MVC) structure in the application layer is


.Net 2.0 web application will have three fundamental built-in primary level controllers; MasterPage, UserControl, and Page. Each controller should also reproduce second level BaseMasterPage, BaseUserControl and BasePage custom classes. Having those base custom classes ensures the application that certain type of methods, objects, and business rules are in one single place, and it can be used by all inheriting classes.

Those base classes also have interaction with module factory layer, and create module factory objects.

Sample for BasePage class:


download :
1) Christopher Thant's Application Architecture (PDF)
2) Ready to use sample project (Visual Studio 2005)
3) Microsoft's Application Architecture (PDF)

2 comments:

Anonymous said...

This is great!

U Ba Kaung said...

Matt. I totally agree.

Post a Comment