Friday, January 8, 2010

What are the benefits of a layered architecture when building ASP.NET app?

In other words, why should I use one? I currently build my apps with all data/business logic in the code behind. What are the advantages?What are the benefits of a layered architecture when building ASP.NET app?
A layered architecture in ASP.NET or any language makes you application much easier to maintain, expand and scale. For example if you ever needed to change that database your application uses, or even upgrade to a newer version of the existing database, it will be much easier to make this change if all your data access code is in one place instead of spread across all the page code behinds. In an even more dramatic example you may decide for scalability reasons to move all your data access code to an entirely different server, this would be really hard to do if data access wasn't in it's own layer.





You can run into similar issues with business logic. For example you may have a series of business rules that are checked when some data is entered through a web page. Later on you may need to provide an external interface through a web service, or batch import for entering that same data. Having the business logic in it's own layers allows you to apply the same logic to both interfaces.

No comments:

Post a Comment