Click here to Skip to main content
15,889,216 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
HI All once again,

In our company we are dealing with big ERPs and Payroll systems. Now a days we have an argument about to have a business logic in a different class in vb.net or it should be in a SQL side.

I believe this part is all about database so all the business logic should go to stored procedures and sql functions where my other mates say that everything should be in a vb class.

Now in this situation I think we need your suggestions. So please advice on this.

Have a nice day...!!!
Posted
Comments
Muralikrishna8811 27-Mar-12 11:37am    
Hi,

As per my Exp ...

Based on that Logic we need place it either SP or Component(class).

If logic has feasibility to develop in SP (Sql ) then we can place it in SP
some Logic has based on external entities so obviously we go for Component.

Finally Logic place is not important ...

That Logic must have certain features like feasibility ,re-usability,upgradabilty ....

This is a great debate/conversation, and I have been a part of it several times myself as well. I can honestly say there is no 'right' or 'wrong' in my opinion (OK maybe there is but let me be a little PC here as to not to offend those DB folks right from the start), but only 'pros' and 'cons' to each method. I think both have their advantages and disadvantages, and no option really screams out as the obvious choice on the surface unless there is say some significant performance advantage one way or the other. However I have my bias on 1 side of the argument as I will detail below.

The default stance in designing an application should be that business logic is held in the application code, NOT in database stored procedures. Only move business logic into StoredProcedures as performance needs required.

In my opinion, StoredProcedures should only be used for some operation that many different applications and/or languages need. If many different apps have or will have the same need, then consider factoring it to a stored procedure. You can't readily do this with app code because different languages would need re-coding for themselves.

http://allen-conway-dotnet.blogspot.in/2012/02/should-i-place-my-business-logic-in.html

http://c2.com/cgi/wiki?BusinessLogicInStoredProcedures
 
Share this answer
 
v2
Hi,

This is just my opinion:

Business logic should be in the "Business Logic Layer", a single class seems ridiculous though, you should have an entire BL project(s) depending on the size of your application.

Whenever I have Business Logic I put it there, so I know, even 2 years later, that it should be there and only there, that's why the BL exists in the end so...

But there are exceptions to that rule, the most important is performance. If you are critically loosing performance by putting some business logic there instead than on the database, then you might consider making an exception, but as any exception it should remain an exception.

As I said, that's just how I do it, I may be totally wrong.

Hope it helps.

[Edit]

You would usually have something like this:

UI (User Interface) -> BL (Business Logic Layer) -> DAL (Data Access Layer) -> SP (Stored Procedures, this is optionnal)

As it's name says, the Business Logic Layer is for... Business Logic :)
This is a three tier architecture.

[/Edit]
 
Share this answer
 
v3
Comments
hiren soni 28-Mar-12 2:11am    
Thanks a lot for your reply Zorro,
Yes you are right we have the architecture exactly like this

UI (User Interface) -> BL (Business Logic Layer) -> DAL (Data Access Layer) -> SP (Stored Procedures, this is optionnal)

But our argument is again about this SP which you said is optional. But I think we will end up with mixture of both, few will go in class and few will stay in stored procedure.
_Zorro_ 28-Mar-12 3:44am    
If your question is about using Stored Procedures or not, then that's your decision. You should look for pros and cons and analyze which is the best option in your situation. I personnaly would usually use SPs, mainly for performance reasons.

Instead, if your question is shoul I put the logic in the SP or the BL? Always the BL when possible.
I think the data layer i.e. should contain the procedures for exhaustive data access. The Data access layer on top of data layer should provide the applcation specific data access logic. and the Business logic layer on top of Data access layer should contain business specific logic.

Imagine 2 scenarios 1, where Data access layer is not coded and an ORM is used then the business specific logic will be in BLL (perhaps using linq). second scenario is where underlying data technology needs to be changed (like sqlserver to mysql) then you dont have to rewrite applicatin specific logic since it is still in BLL.
 
Share this answer
 
Comments
[no name] 28-Mar-12 11:08am    
SPs are not really a Data Layer...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900