Separating Your Concerns- Antidote to Smart UI

Separating Your Concerns

An antidote to smart UI antipattern is the notion of Layering your applications.

Layering an application is a form of separation of concerns and can be achieved via namespaces,folders or with Separate Projects . Below Figure shows Typical
ASP.NET enterprise level Layerd Architecture

Let us rewrite the code which we have written in SmartUI Antipattern.. aligning to Seperation of Concerns…which we have discussed above…

Refactoring to the principles.. lets start coding…!!

  • Create a new blank solution in Visual Studio and name it ASPPatterns.Chap3.Layered
  • Add a new class library project to the solution by right-clicking the solution name and selecting Add ➪ New Project. Name the new project ASPPatterns.Chap3.Layered.Repository .
  • Add a further three class library projects to the solution named:
  • 1. ASPPatterns.Chap3.Layered.Model
    2. ASPPatterns.Chap3.Layered.Service
    3. ASPPatterns.Chap3.Layered.Presentation

  • Add a new web application to the project by selecting Add ➪ New Project and selecting the Web Application Project. Name the project ASPPatterns.Chap3.Layered.WebUI.
  • Right-click on the ASPPatterns.Chap3.Layered.Repository project and add a project reference to the ASPPatterns.Chap3.Layered.Model project
  • Right-click on the ASPPatterns.Chap3.Layered.Service project and add a project reference to the ASPPatterns.Chap3.Layered.Repository and ASPPatterns.Chap3.Layered
    .Model projects
  • Right-click on the ASPPatterns.Chap3.Layered.Presentation project and add a project reference to the ASPPatterns.Chap3.Layered.Model and ASPPatterns.Chap3.Layered
    .Service projects
  • Right-click on the ASPPatterns.Chap3.Layered.WebUI web application and add a project reference to the ASPPatterns.Chap3.Layered.Model, ASPPatterns.Chap3.Layered.Service,ASPPatterns.Chap3.Layered.Presentation, and ASPPatterns.Chap3.Layered.Repository projects
  • This is how solution looks like…

in the Smart UI Application, we have written Business logic in the Presentation layer itself..

Now we will separate this..All domain related stuff goes in to ASPPatterns.Chap3.Layered.Model ..

will start coding in next blog.. tune in folks .. lots and lots of new stuff is going to come…

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s