Isn't soft-delete just a variant of having a lifecycle? The article tries to distinguish it by saying that the lifecycle pattern is implemented at the app-layer instead of the database layer, but isn't their criticism of soft-delete that the app-layer has to deal with it? Maybe a better recommendation is to give guidelines for implementing soft-delete?
Avoiding the soft delete anti-pattern
41–50 of 61 posts
Re: Avoiding the soft delete anti-pattern
#42This allows for undoing a soft delete and gets rid of soft deleted rows eventually.
Re: Avoiding the soft delete anti-pattern
#43Re: Avoiding the soft delete anti-pattern
#44So we call approaches 'anti-patterns' now if they aren't universally suitable?
So, not the opposite of a pattern, but the opposite of good. There you have it.
Re: Avoiding the soft delete anti-pattern
#45Isn't soft-delete just a variant of having a lifecycle? The article tries to distinguish it by saying that the lifecycle pattern is implemented at the app-layer instead of the database layer, but isn't their criticism of soft-delete that the app-layer has to deal with it? Maybe a better recommendation is to give guidelines for implementing soft-delete?
I have the same struggle figuring what the author wants to say about this. The difference between a soft delete and a lifecycle, in the context of the article, is just semantic.
Re: Avoiding the soft delete anti-pattern
#46I am surprised the article didn’t mention the obvious fix soft deletes potential performance issues - have a job run regularly that archives soft deleted data older than X units of time. This allows for undoing a soft delete and gets rid of soft deleted rows eventually.
Re: Avoiding the soft delete anti-pattern
#47A. Move deleted data to (an)other table(s): users, deleted_users
B. Read from a scope, view, or materialized view but update a raw table: deleted bool or deleted_at datetime
C. Sprinkle conditionals everywhere live data is desired: deleted bool or deleted_at datetime
There is no one "the way" for all use-cases.
Re: Avoiding the soft delete anti-pattern
#48Isn't soft-delete just a variant of having a lifecycle? The article tries to distinguish it by saying that the lifecycle pattern is implemented at the app-layer instead of the database layer, but isn't their criticism of soft-delete that the app-layer has to deal with it? Maybe a better recommendation is to give guidelines for implementing soft-delete?
Re: Avoiding the soft delete anti-pattern
#49Earlier quoted context omitted.
The problem is that people’s first choice is to use generic models like CRUD/CRUD-L/REST/etc., instead of unvesting a bit of time in upfront thinking/design and building a custom model. IMO, if entity might be resurrected/revived/“undeleted”, then it either cannot be killed/deleted, or more likely what you thought as “deletion” was something else (e.g. suspending, archiving, hiding, or putting into trash bin). It’s b…
I've never seen it done well, and yeah, it sounds good in theory, in reality, blurgh.
IME, ideal state is that 'soft deletes' are kept primarily for easing debugging, and the 'soft delete' is kept until archival of soft deleted events occurs (also primarily for debugging/compliance, but sometimes having 'recent data' closer to runtime makes debugging cycles easier...
The biggest problem in doing so successfully is getting the design of things right, which is hard to get buy-in on.
Re: Avoiding the soft delete anti-pattern
#50It’s a great article exploring the idea, but the premise and arguments leading to it are somewhat weak, imo. First, views aren’t “fragile”. I may be wrong here, but it feels like TA tries to squeeze that along with some abstract-ORM issues. Second, “anti-pattern” is a very technical rating of this phenomenon. Business logic and its databases may contain data that may, may not, or can never be viewed as deletable, at…
People get so attached to ORMs with object tracking that they invent whole categories of blog articles to work around cases where a simpler abstraction would be less work.