The Benefits of Building a Layered Application

May 9, 2009

4 comments

The Benefits of Building a Layered Application


During the last two weeks I’m consulting at a customer that built
a very simple application very badly. One of the problems that I found was
the lack of layers separation which made the application very tangled.
One example for that is the calling of stored procedures from UI user
controls. I talked to the managers about that issue and explained the
benefits of building a layered application. This post will explore those
benefits.


Layered Application Pattern


Before talking about the benefits first we need to understand what is
layered application pattern. The pattern is very easy. You separate the
application components to layers. The components in each layer should
be cohesive and should have very close related in their functionality. Each
layer should be loosely coupled to the layers that are below it.
The following figure shows layers:
Layers 
(the figure is taken form the Enterprise Solution Patterns Using Microsoft .NET
book)

The main subject in layers is dependency management. Every component
in one layer can interact with components in the same layer or components
from lower layers. There are many approaches to layers building but it won’t
be covered in the post. For more details you can read about the subject in
the following books:



  • Enterprise Solution Patterns Using Microsoft .NET

  • Patterns of Enterprise Application Architecture

The Benefits of Building a Layered Application



  • Other applications will be able to reuse the functionality exposed
    by your layers. 

  • You will be able to distribute your layers over multiple physical
    tiers. This can make a very good impact on your application by
    improving performance (sometimes), scalability and fault
    tolerance.

  • The maintenance of your application is easier because of the low
    coupling between layers.

  • Adding more functionality to your application is made easier.

  • Layers make your application more testable.

  • Building a well formed layers makes the orientation in your
    application more easier.

Summary


Lets sum up, the post explained what is the layered application pattern.
It also explored the benefits of building a layered application. Building
layered application can make your life easier. I encourage you to use the pattern.


DotNetKicks Image

Add comment
facebook linkedin twitter email

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

4 comments

  1. Ran WahleMay 9, 2009 ב 12:30

    There is one more benefit of using layered application regarding security.
    Each layer has it’s own security threats. For example – your data access layer has to deal with data access threats (i.e – SQL injection). Your presentation layer has it’s own threats (mainly regarding user input validation), your business layer has all sorts of security threats (differs from one application to another so I won’t provide an example here)and so on.

    Having your application not layered means that you have to deal with all security threats in one place which is very difficult. Having your application distributed to layers makes it much easier for design and implement.

    Reply
  2. Gil FinkMay 9, 2009 ב 12:56

    Well written Ran.
    Security is a very important benefit that I forgot to mention.

    Reply
  3. Arnon Rotem-Gal-OzMay 9, 2009 ב 21:53

    “You will be able to distribute your layers over multiple physical
    tiers” – This is a very dangerous assumption
    you can’t just take layers and distributed them if you didn’t plan for that since arbitrary tier splitting doesn’t take into account the fallacies of distributed computing

    Reply
  4. Gil FinkMay 9, 2009 ב 22:32

    Thanks for the comment Arnon.
    This wasn’t an assumption. I agree with what you wrote. Without a good deployment plan it is not trivial to distribute your layers over multiple physical tiers in distributed computing. You need to plan ahead your layers when you create a distributed application.

    Reply