Hi!
Records will be really useful in cases where we are looking for immutable data. Examples:
DTOs
Events when working in event sourcing
Commands
...
I recommend you to read this blog post (pre-records) by Jimmy Bogard when he explains the challenges of immutable classes in .net. Know, with records, it's embedded in the language.
Hi,
thanks for the comment! I agree records can be great for DTOs and Commands (I'm also thinking about MediatR). As Jimmy Bogard mentioned in his blog post upon until now Immutable objects could not be serialized easily. Now that we have records they are immutable and can be serialized 🎈. Here is a small example of the serialization (I couldn't believe it, I had to try it myself :D) dotnetfiddle.net/e8tSIN
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Hi!
Records will be really useful in cases where we are looking for immutable data. Examples:
I recommend you to read this blog post (pre-records) by Jimmy Bogard when he explains the challenges of immutable classes in .net. Know, with records, it's embedded in the language.
jimmybogard.com/immutability-in-dtos/
Hi,
thanks for the comment! I agree records can be great for DTOs and Commands (I'm also thinking about MediatR). As Jimmy Bogard mentioned in his blog post upon until now Immutable objects could not be serialized easily. Now that we have records they are immutable and can be serialized 🎈. Here is a small example of the serialization (I couldn't believe it, I had to try it myself :D) dotnetfiddle.net/e8tSIN