Hacker News new | ask | show | jobs
by magicalhippo 1 hour ago
I found the article very hard to follow. Then I read the domain name and it all made sense...

Guess our pattern is different, not really felt the pain point the author is talking about. Or it's the language/framework, not sure whatever the example code is written in, but setting properties on entity records would never update the database in the ones I've used.

When we did things more manually we'd make sure that methods like `create_main_records` would start a transaction if not in one, and only commit if it started the transaction. This way we could nest without worry. Our database supported nested transactions but using this pattern we didn't feel the need.

1 comments

Tired: pass live DB model objects around, mutate them to accumulate random changes, call commit() five levels deep, experience the chaos as described by the author.

Wired: fetch DB records and construct domain objects, pass them around, do mutation on the outermost level within an explicit transaction. (Typical best practice.)

Inspired: "functional core, imperative shell".