Hacker News new | ask | show | jobs
by kgbcia 874 days ago
How about move the business logic to stored procedures
5 comments

Writing my business logic with no libraries, no standard testing framework, and a syntax and overall feel comparable only to COBOL? No thanks.

(Some databases allow writing stored procedures in other languages, true, but that means a nonstandard interface, tightly coupled deployment model, and testing is still awful)

There is e.g. https://pgtap.org/ as a testing library for Postgres.
My first employment did this. All the business logic was in stored procedures. These procedures quickly grew bigger and bigger and were nightmare to understand and test.
This would be the right way to go if:

1) Databases had a consistent language for storage procedures

2) It was sane

The problem is that stored procedures work differently in every database, and most have come up with crazy / stupid ways to do them. That's a fixable problem, but it has not been fixed.

Oh god, no, never.

Painful to maintain, test, debug, etc.

that's also nightmare enducing since sql is great for interacting with data but less great at expressing how that data should be stored and the relationships within the data. this worsens quickly the more complex the business logic gets.

stored procs also tie you to that database engine, which could be bad if, for example, you're paying a fat stack of cash to oracle and they come back asking for more.

i think a business logic api in a programming language that leverages raw SQL is the best middle-ground IMO.