In redesigning and redeveloping Tapovanam's (my friend's organisation) web site, I want to put in place a good architecture. The following are some of the considerations:
- A multi-tier design (mainly to separate presentation code from business logic)
- Support themes in presentation layer to switch designs easily at later stage.
- Object oriented business logic layer (BLL) (with business objects)
- Data access layer (DAL) to be independent of underlying database (to switch databases or even use XML files as data store at a later time)
- Data Transfer Objects (DTO) to pass data between BLL and DAL
- Maximum use of Data Binding at the presentation layer
Following are few ideas in mind at this moment to solve the above problems:
Presentation Layer - ASP.NET Web Forms
Business Logic Layer - C# business objects having all the validation logic and an abstracted view of underlying data schema.
Data Access Layer - C# data access classes to retrieve and store data in data transfer objects
Plug-in model for Data Access
To be able to change or use multiple data stores with least effort, the Data Access Layer will use the Provider Model design pattern.
An abstract base class containing common data access methods like ExecuteNonQuery, ExecuteReader will be used. This methods in this abstract base class serve as Helper methods for data access. (similar to Data Access Application Block in Enterprise Library). This could be named as DataAccess
For each module in the web site (Eg.. Photos, Events, Commentaries), an abstract provider class and a concrete class is created.
The abstract provider class will have abstract CRUD (create, retrieve, update, delete) methods which will be implemented by the concrete class. For example, GetPhoto(), GetPhotosByCategory() etc. This class is data store agnostic. This could be named as PhotoProvider
The concrete class will have the data store specific method implementations defined in the abstract provider. This could be named as SqlPhotoProvider
Data Transfer Object
To transfer objects with data between BLL and DAL, separate classes are created. For example, PhotoDetails class to store the Photo record obtained from data store. Using un-typed DataSets as DTOs is problematic when it comes to maintenance (spelling mistakes are a pain)
A collection (like List<T>) of DTOs is used to pass a set of retrieved data from data store to BLL.
Object Oriented BLL
The business logic layer consists of C# classes that represent the business objects. These classes have all the validation logic, business logic and methods that talk to the DAL. These classes also use the respective Data Transfer Objects to pass and retrieve data from DAL. These classes can be named like Photo, Event etc.
DataBinding in Presentation Layer
To databind UI components like ListView, GridView, DetailsView etc. the ObjectDataSource controls are used in the aspx pages. The ObjectDataSource controls use the Business Objects in BLL and facilitate as binding adapters between the aspx page and business objects.
Other considerations include :
- Using all the existing ASP.NET built-in Provider services like Membership, Profile, Health Monitoring and Personalisation
- Using Enterprise Library's Data Access, Exception, Logging, Security blocks.
- Pay-pal integration for e-shop
- Globalisation and Localisation to display web site in Indian Language
- Content managed pages (allow contributors to compose and publish pages)