this has absolutely nothing to do with asp.net or associated environments. but the topic has been scratched is a few different post. It's not really a helpful tip either, but I figured the light bulb is a better choice than the question mark.
I'm of the opinion that procs should be avoided as much as possible. other believe that procs are the gateway to the database. there are many reasons why a developer, team, company would favor one over the other.
I've been giving this some thought. Why have I choosen dynamic sql (via ORM tools like LLBL and NHibernate) over procs?
testability first comes to mind. But having testable code doesn't make good code. it' just means the code passes a specific context. so testing, as a stand alone argument fails.
transparency. I can write sql statements for any database without changing my code or database. all I need to do is update my ORM configs and I'm set. Once deployed this isn't too much of a concern. You wouldn't arbitrarily change your database. However during development, testing, demo, I may be using a different database. When writing light weight integration tests I favor the SqLite database. My testing database uses SqlExpress and my production box is running Sql Server 2000. I can seamlessly switch between environments without synchronization issues.
I also get the power of using OOP to shape my queries in complex scenarios. i can't get that from a stored proc (to may knowledge).
I don't think you can argue performance. in some ways it's like comparing apples and oranges. and ORM needs to hydrate the entity/projection and a stored proc gets the raw data. Mature ORMs also have many optimizations built, between db specific db tweaks, caching (both query and results), entity maps, etc. this can reduce the number of hits to the database.
security, is also a concern. but depending on the sensitivity of the information this may be over kill. for example; a blog doesn't need tight db access, however a financial or medical institution would need the highest level of security. but this can still be handled with dynamic sql. With systems you would also have security baked into the application itself, so is tightening down the db a requirement? I can only say that depends.
I'm interested in your thoughts on this subject. do you favor procs of dynamic sql? what are your reasons behind that decision?
Jason Meckley
Programmer
Specialty Bakers, Inc.
I'm of the opinion that procs should be avoided as much as possible. other believe that procs are the gateway to the database. there are many reasons why a developer, team, company would favor one over the other.
I've been giving this some thought. Why have I choosen dynamic sql (via ORM tools like LLBL and NHibernate) over procs?
testability first comes to mind. But having testable code doesn't make good code. it' just means the code passes a specific context. so testing, as a stand alone argument fails.
transparency. I can write sql statements for any database without changing my code or database. all I need to do is update my ORM configs and I'm set. Once deployed this isn't too much of a concern. You wouldn't arbitrarily change your database. However during development, testing, demo, I may be using a different database. When writing light weight integration tests I favor the SqLite database. My testing database uses SqlExpress and my production box is running Sql Server 2000. I can seamlessly switch between environments without synchronization issues.
I also get the power of using OOP to shape my queries in complex scenarios. i can't get that from a stored proc (to may knowledge).
I don't think you can argue performance. in some ways it's like comparing apples and oranges. and ORM needs to hydrate the entity/projection and a stored proc gets the raw data. Mature ORMs also have many optimizations built, between db specific db tweaks, caching (both query and results), entity maps, etc. this can reduce the number of hits to the database.
security, is also a concern. but depending on the sensitivity of the information this may be over kill. for example; a blog doesn't need tight db access, however a financial or medical institution would need the highest level of security. but this can still be handled with dynamic sql. With systems you would also have security baked into the application itself, so is tightening down the db a requirement? I can only say that depends.
I'm interested in your thoughts on this subject. do you favor procs of dynamic sql? what are your reasons behind that decision?
Jason Meckley
Programmer
Specialty Bakers, Inc.