The company I'm working for is currently using Stored Procedures (in the MsSQL server backend) as their Business Logic Layer. The actual Business Logic DLL just calls the sProcs and basically manages the UI (events, data binding, etc.)
I think there's something wrong in the setup, although I'm not sure how to explain it to my colleagues. Btw, the system works.
Is the "Best Practices" in my workplace wrong? Or am I just overthinking this?
"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. "
T-SQL Stored Procedures (SPs), along with some views and functions, are a useful way to encapsulate and implement most of an application's business logic, especially that which retrieves the underlying data from the tables (master or transaction), and/or updates it.
Stored procedures handle large quantities of data much better; in fact EF has some limitations on how much data can be handled.
Stored Procedures can also act as an additional security layer. We pass data as a parameter in a Stored Procedure so SPs avoid SQL injection. We can also implement a security model on SPs rather than tables or views.
GaiusSensei - it's perfectly fine to work in that way as long as the business domain is able to handle seismic shifts in business practices. i think the debate is still rife between SP's and BLL dll's and no doubt, there will be plenty on both sides in this thread. However, from my own experience over a range of projects in the past 10 years, here are my observations supporting the BLL dll approach:
The list goes on but, these are my top of the head PROS for adopting a BLL approach.
Looking fwd to the many spins on this one :)
jim
[edit] - i'd also add that this BLL should NOT emit any UI information either, other than (as you mention) to convey events etc. each UI layer (relevant to the target device -browser/mobile device/factory) should reference the BLL and do it's own 'thang' with the data. I'd further add that below the BLL would be your DAL layer. this layer could be considered a 1-1 reference with the underlying datastore.
We do that.
That's because we support scenarios where users connect to the db using programs other than the intended software (like, SQL Management studio, osql and Excel).
When you directly connect to a database which is no more than data storage, you can mess everything up as there's no rules that would stop you. These rules only exist inside the program that uses this database, and if you don't use that program, you can use you I-can-write-to-this-table permissions to do stupid (or fun) things.
When you only have permissions to execute stored procedures, you can't.
I personally think it's a better approach.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With