Introduction
This document describes the details of four tier implementation of the new architecture.
The scope of this document is demonstrating the four tier implementation of the new architecture.
This document is primarily targeted for the developers and architects working on the Veriphy applications. It provides a useful perspective to other stakeholders such as managers, and the customer.
Overall Description
· The client workstation represents first tier that uses a browser application to interact with the Web server.
· The Web server represents a second tier that contains the presentation layer, which is responsible for handling requests from the user and interacting with the business layer to implement the request.
· The application server represents the third tier with service, business, and data access layers.
· The fourth tier in this design is the database server.
Tiered Diagram
· Browser interaction with the Web Server uses standard HTTP GET and POST requests.
· The presentation layer uses a request-based / message-based protocol to interact with the service layer.
· The Service Layer uses a Facade call to interact with the business layer.
· Stand-alone ASP.NET Web application that supports basic CRUD operations.
· Presentation and Business logic are distributed across physical boundaries.
· DAL implementation will be implemented using LINQ.
· The application uses data from an existing database schema.
· Tables and views in the database define data structures used by the application
Another View
Detailed Tiered/Layered
The following is a summary of the patterns used by this scenario:
· User interface processing is handled by a Request-Response pattern.
· The user interface is composed of multiple controls, with some that can be bound to data elements.
· An Http-Get request / Proxy is used to communicate between the presentation layer and service layer
· The Data Transfer Object (DTO) pattern is used to package multiple data structures into one.
· The Service Layer provides translation between internal and external data structures.
· The Business Layer uses a façade pattern to support coarse-grained message-based operations.
· Transactions and Business Logic are managed by objects in the business layer.
· Business entities are defined using the Table Module pattern (LINQ).
· The Table or Row Data Gateway pattern is used to provide a data access interface.
· The Query Object pattern is used to support the generation of SQL queries.
Technical Details
Client Workstation
Target browser is Internet Explorer 6.x and higher
|
Browser will initiate the further flow.
|
Web Server
ASP.NET Page Control
|
ASP.NET Page controls are used to define each page of the web application.
Standard ASP.NET page processing is used to handle control events.
|
Composite View
|
Page, server and user controls represent a Composite View.
|
Bound Data Control
|
Control that can be bound to a data structure, which is used to provide data displayed by the control.
|
Proxy
|
Provides a local interface used to interact with services on the application tier.
Adding a service reference will generate classes used to interact with the service. From a coding perspective the proxy provides a local interface that hides details related to interaction with the service.
Proxy is used when the presentation layer is required to communicate using WCF contracts.
|
Application Server – Service Layer
Service Interface
|
The service layer can be Class Library Project or could be defined using WCF service, data, message, and fault contracts.
Operations exposed by the service are application scoped. For example, instead of providing multiple operations to return demographic information you would provide one operation that returns all data related to demographic information.
|
Data Transfer Object
|
Used to combine multiple data structures into a unified view that can be passed across physical and logical boundaries.
|
Entity Translator
|
Implement an object that transforms message data types to business types for requests and reverses the transformation for responses.
Classes that provide operations to translate between business entities and WCF data contracts.
Translate DTO to Business Entity Objects.
Public LINQ.DataManager.Order TranslateOrderToOrderDTO();
|
Application Server – Business Layer
Façade Interface
|
The business layer implements a façade with coarse grained operations.
Implement a unified interface to a set of operations to reduce coupling between systems.
An Interface type is used to define the façade interface.
The Façade acts as a boundary that catches all unhandled exceptions that may occur when processing business operations.
public interface BusinessFacade
{
Data.Order GetData();
int SaveData(LINQ.Data.Order businessEntity);
bool DeleteData(int businessEntityID);
}
|
Business Process Objects
|
Business process objects are used to handle requests made to the business layer.
Business process objects allow you to Implement Business Rules And Provide Transaction support if required.
Business operations that need to be included in a transaction are combined in a single operation exposed by a business process object that implements the transaction script pattern.
public bool SaveData(LINQ.Data.Order businessEntity)
{
string sError = string.Empty;
bool success = false;
int orderId = -1;
try
{
BeginTransaction();
if (orderId == -1)
{
orderId = LINQ.DataManager.FindNextOrderID();
if (orderId == -1)
{
sError = "Failed to retrieve new Dealer ID. Rolling Back Transaction";
RollbackTransaction();
return success;
}
orderId = LINQ.DataManager.InsertOrder(businessEntity);
if( orderId == 0)
{
sError = "Failed to insert Dealer ID. Rolling Back Transaction";
RollbackTransaction();
return success;
}
}
CommitTransaction();
success = true;
}
catch (Exception ex)
{
RollbackTransaction();
}
return success;
}
|
Application Server – Data Access Layer
Table Module / Business Entities
|
Business entity that represents a table or view within a database and provides operations to interact with the table or view.
Business rules are not implemented within the business entities.
The business entities are just data containers. Business rules are handled by business processing components.
|
LINQ DataManager
|
Separate classes are used to define LINQ query objects.
It behaves like a gateway object - defined for each business entity in the design.
The gateway encapsulates all logic related to interacting with the associated DB table or view.
public int InsertOrder(LINQ.Data.Order order)
{
order.InstitutionID = _institutionId;
_dataContext.Orders.InsertOnSubmit(order);
_dataContext.SubmitChanges();
return order.OrderID;
}
|
Database Server
SQL Server DB
|
Tables and views are accessible to the Data Access Layer using LINQ ORM.
|
Hope this helps.
Thanks & Regards,
Arun Manglick
This is awesome!! really helpful for me. Thanks for sharing with us. Following links also helped me to complete my task.
ReplyDeletehttp://www.codeproject.com/Articles/439688/Creating-ASP-NET-application-with-n-tier-architect
http://www.mindstick.com/Articles/d36ceb0f-018c-4979-b2f5-a4a1e616cb5b/default.aspx?N+Tier+Architecture+in+ASP+NET