Web Application Architecture

I was busy in a discussion of the architecture of an application.

Without going in any further detail we divided our application architecture (Arch) into the traditional three layers. But throughout the whole design of the application Arch that implementation should be separate from the communication between layers.

arch1.gif

I explain what I did with it.
 
User Interface

First of all to discuss the UI actually it depends on the technology you are using like I was on .Net then .Net provides the controller class in the form of aspx.cs, but it would be different in the case of Java.

In Java usually most architects use the Front Controller Pattern, but in the case of .Net we usually prefer the Page Controller Pattern. I will not delve into the detail of patterns because this is not our subject.

I am describing the front controller because I love this pattern to use. Because we have facilitated by the web Framework of .Net. Page control pattern should be used in every application; it reduces our calls from every instance, it takes care of all prevention that we have to do on every page.

arch2.gif

Like session, security, some cached object, most visited objects and all decision we have to take on most of the pages we promoted it into base controller. The Base controller will handle it. Now it's time to move onto the Facade thin layer.

Facade

As our focus on we want to separate implementation from its abstraction. Actually this is very important for us to know this rule. Everyone can implement their own; I do it on my own, some can do it according to his business needs and be better of it. But the rule should be the same; for now, we use FACADE because of we can call BAL or might be outside of our domain like web service etc.

So, the UI layer shouldn't be affected and free from this knowledge that where it gets data and what is the complexity or calling cost.

BAL (Business Access Layer)

The Business Manager contains all the business knowledge of the Application, Transactions ensures, maintain abstraction between UI and DAL. Architecture should have BaseManager which responsibility is control transaction, most frequently called methods actually this is contract between Façade and BAL so, FACADE doesn't know about the implementation of Managers. There is a question of whether the manager can have the same methods, then we have to make an interface for each manager just for separating it from the implementation because you can have two managers for the same purpose for any purpose, it provides you a flexibility to change your implementation according to your need and your application other part will also work.

In every BAL class there should be an implementation of a singleton pattern just for ensuring a single object and avoiding unnecessary objects on every call.

arch3.gif
 
Another good idea (it is something I read about) is the spring framework; this is excellent, it takes all the responsibility of making an object we just pass the object name and it creates it for us. The great thing of this framework is you can also define a dependency and it will create an object for you with all of its dependencies.

Great work!

Data Access Layer

Data Access Layer also the same rule we define an interface for every DAO. Every DAO should use a singleton pattern because otherwise there might be a huge amount of unnecessary object creation.

arch4.gif

To avoid this extra object creation, implement a singleton in every DAO.
 
This is BaseDao responsibility to control the internal transaction and all search criteria, Creation, Deletion and Updating method to avoid redundancy of the same implementation. It is possible to have object caching because it will avoid your round trip of the server each time and improve the performance of your application. The most important thing is to use this framework is work with objects rather xmlDataset. For Object Relational Mapping you can use:

  • Nhibernate
  • ORM Tool
  • Opf3
  • Entity Framework

To avoid creation of a Dao object every time in BAL you can use as I discussed earlier some Framework of Inversion of control I am discussing here the Spring Framework there is also another option you can use according to your requirement and ease of use.

So, this framework is responsibile to create, session and keep all its dependencies and return on calling correctly.

Up Next
    Ebook Download
    View all
    Learn
    View all