4 ms·
Your point 2 is far from ridiculous. We do it that way so the business logic exists and is enforced in one place rather than being scattered around this desktop
by gaius 17y ago
Your point 2 is far from ridiculous. We do it that way so the business logic exists and is enforced in one place rather than being scattered around this desktop app and that website and so on. Only the most trivial applications can afford to put all their business logic in the middle tier.
Also I'm not allowed to use OCaml in production systems because too few people at the company speak it. Annoying for me, but again far from ridiculous.
- ohhmaagawd 17y agothis was common practice about 15 years ago, before people discovered that putting biz logic in stored procs really sucked for UI interaction, sucked for maintainability (stored proc languages really suck), and truly sucked for scalability.
- sports_guy 17y agoIt sucks yes, but working at a place where there are a groups of people that commonly access the database to do operations that cannot be done from the front end you definitely want procedures. They use different tools for a variety of tasks and when the business logic isn't in procedures its very easy for them to break things and they have and do.... Our DBA however wants all procedures for all access which I find to also be an extreme example for the reasons you mention as not all data needs this level of control as its just simple CRUD operations and tables they should never change anyways.
- brown9-2 17y agoWell then in this case you have a people problem, not a software problem.
- stcredzero 17y agoPoint 2 is a bad idea. SQL stored procedures are not a good way to implement business logic. Of course, people who hold the opinion that OO is a bad idea would think it's a great way -- it's pretty much the opposite of OO. We do it that way so the business logic exists and is enforced in one place...Only the most trivial applications can afford to put all their business logic in the middle tier. There are much better ways of enforcing business logic and controlling it all in one place, which would be compatible with configuration management/source control and much more convenient for most programming teams. (Namely: just publish the business logic as a library and have standards that dictate its use. These can be enforced using automated scripts and a little process. You are also not restricted to the middle tier, though I'd still say it's a good idea.)
- deleted 17y ago[deleted]
- asb 17y agoStored procedures don't seem like a bad approach to me. You can provide versioning support by doing something much like Rails migrations. Providing access to the database through stored procedures basically is publishing business logic as a library. I'll admit pl/pgsql looks a little funky, but it doesn't seem too bad. I'll note I'm not talking from experience here, I'm just speculating and hoping for somebody with more practical experience in the matter (or better insight) to enlighten me.
- stcredzero 17y agoIf it is "basically...publishing business logic as a library" then why incur the expense of using such a scheme? Just publish the darn library and put it on a read-only shared directory. Why give up the use of purpose built version control and programming tools? Why give up the modularity and increased productivity that a high level language can give you? Most of the time, it's because the organization thinks in terms of SQL and relational tables. There are better ways to do business logic.
- arghnoname 17y agoAs a language, it's pretty painful to use and you run into those limitations pretty quickly. You also put more processing in the database, which isn't great for scalability. It is nice being able to test changes via the sql prompt though. A library + console app might be a good compromise.
- gaius 17y agojust publish the business logic as a library and have standards that dictate its use LOL!! Why not put the business processes in the standards too, then you won't need any code! The point is, no-one running any apps against your database has a choice but to respect the business processes if it's all implemented in stored procs. You are protected from malice, from incompetence, from simple human error, and your auditors and regulators and shareholders are happy. Maybe no-one cares if it's only a website. Also I am hilariously amused that you don't think stored procedures can live in version control like any other source code.
- pmichaud 17y agoThe alternatives are not 1) Sproc 2) Scattered around the app haphazardly The only apps I've seen use the BLL-as-an-sproc trick were written by people without any experience writing scalable code at a real company.
- gaius 17y agoReally? Most of my experience is on trading systems handling thousands of real-money transactions per second, and stored procedures are the only proven approach.
- jrockway 17y agoYour point 2 is far from ridiculous. We do it that way so the business logic exists and is enforced in one place rather than being scattered around this desktop app and that website and so on. Only the most trivial applications can afford to put all their business logic in the middle tier. But of course, the middle layer that applications talk to need not be the database. A simple RPC server between the apps and the database makes maintaining the system significantly easier. Your procedures are "normal code" that you already have a toolchain in place for dealing with. (Testing, libraries, version control, etc.) The environment is richer, which means the middle tier can handle caching, sharding, replication, auditing, and anything else that you might need to add. And, you can add these things incrementally, without touching the apps that speak to this server. IMHO, stored procedures are a quick hack that are barely viable for even the simplest tasks. Many people seem to disagree, but I doubt they have ever considered any other way. (A notable example of this system is Flickr. Their internal apps, like the public web interface, use the Flickr API to do their work. In this case, the web app that powers the API is the "middle layer"/"RPC server". I think this worked out pretty well for them, and it made it easy to expose their database to third parties.)
- viggity 17y agoMy dad can beat up your dad.
- cromulent 17y agoSAP has all it's business logic in the middle tier, and I wouldn't call it trivial.