Description

In this video I invited the illustrious Mads Torgersen to my office to help me out with some code! Our goal was to see how C# 7.0 could be used to improve some existing code. In this video we explored Tuples, Pattern Matching, Local Functions, Out Parameters, and more! I figured that instead of talking about them we would dive into my machine learning library to update some of the older constructs in favor of some of the new syntax. Enjoy!

Outstanding session, gentlemen. Nice to see real-world examples in production code rather than working with contrived throwaway projects with the simplest use cases. The cameo by Mr. Hanselman was a nice surprise as well. ;)

That was a really great discussion of these three new useful C# features. I was particularly impressed with the interactive code update approach. It locks in the concepts as one can see the thinking real time. The discussion of the var out in the third example went off in the wrong direction briefly until it became clear the issue wasn't scope but the possible return of an unassigned variable. This was great to follow along as it really helps lock in exactly what is going on and helps us use this cool shorthand. More of this!

Great video. Great interactive refactoring session. I love stuff like this, keep it up!

At 27:37 the nastiness of out var is pretty undeniable. Maybe I will come to accept it but it seems to me the antithesis of declarative programming to have a name extracted from a nested short-circuiting conditional into a parent scope and rebound. It is just not clear at all where it comes from and even when you see it, it would be better declared beforehand because it makes the second use clearer.

I think out var is the first truly bad feature ever added to C#.

All of the changes in this session (case b when b was just illustrative, predicated cases are great) improved the code making it better written as C# 7.0, even where it was suboptimal C# 6.0, except for that one.