|
Marc Clifton wrote: with a particular entity needs to be copied to as a child of a different parent entity
Yes that is the example I thought of.
Like many new features I can only see the new feature being helpful in a limited number of cases.
Where it might be nice is when the original class has many attributes and the set (unfortunately) continues to grow. Then the more manual updates become more of a problem. If only because on a standard screen actually remembering that way down below in the class there is one (or more) copy ctors. Forgetting those can become a problem.
|
|
|
|
|
Great examples and the value of the record keyword is that you get a lot of pre-created functionality as follows (the first one being the big one):
- It writes a protected copy constructor (and a hidden Clone method) to facilitate nondestructive mutation.
- It overrides/overloads the equality-related functions to implement structural equality.
|
|
|
|
|
|
Graeme_Grant wrote: I find them useful as DTOs or for simple POCOs.
That makes a lot of sense to me.
I will check out the video. Thanks
|
|
|
|
|
raddevus wrote: I will check out the video. Thanks
Nick is very good. He deep dives and is very thorough.
Graeme
"I fear not the man who has practiced ten thousand kicks one time, but I fear the man that has practiced one kick ten thousand times!" - Bruce Lee
|
|
|
|
|
often, because a lot of common bugs can be traced back to unexpected mutations
so if you send me an object and I don't know where it comes from, and I need a modified version of that to do something else, I'll make a copy first - I might use .DeepClone() from NuGet Gallery | PeanutButter.Utils 3.0.167 followed by some (again, from that lib) .With(...) statements, eg
var foo = yourObject.DeepClone()
.With(o => o.Name = o.Name.ToUpper());
------------------------------------------------
If you say that getting the money
is the most important thing
You will spend your life
completely wasting your time
You will be doing things
you don't like doing
In order to go on living
That is, to go on doing things
you don't like doing
Which is stupid.
|
|
|
|
|
|
I use this all the time. The naming is a little odd, but the concept is very simple:
Copy an object and then change just those fields and properties you need to change.
Seriously, I'm not sure this is useful as syntactic sugar except in very limited cases.
|
|
|
|
|
It's excellent for data contracts in web services where the reception is generally out of the client's control and whatever comes in the response, that is the object, because that is what came and it should probably never be mutable.
The bottom line is that record can help enforce SOLID adherence.
Many POCOs in general should now probably be defined as records instead of class.
They're great.
The only drawback/beef I have with them is having to do hokey workarounds to use them while targetting .NET Standard (C# 9–Use Record types in .NET Standard 2.0[^]).
|
|
|
|
|
Have I (to your point) occassionally has a use for this?...Yes.
Is this overkill?...Yes.
This is what you get when you open source things and can't think of a compelling reason to say "no".
That being said there ARE some useful things that have come from the open sourcing.
BTW, Top Level command NOT being one of them! 
|
|
|
|
|
This feature is useful to avoid all kind of bugs related to the usage of mutable values with multiple ownership shared through references.
Think about scenarios when a method 'foo' receives an object as an input parameter. The initial contract is that the object's fields are not changed inside 'foo' . In a big codebase there would be many places where 'foo' becomes used over time, with the semantics of not changing the fields of the input object. If at some point someone makes a change in 'foo' to mutate one of the fields, this could cause many non obvious problems. In practice, in complex codebases these problems might be difficult to detect in a code review.
Immutable types and non destructive mutation provide a solution to better express this kind of semantic.
If you can't explain something to a six year old, you really don't understand it yourself. (Albert Einstein)
|
|
|
|
|
Artwork stops flying cod for example! (9)
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Is it landscape ?
In a closed society where everybody's guilty, the only crime is getting caught. In a world of thieves, the only final sin is stupidity. - Hunter S Thompson - RIP
|
|
|
|
|
It is indeed - you are up tomorrow!
Artwork
stops flying LANDS
cod for example! CAPE
LANDSCAPE
I liked that one.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Yes especially the cod for example
In a closed society where everybody's guilty, the only crime is getting caught. In a world of thieves, the only final sin is stupidity. - Hunter S Thompson - RIP
|
|
|
|
|
My original was "Artwork stops flying head? (9)" but while "HEAD" is a synonym for "CAPE" I feel the link was too weak. Better flowing clue though.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
A capital C in Cod might have given us mere mortals a clue!
|
|
|
|
|
You think I want you to get it?
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
I thought you'd stopped doing the CCC Rich
In a closed society where everybody's guilty, the only crime is getting caught. In a world of thieves, the only final sin is stupidity. - Hunter S Thompson - RIP
|
|
|
|
|
I have merely stopped getting it right ...
(To be fair, it's often solved before I see it)
|
|
|
|
|
Just came across GUNSHIP's Fly For Your Life video. It depicts war and blood, so not the most uplifting topic, but the graphics are very well done for those who enjoy such things. Kinda reminds me of Heavy Metal's tone, but I don't think this was hand drawn. (I could be wrong, but it looks too fluid and detailed for that.)
|
|
|
|
|
|
Action reminds me of latest version of "Top Gun". Very interesting animation.
The essence of combat in B&W. As US grant said, "War is Hell".
Probably a mix of hand drawn and computer animation?
I am doing some research.
"A little time, a little trouble, your better day"
Badfinger
|
|
|
|
|
jmaida wrote: Probably a mix of hand drawn and computer animation? Probably. The perspective of the background terrain seems to be far too accurate as the camera and planes twist and turn to have been laid out by hand.
|
|
|
|
|
agree
"A little time, a little trouble, your better day"
Badfinger
|
|
|
|