Wednesday, July 18, 2012

Where should business logic reside in a website?

In my experience, there have been more advantages than drawbacks of having business logic in the web/wcf application instead of having it inside stored procedures.

Advantages of having business logic in the application:
1> Compared to SQL server, it is easier to scale a web application (through use of load balancers for example).
2>Debugging with break points is a lot easier in a web application.
3>If you have multiple database servers, then web application can be a common location for all business logic.
4>Application code is a lot easier to integrate with source control.
5>You can apply sophisticated design patterns on your business code, thus leading to a more maintainable and scalable business code.

Advantages of business logic in a stored procedure:
1> If the data manipulation is done in the database and only the final result set is passed to the application, network load can be greatly reduced. This is particularly true if you have to sift through Giga Bytes of data (reporting applications for instance) before presenting the end result to the user.
2>Performance tuning is easier.

No comments:

Post a Comment

Comments will appear once they have been approved by the moderator