Should you Delete or Soft Delete?

Should you Delete or Soft Delete?

CodeOpinion

2 года назад

11,338 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

@zimcoder
@zimcoder - 29.06.2022 16:44

Sometimes a user requests that all the data be deleted permanently, you can't just make another entry elsewhere that they requested to be deleted and capture data on that event because you will be violating their right to be forgotten. Sometime a delete is just a delete.

Ответить
@chadgregory9037
@chadgregory9037 - 29.06.2022 16:56

about 15 minutes of real, actual work.

Ответить
@dasfahrer8187
@dasfahrer8187 - 29.06.2022 16:58

I'm pretty sure if I'm Peter I want to hard delete all TPS reports.

Ответить
@sangmin7648
@sangmin7648 - 29.06.2022 17:00

Thanks for the video! Choosing between event sourcing and crud seems to be a difficult job. How should I know when to use which? And later down the line, when I realize that I should’ve gone with the other method, how should I make the change? Changing from event sourcing to crud seems pretty simple, as I already have all the data. But how should I change from crud to event sourcing? Or should I just event source everything to be safe?

Ответить
@AaronInCincy
@AaronInCincy - 29.06.2022 17:14

How do you handle mis-keyed data in a task based system? Let's say an employee moved, and you go through the workflow of entering a new address. You click save, the system kicks off an employee moved event and everything is great. Then you noticed you miskeyed their street name. Do you have another employee moved event? They didn't really move twice. Do you have an AddressCorrected event? At that point do you have to support task based AND crud based events for every piece of data?

Ответить
@Oswee
@Oswee - 29.06.2022 17:28

Nah... you should cover GDPR where users has rights to wipe out their data. So you should wipe out all sensitive marked data. You can't keep it in original form.

Ответить
@mahmutjomaa6345
@mahmutjomaa6345 - 29.06.2022 17:44

So you would add data with more information (i.e. EmployeeTermination and EmployeeHiring) instead of toggling an isDeleted flag because the facts of what happened might be important.

Ответить
@brandonpearman9218
@brandonpearman9218 - 29.06.2022 17:47

so what you are saying hireEvent = add to db, and terminateEvent = update db... so your answer is softdelete.

Ответить
@MiningForPies
@MiningForPies - 29.06.2022 18:34

Soft deletes are the bane of my existence. Got a system I’ve inherited where the soft delete flag means something different depending on the entity it’s on. And query/report performance is crap because it’s got to be included in every one

Ответить
@roko567
@roko567 - 29.06.2022 18:58

Soft deleting user info is illegal in Europe

Ответить
@wboumans
@wboumans - 29.06.2022 19:47

Derek do you use C4 diagrams? If so would you ever do a primer on them?

Ответить
@chengchen9032
@chengchen9032 - 29.06.2022 19:52

yean totally agree that events are more informative than crud, but I feel like the storage of events could be challenging. do you have any advice on that? let's say one entity is a row in the sql db, if its crud, no matter how many events happened in the domain, cuuud ends up with d, one row less for the table, however, it would be five events to stored if we do event sourcing.

Ответить
@sodreigor
@sodreigor - 29.06.2022 20:29

I can think of several occasions where you should actually hard delete things. The first one that comes to mind is: If I click "Terminate My Account" on facebook for instance, Facebook should hard delete all of the media that I uploaded there.

Now the question is: Will facebook actually delete it? I don't know.
But should facebook hard delete it? Yes.

Ответить
@void_star_void
@void_star_void - 29.06.2022 21:07

What about the right to be forgotten? instances when you ask the company to delete your data

Ответить
@everydreamai
@everydreamai - 29.06.2022 21:09

A lot of your videos hit on a very important topic without actually explicitly getting into it. It's very important to have a competent product owner who can focus on delivering their team with meaningful acceptance criteria for actual business cases instead of things that look like CRUD operations. This is often a challenge with businesses that do a poor job aligning teams with business functionality and not technical considerations.

Ответить
@mybackhurts247
@mybackhurts247 - 30.06.2022 01:38

Peter Gibbons: what would you say you do here? do you deal with the gd customers so the engineers don't have to? do you have people skills?

Ответить
@FISS007
@FISS007 - 30.06.2022 02:23

I totally agree with you. There are even some regulations and laws that forbid data deletion and enforce keeping data history.

Ответить
@markovcd
@markovcd - 30.06.2022 09:58

What about GDPR?

Ответить
@ddruganov
@ddruganov - 02.07.2022 13:56

A great example of domain specific language usage!

Ответить
@grumpydeveloper69
@grumpydeveloper69 - 02.07.2022 21:26

Even when from a business standpoint you don't think of hard deletes, regulations like the GDPR and right to be forgotten laws would still requires systems to be able to hard delete. How do you handle such regulatory requirements?

Ответить
@ujwaldhakal6004
@ujwaldhakal6004 - 04.07.2022 22:43

Do you delete user related data from even store to comply with GDPR?

Ответить
@remigiuszkowalski7405
@remigiuszkowalski7405 - 16.07.2022 04:45

​ @CodeOpinion I've read the comments :D Please stop explaining purpose of this video to everyone. It's like riding a bicycle with inverted handlebars - your brain needs to adopt first.

Ответить
@sethdodson5475
@sethdodson5475 - 26.08.2022 17:00

One notable exception: if your business wants to comply with European privacy laws and receives a request to delete PII for an individual, then deletion truly is in line with a business process.

Ответить
@JackiePrime
@JackiePrime - 02.09.2022 00:08

Doesn't this make your life as a developer much more difficult? For example we use soft delete, and in our EF database context we filter out based on IsDeleted == false as the default. Only when we explicitly requested deleted data is it returned from the API. This means we don't have to think about deleted data. If we went with your approach, we would have to have seperate logic for filtering out deleted records for every entity.

Ответить
@TheRicherthanyouguy
@TheRicherthanyouguy - 06.09.2022 15:00

I can 100% support this mind set. I’ve worked in large scale and super small projects and in my experience I’ve started evolving away from a soft delete an instead use some kind of enumeration or status code id usually stored in a database of some sort to define that current status of data. I think a lot of the frustration caused here is generally because these type of thinking does require user interfaces and queries to be a bit smarter than we might like but I’ve found it’s usually worth it.

Ответить
@br3nto
@br3nto - 22.09.2022 03:09

It would be helpful if you describe what the database schema and database changes would be for the evented version. It’s easy to see how soft delete works because you showed the schema with the IsDeleted column and how/when it is updated. But it’s not clear on what the db schema is and how data is managed in the evented version.

Ответить
@ndev92
@ndev92 - 12.12.2022 11:33

What if you Aggregate Root has a collection of items, and then somewhere in your code you write AggregateRoot.Collection.Remove(item)? In my case the collection is lets say an Assessment and the collection is Reviewers. But I want to remove one of the Reviewers of the Assessment. Lets say I am using EF and SQL database, What would be the best way to handle that?

Ответить
@TheAceInfinity
@TheAceInfinity - 20.02.2023 13:05

Answering the question of whether to hard delete vs soft delete with the the notion of "adding" things doesn't make any sense. It still doesn't answer the question on whether you should use one or the other because the it's irrelevant to the question, with no alternative provided, and assumes extremely contextual business application requirements that do not apply universally! There's lots of cases where recording a chronological order of events is not the right solution. Not a great answer to the question IMHO.

Ответить
@marna_li
@marna_li - 28.02.2023 01:13

"Why store all these events and data taking up space?" - Because of auditing. "But I don't need that" - So be it, this is just a concern that might become important to your business later down the road. You need to know that this is a way of thinking about your system. And you don't have to go all in on event sourcing for this either.

Ответить
@Thorarin
@Thorarin - 13.09.2023 09:02

And then GDPR became a thing for many of us, so we cannot just keep data around indefinitely. Eventually you will have to hard delete if it applies to your business.

Ответить
@fabiogusmaoribeiro
@fabiogusmaoribeiro - 13.09.2023 16:11

Expanding on the subject of soft-delete, do you believe that adding "created by", "created at", "updated by", "updated at", "deleted by" and "deleted at" columns to your database is redundant when you can grab that information from the event store?

Ответить
@hemslingo7219
@hemslingo7219 - 05.10.2023 03:44

Very easy situation to get into. The most annoying repercussion I've come across is having to omit IsDeleted entities throughout the entire application, including navigation properties. If you're selecting from the db at the root entity level, it's very difficult to deal with in a large app.

Ответить
@cdnkarasu
@cdnkarasu - 05.11.2023 20:33

Soft delete is useful for adding a versioning mechanism. Also an alternative is to use temporal tables.

Ответить
@ronifintech9434
@ronifintech9434 - 27.03.2024 04:40

Looks like this is a good approach for nosql? how do you implement something like this for SQL?

Ответить