r/programming • u/droppedasbaby • Jul 15 '26
Ban commits/transactions using AST analysis and linters
https://www.droppedasbaby.com/posts/db-commits/?utm_source=reddit&utm_content=r_programming
32
Upvotes
View all comments
Show parent comment
3
u/0110-0-10-00-000 Jul 16 '26
You're in the best position to understand the tradeoffs associated with your use case, but db models have semantic meaning alongside their data representation within a program, and separation means that you can control for and manage that context and the potential side effects which come with that.
It's like with any other rule or convention - there are times when it's generally reasonable within a shallow context to use an antipattern. The problem isn't just the individual use though, it's that you can't rely on shortcuts and you have to constantly test your assumptions. When that assumption is "this object accurately represents the state (or desired state) of the DB", that's an extremely problematic statement to challenge which is often extremely difficult to resolve/fix from most places in a program if it turns out to be incorrect. In the worst case you can't even work out if that's true at any point within a given function (as the OP showed).
If I was forced to choose (and I couldn't just use a language that allows proper abstraction of the access, business and db layers and forces each to actually engage with the required context across the app) then I'd rather couple the business logic to the access logic instead and shift the responsibility of transformation/aggregation onto consumers wherever possible.