<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Mark Clearwater</title>
    <description>The latest articles on DEV Community by Mark Clearwater (@csmacnz).</description>
    <link>https://dev.to/csmacnz</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F173499%2Fd59e13a8-1e14-4bcc-8797-ab5e66fbf456.png</url>
      <title>DEV Community: Mark Clearwater</title>
      <link>https://dev.to/csmacnz</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/csmacnz"/>
    <language>en</language>
    <item>
      <title>We are all 10x engineers, but I don't think it means what you think it means</title>
      <dc:creator>Mark Clearwater</dc:creator>
      <pubDate>Mon, 15 Jul 2019 21:50:55 +0000</pubDate>
      <link>https://dev.to/csmacnz/we-are-all-10x-engineers-but-i-don-t-think-it-means-what-you-think-it-means-55n6</link>
      <guid>https://dev.to/csmacnz/we-are-all-10x-engineers-but-i-don-t-think-it-means-what-you-think-it-means-55n6</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ei8f4wcu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://images.unsplash.com/photo-1554854044-80ab1a40e12b%3Fixlib%3Drb-1.2.1%26q%3D80%26fm%3Djpg%26crop%3Dentropy%26cs%3Dtinysrgb%26w%3D1080%26fit%3Dmax%26ixid%3DeyJhcHBfaWQiOjE2ODI3fQ" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ei8f4wcu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://images.unsplash.com/photo-1554854044-80ab1a40e12b%3Fixlib%3Drb-1.2.1%26q%3D80%26fm%3Djpg%26crop%3Dentropy%26cs%3Dtinysrgb%26w%3D1080%26fit%3Dmax%26ixid%3DeyJhcHBfaWQiOjE2ODI3fQ" alt="We are all 10x engineers, but I don't think it means what you think it means"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If your reading this blog, and used twitter in the past few days, you have probably already seen this tweet, or some of the replies coming through from the community:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;10x engineers  &lt;/p&gt;

&lt;p&gt;Founders if you ever come across this rare breed of engineers, grab them. If you have a 10x engineer as part of your first few engineers, you increase the odds of your startup success significantly.  &lt;/p&gt;

&lt;p&gt;OK, here is a tough question.  &lt;/p&gt;

&lt;p&gt;How do you spot a 10x engineer?&lt;/p&gt;

&lt;p&gt;— Shekhar Kirani (@skirani) &lt;a href="https://twitter.com/skirani/status/1149302828420067328?ref_src=twsrc%5Etfw"&gt;July 11, 2019&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;As a developer who tries to be good at their job, I have thoughts on this. As a Human, I like to be heard. (Note that being heard is not the same thing as being agreed with, or being right.) So here I am giving my opinion on this idea of a 10x developer, and specifically these "10 signs" put up online.&lt;/p&gt;

&lt;p&gt;I like the idea that there are no 10x people, instead, you can strive to produce 10x teams.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Meetings
&lt;/h2&gt;

&lt;p&gt;A lot of people don't like meetings. But unfortunately, communication is a big part of effective teams and businesses. While it is true that some people love meetings, and some meetings don't hold productivity, the key here is communication. If you can find an effective means of communication within a team that works, that is most important. Having a team full of people that don't have meetings doesn't make a 10x team. If meetings are causing you or your team problems, it is work looking at other strategies for effective communication. There are alternatives out there.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Office Hours
&lt;/h2&gt;

&lt;p&gt;"Nine to Five" is such an old fashioned idea these days. Not only do some countries have alternative ideas like 4 day weeks, long lunch hours, "flexitime", but more and more business work across locations and across timezones. We are asking people to work outside these hours for various reasons already, so why not some give and take here?&lt;/p&gt;

&lt;p&gt;Most people would love flexible work hours. It turns out that if people can work around their own schedule, they put their best work forward when they are present. I would much rather have someone contribute 100% at 9 pm at night because their kids are in bed and they can concentrate rather than pay them to sit at their desk for several hours texting and calling their family. Just a thought.&lt;/p&gt;

&lt;p&gt;We are so fortunate that in our industry is so capable and adjustable to different working hours that it is a shame not to support this. It is not that "10x developers are the people who like this", it is actually that most employees want this, and it can be done.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Screen colour and worn keyboards
&lt;/h2&gt;

&lt;p&gt;If I saw a sports star on the field/pitch/court wearing badly worn shoes, I wouldn't think "This is a superstar", I would probably think "he isn't paid enough".&lt;/p&gt;

&lt;p&gt;Why are you letting your developers use worn-out equipment? Buying the required hardware and software is such an important thing, just do it! In all seriousness, though, giving staff the right tools to get their job done is always a good idea.&lt;/p&gt;

&lt;p&gt;There is an interesting dichotomy with custom technical tools as well. If you have one developer that goes against the grain of the team with customisation, then it both makes it harder for them to use other machines (e.g. during pairing/mobbing) and for others to use theirs. There is some efficiency to using the out of the box defaults too. You can get up and running faster, and waste less time doing customisations every time you refresh your machine or change jobs and get new hardware.&lt;/p&gt;

&lt;p&gt;Also, if you have to have everything customised your own way, you won't be able to acclimatise to new situations, new tools, new teams. Not someone you want to add to your team.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Good memory
&lt;/h2&gt;

&lt;p&gt;One my big comparisons between my generation and the one before me (that is the one with the access to Google, but not access to iPads) was that at school we were no longer taught to memorise and recall information. Instead, we were taught, and learned, the importance of finding and referencing information. There is too much information for us all to hold in our heads. knowing where to look and what to look for is far more important that memorised information for a technology that will be obsolete in 3 years (if you are lucky), let alone memorising a dozen of them over time.&lt;/p&gt;

&lt;p&gt;Yes, it is great to get people who know the domain really well, and for some people, it really is a skill. But people can't know what they haven't seen yet, and new hires always start as a blank slate. Not to mention tomorrow will bring a new set of libraries, applications and services that need to be learned and understood.&lt;/p&gt;

&lt;p&gt;Scott Hanselman talks of the experience-groundhog-day scenario.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Do you have 10 years’ experience, or the same year 10 times? &lt;a href="https://t.co/LhIeWiWl3H"&gt;https://t.co/LhIeWiWl3H&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;— Scott Hanselman (@shanselman) &lt;a href="https://twitter.com/shanselman/status/1001495109836226560?ref_src=twsrc%5Etfw"&gt;May 29, 2018&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  5. Full Stack
&lt;/h2&gt;

&lt;p&gt;Don't you love buzz words? FullStack. A full-stack would be from the HTML/CSS/js to the backend code, to the database. But it is also understanding how the TCP/HTTP layer works with packets and routing. How does your platform infrastructure run, do you manage and patch the servers? Database backups and data security, not to mention how the hardware scales, can you write the assembly to work with arm processors too?&lt;/p&gt;

&lt;p&gt;Jack of all trades, master of none. That is a saying that acknowledges you are spread too thin. You can't be an expert in everything, so instead, you can hire an expert in each thing. Yes, you want everyone to be a generalist, but make sure you have coverage with all of the specialists, too.&lt;/p&gt;

&lt;p&gt;I can't say I've met too many people who can design and build an amazing user experience, and also optimise a large scale database, and run a datacentre. Oh and also works well with others...&lt;/p&gt;

&lt;h2&gt;
  
  
  6. Wait, WAT?
&lt;/h2&gt;

&lt;p&gt;This one I just have to quote it in two parts:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;10x engineers can convert "thought" into "code" in their mind and write it in an iterative fashion.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Just for a second, imagine with me, that you could replace the words "10x engineer" with "a developer". Crazy idea, but it might actually work.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Given a product feature, they can write that entire feature in one or two sittings of 4 to 6 hours with a caffeinated drink without distraction.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;We all have good days where we fire on all cylinders. Or a task or feature fits into just the right hole in a system. Cherish the days when it happens, but realise its more about the stars aligning and less about the ability of your developer. We are all capable of this. But the rest of the time it's just a Monday.&lt;/p&gt;

&lt;h2&gt;
  
  
  7. Good Memory. Part Deux
&lt;/h2&gt;

&lt;p&gt;We talked about this. Enough said.&lt;/p&gt;

&lt;h2&gt;
  
  
  8. Learning
&lt;/h2&gt;

&lt;p&gt;This is another one of those things with a dichotomy. If you are always learning something new, you never get to master anything. There is a benefit to having people who are masters, and people who can learn, and people who can teach and share. You need balance both as a developer and person, but also in and within a team. If you don't have this yet, look at hiring the capabilty, but don't use it to rule in or out talented people.&lt;/p&gt;

&lt;h2&gt;
  
  
  9. Terrible leaders
&lt;/h2&gt;

&lt;p&gt;Yes. I think exactly what you want to do is hire someone who cannot teach how the system works to new staff. That will help you grow. No, not really. The team is only as strong as its weakest point. And the ability to both cover for, and teach and grow newer talent is key to growth and success.&lt;/p&gt;

&lt;p&gt;Also, while it is true that some people will be amazing on your team, but will interview poorly, I can't say there is a direct reverse correlation here, either. Sorry.&lt;/p&gt;

&lt;h2&gt;
  
  
  10.
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;10x engineers rarely job hunt or move out of the company. They move out because you make their life miserable with the process, meetings, training, and other non-value-added activities. If you come across them, hold on to them. Celebrate them.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;So close. This is the first point I almost agree with. Just go ahead and replace "10x engineers" again with "developers", Or even just "employees" will do.&lt;/p&gt;

&lt;h2&gt;
  
  
  0.1x developers
&lt;/h2&gt;

&lt;p&gt;While there are seeds in here that make for an interesting debate, they have nothing to with "10" or "X". The best summary of the whole situation is this: The scale is off. I think the truth of the matter is that there are developers who might contribute to failings in a team (and some warning signs appear above, under the wrong inversion, though). We can call them the 0.1x developers. They are the ones to truly watch out for.&lt;/p&gt;

&lt;p&gt;As founders and employers, you will want to be doing all the right things to attract and keep good talent, and that is more important than going after a mythical creature known as the 10x developer.&lt;/p&gt;

&lt;p&gt;What someone needs to do is follow the footsteps of Dylan Beattie's &lt;a href="https://github.com/RockstarLang/rockstar"&gt;Rockstar programming language&lt;/a&gt; and make a language or piece of hardware board and call it "10x". Then we can all be Rockstar Programmers and 10x Engineers.&lt;/p&gt;

</description>
      <category>softwaredevelopment</category>
    </item>
    <item>
      <title>Snuffleupagus-Oriented Programming</title>
      <dc:creator>Mark Clearwater</dc:creator>
      <pubDate>Mon, 08 Jul 2019 18:00:00 +0000</pubDate>
      <link>https://dev.to/csmacnz/snuffleupagus-oriented-programming-2ado</link>
      <guid>https://dev.to/csmacnz/snuffleupagus-oriented-programming-2ado</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--luVRidSr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://blog.csmac.nz/content/images/2019/07/1rYH-1-.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--luVRidSr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://blog.csmac.nz/content/images/2019/07/1rYH-1-.gif" alt="Snuffleupagus-Oriented Programming"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;An impromptu introduction to Snuffleupagus-Oriented Programming (SOP): &lt;a href="https://t.co/jPkjPRgqQr"&gt;https://t.co/jPkjPRgqQr&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;— Casey Muratori (@cmuratori) &lt;a href="https://twitter.com/cmuratori/status/623332420855541764?ref_src=twsrc%5Etfw"&gt;July 21, 2015&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Sometimes naming something is the best way to start talking about a topic that lots of people do but don't realise or haven't pulled together as a concept. This is one of those ideas that finally has a good (?) name.&lt;/p&gt;

&lt;p&gt;How do you build out a new API? Here we are meaning programming contracts effectively. You can hack away until you have something functional, and then start consuming it. Better yet, build it out as code to do a job and then ship it to someone else to try and use.&lt;/p&gt;

&lt;p&gt;Most developers get to a point where they see the value in having contract design up front across team boundaries, layer boundaries, reusable components, HTTP/Soap boundaries etc. An evolved design for these will never be as good as an intentional one. And on the flip side, we have all used clunky library APIs in various languages, BCL or otherwise.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is Mr Snuffleupagus
&lt;/h3&gt;

&lt;p&gt;The name comes from Sesame Street. Muppets basically. Big Bird and Bert and Ernie, Elmo etc. There was a storyline decades ago where Big Bird kept seeing Mr Snuffleupagus and talking about him, but no one else ever saw him. They concluded it was an imaginary creature for a long time. In the show, it was very ambiguous what the truth was. Eventually, they actually saw the Snuffleupagus too and concluded it wasn't imaginary after all. &lt;a href="https://www.smithsonianmag.com/smart-news/brief-history-sesame-streets-snuffleupagus-iidentity-crisis-180957351/"&gt;More here.&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Enter SOP
&lt;/h3&gt;

&lt;p&gt;The ideas from this story match an approach to building your API.&lt;/p&gt;

&lt;p&gt;First, we are going to imagine that what we want to use exists. Then we are going to write code against the API, crafting our usage case, without implementing anything. Once we are happy that our API is usable, we implement it and make it actually exist, make it real. There may be a few tweaks once the realities and limitations of the implementation are taken into account, but the idea is to try and keep it as usable as the original usage cases as possible, usability intact.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://gifer.com"&gt;via GIFER&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  TDD
&lt;/h3&gt;

&lt;p&gt;This is a great candidate approach to work with TDD as well, just with more implementation code along the way to produce passing tests. Like Mr Snuffleupagus, this implementation code is imaginary until you have enough test cases to make it real, and refactor.&lt;/p&gt;

&lt;h3&gt;
  
  
  Thanks
&lt;/h3&gt;

&lt;p&gt;Go forth and start sharing SOP, Snuffleupagus-Oriented Programming. Imagine, Build Usage, Make it Real. Thanks &lt;a href="https://twitter.com/cmuratori"&gt;Casey Muratori&lt;/a&gt; for coining the term and making it stick. See more of his programming on &lt;a href="https://handmadehero.org/"&gt;HandMade Hero&lt;/a&gt; (&lt;a href="https://www.youtube.com/handmadehero"&gt;YouTube&lt;/a&gt;), and his company &lt;a href="https://mollyrocket.com/nexus"&gt;Molly Rocket&lt;/a&gt; for games and more.&lt;/p&gt;

</description>
      <category>softwaredevelopment</category>
      <category>patterns</category>
    </item>
    <item>
      <title>Looking Back on C# 7: Pattern matching</title>
      <dc:creator>Mark Clearwater</dc:creator>
      <pubDate>Mon, 01 Jul 2019 18:00:00 +0000</pubDate>
      <link>https://dev.to/csmacnz/looking-back-on-c-7-pattern-matching-55ae</link>
      <guid>https://dev.to/csmacnz/looking-back-on-c-7-pattern-matching-55ae</guid>
      <description>&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimages.unsplash.com%2Fphoto-1530226406379-f84b9edd291b%3Fixlib%3Drb-1.2.1%26q%3D80%26fm%3Djpg%26crop%3Dentropy%26cs%3Dtinysrgb%26w%3D1080%26fit%3Dmax%26ixid%3DeyJhcHBfaWQiOjE2ODI3fQ" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimages.unsplash.com%2Fphoto-1530226406379-f84b9edd291b%3Fixlib%3Drb-1.2.1%26q%3D80%26fm%3Djpg%26crop%3Dentropy%26cs%3Dtinysrgb%26w%3D1080%26fit%3Dmax%26ixid%3DeyJhcHBfaWQiOjE2ODI3fQ" alt="Looking Back on C# 7: Pattern matching"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With C# 8 on our doorstep, I figure it is a good time to reflect on recent additions to the language that have come before. There are some great improvements you may have missed, some that I really enjoy using, and some I consider have reached canonical usage status that I think are all worth some reflection.&lt;/p&gt;

&lt;p&gt;Pattern matching is a powerful feature that has been unlocked against various language constructs in C#. The idea is to take existing features like &lt;code&gt;case&lt;/code&gt; from switches and &lt;code&gt;is&lt;/code&gt; and extract their capabilities into a "pattern matching" concept over types and values. This can then be applied back to these language features, and other places in the future.&lt;/p&gt;

&lt;p&gt;Before the new concept of patterns, &lt;code&gt;case&lt;/code&gt; accepted a constant as an argument, and &lt;code&gt;is&lt;/code&gt; would accept a type.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Check the type of the variable "is assignable to" Shape
if(widget is Shape)
{
    switch ((widget as Shape).Type)
    {
        // When value matches the constant "Square"
        case "Square":
            // ...
            break;
        default:
            break;
    }
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With the introduction of C# 7.0, both of these language features have been enhanced to use the new Pattern Matching syntax. This is a backwards-compatible change, meaning that the pattern type can be a const or a type. As well as these existing cases, it also includes &lt;code&gt;when&lt;/code&gt; clauses and var patterns as well.&lt;/p&gt;

&lt;h3&gt;
  
  
  is Expression
&lt;/h3&gt;

&lt;p&gt;Originally, &lt;code&gt;is&lt;/code&gt; was able to check a type. This could create more readable code but often left casting or &lt;code&gt;as&lt;/code&gt; operator usage in the aftermath.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if (widget is Shape)
{
    var myShape = widget as Shape;
    // var myShape = (Shape)widget;
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This has been improved by the pattern matching. First, we have constant checking:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if (widget.Type is null)
{
    // ...
}

if (widget.Type is "FOO")
{
    // ...
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As well as this, the Type checking Pattern now includes support to create a scoped variable of the correct type, similar to the new out parameter functionality. This language feature is collectively known as "expression variables".&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if (widget is Shape shape)
{
    // ... use `shape`
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Switch Statement
&lt;/h3&gt;

&lt;p&gt;A switch used to only match on constants, but with the new pattern matching, we can do so much more.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;void SwitchIt(object value)
{
    var result = 0;
    switch (value)
    {
        // We can still switch on constants, even when the types don't match
        case 0:
            break;
        // We can switch on type, and even create a scoped variable (like with `is`)
        case IEnumerable&amp;lt;int&amp;gt; childSequence:
        {
            foreach(var item in childSequence)
                result += (item &amp;gt; 0) ? item : 0;
            break;
        }
        // using `when`, we can do range or bounds checking
        case int n when n &amp;gt; 0:
            result += n;
            break;
        // We can constant check against null
        case null:
            throw new NullReferenceException("Null found in sequence");
        default:
            throw new InvalidOperationException("Unrecognized type");
    }

    return result;
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There is another new pattern that is useful with switch, which is the var pattern. The "var pattern" is similar to the type pattern, except that it always matches, but creates a variable with the assigned value.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;switch(shape)
{
    case Circle c:
        WriteLine($"circle with radius {c.Radius}");
        break;
    case Rectangle s when (s.Length == s.Height):
        WriteLine($"{s.Length} x {s.Height} square");
        break;
    case Rectangle r:
        WriteLine($"{r.Length} x {r.Height} rectangle");
        break;
    case var s:
        // Always matches (similar to default) but gives access to the value as `s`
        WriteLine($"This is some kind of {s.Name} shape");
        break;
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It is worth pointing out that the order of your &lt;code&gt;case&lt;/code&gt; arguments now matters. while not a logical breaking change, since it never mattered what order constants where declared, it would always match the right answer, this is a conceptual change you need to be aware of. Mixing and matching patterns in a switch mean that the order does matter, and the first pattern that matches will get executed. To repeat, when all cases are constants this wouldn't make any difference to the outcome but more advanced checks will.&lt;/p&gt;

&lt;p&gt;In C# 7.1, the patterns were extended to work correctly with generic variables as well. In C# 7.0, you could use these type patterns as expected by first casting the &lt;code&gt;T foo&lt;/code&gt; value to an &lt;code&gt;Object&lt;/code&gt; (which could cause Boxing) and then the type checking would all work. In C# 7.1, this cast is no longer necessary, and also avoids any boxing and unboxing along the way. &lt;a href="https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/switch#type-pattern" rel="noopener noreferrer"&gt;The docs&lt;/a&gt; go over this is more detail with an example comparing the two implementations, as there are a few subtle differences, especially around null/default cases.&lt;/p&gt;

&lt;h3&gt;
  
  
  Pattern Matching coming soon
&lt;/h3&gt;

&lt;p&gt;This feature is an interesting one in the sense that it is both newer and probably under-used and less known. You can program away happily in C# never needing to use it and not coming across it.&lt;/p&gt;

&lt;p&gt;But with C# 8, there is a bunch of new features that will be using this existing pattern matching coming, so you might want to get on board with this in preparation, because soon you will need to understand code using it, and probably see a lot more of it around.&lt;/p&gt;

&lt;p&gt;Bring on the Switch Expression!&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Looking Back on C#: async and await</title>
      <dc:creator>Mark Clearwater</dc:creator>
      <pubDate>Mon, 24 Jun 2019 18:00:00 +0000</pubDate>
      <link>https://dev.to/csmacnz/looking-back-on-c-async-and-await-52f8</link>
      <guid>https://dev.to/csmacnz/looking-back-on-c-async-and-await-52f8</guid>
      <description>&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimages.unsplash.com%2Fphoto-1502426899022-660e3522a15a%3Fixlib%3Drb-1.2.1%26q%3D80%26fm%3Djpg%26crop%3Dentropy%26cs%3Dtinysrgb%26w%3D1080%26fit%3Dmax%26ixid%3DeyJhcHBfaWQiOjE2ODI3fQ" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimages.unsplash.com%2Fphoto-1502426899022-660e3522a15a%3Fixlib%3Drb-1.2.1%26q%3D80%26fm%3Djpg%26crop%3Dentropy%26cs%3Dtinysrgb%26w%3D1080%26fit%3Dmax%26ixid%3DeyJhcHBfaWQiOjE2ODI3fQ" alt="Looking Back on C#: async and await"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With C# 8 on our doorstep, I figure it is a good time to reflect on recent additions to the language that have come before. There are some great improvements you may have missed, some that I really enjoy using, and some I consider have reached canonical usage status that I think are all worth some reflection.&lt;/p&gt;

&lt;p&gt;Multithreaded programming has always been a difficult thing to get your head around, and there are many pitfalls easily stumbled into. To help combat this, Microsoft gave us async/await in C#.&lt;/p&gt;

&lt;p&gt;Async/Await is a language feature that has been around since Visual Studio 2012 and C# 5 and hides a bunch of the boilerplate state machine code required to safely park a logical thread of execution while it waits for some work to complete or to respond from another thread, IO, or network device. This allows code to be more logically procedural and linear, therefore easier to read and comprehend.&lt;/p&gt;

&lt;p&gt;Since it first came out there has been a raft of improvements across different versions of C#.&lt;/p&gt;

&lt;h2&gt;
  
  
  The basics
&lt;/h2&gt;

&lt;p&gt;The foundation of how it all works rests on the shoulders of a Library, the Task Parallel Library, or TPL. Tasks have been around since 2010 and were part of the .Net 4 Framework. Similar to what &lt;a href="https://developers.google.com/web/fundamentals/primers/promises" rel="noopener noreferrer"&gt;Promises provide in javascript&lt;/a&gt;, this library allowed a logical chain of execution across waiting for blocking or longrunning execution while releasing the UI thread from being blocked. This was the introduction of &lt;code&gt;TaskFactory&lt;/code&gt; and &lt;code&gt;Task&lt;/code&gt;, in a fairly similar form to what we have today. This was a huge improvement from the days of callback chaining because it reduced heavy nesting of lambdas into more of a linear pipeline and a clear place for error handling to take place.&lt;/p&gt;

&lt;p&gt;When C# 5 introduced async/await as a first-class language feature, it was able to leverage the library and extend on it to give us more readable code. It even handled Exceptions by throwing them in the place where &lt;code&gt;await&lt;/code&gt; appeared, making &lt;code&gt;try/catch&lt;/code&gt; blocks useful in asynchronous code.&lt;/p&gt;

&lt;p&gt;What does async/await look like in C# 5?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// A classic synchronous method
public string MakeAWebRequest(Uri uri)
{
    // WebClient has synchronous methods, but it is recommended to use HttpClient for newer apps
    var client = new WebClient();
    return client.DownloadString(uri);
}

// It's async younger brother
public async Task&amp;lt;string&amp;gt; MakeAWebRequestAsync(Uri uri)
{
    // I use WebClient again for better comparing. Use HttpClient!
    var client = new WebClient();
    return await client.DownloadStringAsync(uri);
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There are two distinctive features in this comparison. The return type is wrapped in a &lt;code&gt;Task&amp;lt;T&amp;gt;&lt;/code&gt;, and there is a keyword &lt;code&gt;async&lt;/code&gt; on the method signature with &lt;code&gt;await&lt;/code&gt; beside method calls that return &lt;code&gt;Task&amp;lt;T&amp;gt;&lt;/code&gt; results. Otherwise, the linear execution flow is largely unchanged.&lt;/p&gt;

&lt;p&gt;You can easily use the return type without the keywords. In this case, the code works and operates as normal, passing object references around without any async state. The result object captures the state required for the caller to do the asynchronous work in the future, or respond to its completion. However, if you do use &lt;code&gt;async&lt;/code&gt; and &lt;code&gt;await&lt;/code&gt;, then you should always return either &lt;code&gt;Task&lt;/code&gt; (where usually returns void) or &lt;code&gt;Task&amp;lt;T&amp;gt;&lt;/code&gt; (where usually returns T). (In my opinion, there are no reasons left to ever do async without Task - there used to be but not anymore.)&lt;/p&gt;

&lt;p&gt;Now we have that out of the way, let's move forward to C# 6 and beyond!&lt;/p&gt;

&lt;h2&gt;
  
  
  Async and Exceptions
&lt;/h2&gt;

&lt;p&gt;Exception handling was a big part of this feature on day one. You could simply wrap your async calls in a &lt;code&gt;try{}catch{}&lt;/code&gt; and it would work as you would expect it to. The task you are awaiting throws an Exception, your catch triggers.&lt;/p&gt;

&lt;p&gt;But initially, this did not work inside the catch or finally blocks in any expected way. In fact, it caused a compiler error. In C# 6 await in &lt;code&gt;catch&lt;/code&gt;/&lt;code&gt;finally&lt;/code&gt; blocks were given proper compiler support to do the right thing.&lt;/p&gt;

&lt;p&gt;Using the example from &lt;a href="https://github.com/dotnet/roslyn/wiki/New-Language-Features-in-C%23-6#await-in-catch-and-finally-blocks" rel="noopener noreferrer"&gt;The new language feature docs&lt;/a&gt; directly:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Resource res = null;
try
{
    res = await Resource.OpenAsync(…); // You could do this.
    …
} 
catch(ResourceException e)
{
    await Resource.LogAsync(res, e); // Now you can do this …
}
finally
{
    if (res != null) await res.CloseAsync(); // … and this.
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Async and Console Apps
&lt;/h2&gt;

&lt;p&gt;The language version was C# 7. We had async everywhere, and the &lt;code&gt;NetStandard&lt;/code&gt;s and Frameworks were full of async API calls and interfaces. It was a contagious thing, and you really had to jump through hoops to try &lt;a href="https://journal.stuffwithstuff.com/2015/02/01/what-color-is-your-function/" rel="noopener noreferrer"&gt;to call a red function from a blue one&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;And then there was main. That pesky little entry point into your application. The one the compiler generates for you that kicks off all of the application execution. The one that had to call into your top-most async method to &lt;code&gt;RunAsync&lt;/code&gt;. And it had to be &lt;code&gt;public static void Main(string[] args)&lt;/code&gt; or &lt;code&gt;public static int Main()&lt;/code&gt;. That is not an async method.&lt;/p&gt;

&lt;p&gt;Luckily, with the first ever minor language update, C# 7.1, we were given the mighty and powerful async main!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// You can finaly use Task&amp;lt;int&amp;gt;!
public static async Task&amp;lt;int&amp;gt; Main()
{
...
}

// Also available in no return value flavour!
public static async Task Main()
{
...
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Async and Tests
&lt;/h2&gt;

&lt;p&gt;We have a tonne of async methods in our system. But we should also be testing that code. And our testing frameworks were synchronous.&lt;/p&gt;

&lt;p&gt;Luckily our testing frameworks have finally caught up, and with XUnit we can write tests that return Task and are async&lt;code&gt;, and we also have the&lt;/code&gt;IAsyncLifetime` interface.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`&lt;br&gt;
// This is what we had to do to test async&lt;br&gt;
public class MyTestCase&lt;br&gt;
{&lt;br&gt;
    private readonly MyClass _systemUnderTest;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public MyTestCase()
{
    _systemUnderTest = MyClass();

    Task.Run(async () =&amp;gt; await _systemUnderTest.Init()).GetAwaiter().GetResult();
}

public void CanRunSuccessfully()
{

    var result = Task.Run(async () =&amp;gt; await _systemUnderTest.Run()).GetAwaiter().GetResult();

    Assert.True(result);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;}&lt;/p&gt;

&lt;p&gt;`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Using &lt;code&gt;Task.Run&lt;/code&gt; and &lt;code&gt;GetAwaiter&lt;/code&gt; or other synchronising methods can be very error-prone, and &lt;a href="https://blog.stephencleary.com/2012/07/dont-block-on-async-code.html#preventing-the-deadlock" rel="noopener noreferrer"&gt;prone to deadlocks&lt;/a&gt;. Avoiding these is the best approach always (though still not always avoidable).&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`&lt;br&gt;
The best way to tet with async&lt;br&gt;
public class MyTestCase : IAsyncLifetime&lt;br&gt;
{&lt;br&gt;
    private readonly MyClass _systemUnderTest;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public MyTestCase()
{
    _systemUnderTest = MyClass();
}

public async Task InitializeAsync()
{
    await _systemUnderTest.Init();
}

public Task DisposeAsync()
{
    return Task.CompletedTask;
}

public async Task CanRunSuccessfully()
{

    var result = await _systemUnderTest.Run();

    Assert.True(result);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;}&lt;/p&gt;

&lt;p&gt;`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;I'm not sure if other test runners are able to handle async as well as XUnit does, so I always just use XUnit.&lt;/p&gt;

&lt;h2&gt;
  
  
  ValueTask
&lt;/h2&gt;

&lt;p&gt;The original implementation of the async/await language feature was strongly tied to the &lt;code&gt;Task&lt;/code&gt; and `Task types.&lt;/p&gt;

&lt;p&gt;In C# 7, the language feature was enhanced, similar to other features, to use a pattern based on method signatures (like the &lt;a href="https://dev.to/csmacnz/looking-back-on-c-6-initializers-1h2k"&gt;Add for the initialiser syntax&lt;/a&gt;). Specifically, the &lt;code&gt;GetAwaiter&lt;/code&gt; method must be available on the type used with the &lt;code&gt;await&lt;/code&gt; keyword.&lt;/p&gt;

&lt;p&gt;Along with this change was the introduction of a new type to leverage this pattern, &lt;code&gt;ValueTask&lt;/code&gt;. A &lt;code&gt;ValueTask&lt;/code&gt; is a value type (struct) that will be stack-allocated and copied by value. If your method uses caching, and most of the time returns a simple value instead of an awaited execution, the &lt;code&gt;ValueTask&lt;/code&gt; may be more efficient than the &lt;code&gt;Task&lt;/code&gt; type.&lt;/p&gt;

&lt;p&gt;This is because the overheads of Heap-allocation of the reference type &lt;code&gt;Task&lt;/code&gt; can have an impact on performance. If you detect this as an issue, you can use the new &lt;code&gt;ValueTask&lt;/code&gt; instead. This will be a stack-allocated value type containing the response value and copied around.&lt;/p&gt;

&lt;p&gt;Guidance for this: if you mostly return a value, but occasionally call an actual asynchronous IO execution, &lt;code&gt;ValueTask&lt;/code&gt; will probably add value (e.g. heavy result caching). If you actually await most of the time, &lt;code&gt;Task&lt;/code&gt; should be fine. As usual, measure and test before making the change arbitrarily.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Async programming is becoming the canonical way of building apps with IO in most languages. And in practice, most of the apps I write are IO-bound apps. C# and dotnet make this simple with &lt;code&gt;async/await&lt;/code&gt; and the language keeps improving our experience using this successfully. This is a must-use feature that is unavoidable, but knowing the limitations and extensions available to use it well is still very important to do. Use it, but make sure you know enough about how it works to use it well.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Looking Back on C# 7: refs enhancements</title>
      <dc:creator>Mark Clearwater</dc:creator>
      <pubDate>Mon, 17 Jun 2019 18:00:00 +0000</pubDate>
      <link>https://dev.to/csmacnz/looking-back-on-c-7-refs-enhancements-2cka</link>
      <guid>https://dev.to/csmacnz/looking-back-on-c-7-refs-enhancements-2cka</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--TI-DMmkR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://images.unsplash.com/photo-1530226406379-f84b9edd291b%3Fixlib%3Drb-1.2.1%26q%3D80%26fm%3Djpg%26crop%3Dentropy%26cs%3Dtinysrgb%26w%3D1080%26fit%3Dmax%26ixid%3DeyJhcHBfaWQiOjE2ODI3fQ" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--TI-DMmkR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://images.unsplash.com/photo-1530226406379-f84b9edd291b%3Fixlib%3Drb-1.2.1%26q%3D80%26fm%3Djpg%26crop%3Dentropy%26cs%3Dtinysrgb%26w%3D1080%26fit%3Dmax%26ixid%3DeyJhcHBfaWQiOjE2ODI3fQ" alt="Looking Back on C# 7: refs enhancements"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With C# 8 on our doorstep, I figure it is a good time to reflect on recent additions to the language that have come before. There are some great improvements you may have missed, some that I really enjoy using, and some I consider have reached canonical usage status that I think are all worth some reflection.&lt;/p&gt;

&lt;p&gt;We talked about the out variables &lt;a href="https://blog.csmac.nz/looking-back-on-csharp7-out-variables"&gt;in the previous post in the series&lt;/a&gt;, but there are a few other enhancements related to &lt;code&gt;ref&lt;/code&gt; as well.&lt;/p&gt;

&lt;p&gt;Hopefully, the concepts of values, pointers, stacks and heaps make sense to you at a conceptual level. These are crucial concepts to using and understanding &lt;code&gt;ref&lt;/code&gt; and &lt;code&gt;out&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;As a quick recap, stack memory is local to a function and the function call stack. This memory is semantically "pushed" to for each method call, and "popped" from on each return (the call stack, stack overflow etc). The heap is a shared memory space where objects are allocated and stored, which is acted on by the Garbage Collector.&lt;/p&gt;

&lt;p&gt;Values are mostly stack-allocated. They are copied around so that setting a value variable does not affect any other variable. Primitive types and structs are Value types. Reference types are the classes in C#. Classes are always stored on the heap, and all variables of class types are pointers or references. Assigning a reference to a new variable will point to the same value on the heap. Changing a field value on a reference type will be reflected in both variables. (Boxing values onto the heap is another thing, too.)&lt;/p&gt;

&lt;p&gt;We already have &lt;code&gt;out&lt;/code&gt; that allows the caller to declare a variable on the current stack that it passes by address (pointer, reference, or ref) that the method is contracted to set for you. This essentially gives us some of the power of reference types from a stack-allocated value. When we use &lt;code&gt;ref&lt;/code&gt;, we gain all of the power of passing by reference that we have from heap allocated class types. We are essentially saying that the caller can use the existing value of the reference, and also set a new value to the stack variable if it wants to as well. Basically, all the restrictions that &lt;code&gt;out&lt;/code&gt; imposes are taken off. A ref may not just be a stack variable, but could also be a field on a class that you want to access directly by reference, instead of having to constantly dereference it.&lt;/p&gt;

&lt;p&gt;Pass by &lt;code&gt;ref&lt;/code&gt; has been in C# since the beginning, but like the &lt;code&gt;out&lt;/code&gt; parameters, only works in method signatures. However, from the beginning, you could never declare a &lt;code&gt;ref&lt;/code&gt; variable.&lt;/p&gt;

&lt;p&gt;In C# 7, &lt;code&gt;ref&lt;/code&gt; has been extended to work with return types, and with variables. You can return a value by reference. And so that it the returned result can be assigned to something in a useful way, we also now have &lt;code&gt;ref&lt;/code&gt; variable typing. Like most C# language features, there is safety built in.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You must add the &lt;code&gt;ref&lt;/code&gt; keyword to the method signature and to all return statements in a method.&lt;/li&gt;
&lt;li&gt;A &lt;code&gt;ref&lt;/code&gt; return may be assigned to a value variable (by copy) or a &lt;code&gt;ref&lt;/code&gt; variable.&lt;/li&gt;
&lt;li&gt;You can't assign a standard method return value to a &lt;code&gt;ref&lt;/code&gt; local variable.&lt;/li&gt;
&lt;li&gt;You can't return a &lt;code&gt;ref&lt;/code&gt; to a variable whose lifetime doesn't extend beyond the execution of the method.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These rules ensure the safety of your code and ensure readability, that it is clear about what is happening.&lt;/p&gt;

&lt;p&gt;I'm going to blatantly steal &lt;a href="https://docs.microsoft.com/en-us/dotnet/csharp/whats-new/csharp-7#ref-locals-and-returns"&gt;the Microsoft examples&lt;/a&gt; for this because I don't want to invent an example and get it wrong.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// We declare the method as returning by reference (rather than copy)
public ref int Find(int number, int[] numbers)
{
    for (int i = 0; i &amp;lt; numbers.Length; i++)
    {
        if (numbers[i] == number)
        {
            // All returns must use the `ref` keyword
            return ref numbers[i]; // return the storage location, not the value
        }
    }
    // We can still throw an exception if necessary
    throw new IndexOutOfRangeException($"{nameof(number)} not found");
}

// arrays are already allocated to the heap and passed by reference rather than by value
// (see the `stackalloc` keyword for stack allocating arrays, though)
int[] array = { 1, 15, -39, 0, 7, 14, -12 };

// We have to use `ref` to call the method
// We choose to declare `place` as a reference
ref int place = ref Find(7, array); // aliases 7's place in the array
place = 9; // replaces 7 with 9 in the array
WriteLine(array[4]); // prints 9

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;In the above example, we could have chosen to declare &lt;code&gt;place&lt;/code&gt; without the &lt;code&gt;ref&lt;/code&gt; keyword and the value returned would be copied instead. However, in this case, the assignment of &lt;code&gt;place = 9;&lt;/code&gt; would be overriding the local copy, and not modifying the original array.&lt;/p&gt;

&lt;p&gt;Why would you use these pass by reference additions? Huge performance enhancements can be achieved by avoiding stack and heap copying or dereferencing of values in certain algorithms. Performance is the name of the game here.&lt;/p&gt;

&lt;p&gt;In C# 7.2, the conditional operator (&lt;code&gt;isTrue ? x : y&lt;/code&gt; syntax) can now evaluate to a reference result when both operands (&lt;code&gt;x&lt;/code&gt; and &lt;code&gt;y&lt;/code&gt; above) are also references.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;ref var r = ref (arr != null ? ref arr[0] : ref otherArr[0]);&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;In 7.2 we also got &lt;code&gt;ref readonly&lt;/code&gt;, which allows returned references to disallow modification enforced by the compiler. This may save time constantly dereferencing a child field in a scenario that you need to get the latest value, for instance in a loop. Again, performance is the target use-case.&lt;/p&gt;

&lt;p&gt;The first version of &lt;code&gt;ref&lt;/code&gt; variables was immutable only. Whatever you declared them to point to was what they always referred to for their lifetime. In C# 7.3, they were updated so you can reuse a variable to point to a different reference instead.&lt;/p&gt;

&lt;p&gt;To complement the safety of the &lt;code&gt;out&lt;/code&gt; restrictions compared to &lt;code&gt;ref&lt;/code&gt; we also get the &lt;code&gt;in&lt;/code&gt; keyword.&lt;/p&gt;

&lt;p&gt;Declaring a method parameter with &lt;code&gt;in&lt;/code&gt; essentially makes it a read-only reference. the method is not allowed to modify the value passed in but gets all the benefits of being passed by reference rather than by value (copied). The &lt;code&gt;in&lt;/code&gt; keyword will make the compiler ensure that the method is not allowed to modify the original passed in value. If necessary it will create a defensive shadow-copy to ensure that is true.&lt;/p&gt;

&lt;p&gt;This is well paired with another new feature, &lt;code&gt;readonly struct&lt;/code&gt;. Declaring a struct as read-only means the compiler will ensure you are indeed read-only. (It will disallow &lt;code&gt;public int Foo { get; private set; }&lt;/code&gt; for example.) You can use the &lt;code&gt;in&lt;/code&gt; keyword for any methods that you want to take a ref to one of these structs again to ensure clarity when reading the code, but also enforced by the compiler.&lt;/p&gt;

&lt;p&gt;I mentioned the defensive shadow copy above. The language and runtime do not guarantee that the internal implementation detail of a Property or Method is non-mutable from the contracts, so the compiler will get defensive, and make copies before calling anything that might cause a mutation. This way, the language guarantees the expectations of passing a read-only reference, but maybe doesn't match performance expectations in the process. As a developer, by making the type a &lt;code&gt;readonly struct&lt;/code&gt; instead, the compiler can rely on the guarantees and won't make any copies. The struct won't compile if it mutates any of its internal state, so we have stronger guarantees at compile-time and run-time.&lt;/p&gt;

&lt;p&gt;These features are certainly power features, and when you need them they will be useful. But like most advanced features, you may be sacrificing readability for performance and optimisation. Use sparingly, but maybe measure first and then sprinkle in and measure again.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Looking Back on C# 7: Out variables</title>
      <dc:creator>Mark Clearwater</dc:creator>
      <pubDate>Mon, 10 Jun 2019 18:00:00 +0000</pubDate>
      <link>https://dev.to/csmacnz/looking-back-on-c-7-out-variables-4b41</link>
      <guid>https://dev.to/csmacnz/looking-back-on-c-7-out-variables-4b41</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--TI-DMmkR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://images.unsplash.com/photo-1530226406379-f84b9edd291b%3Fixlib%3Drb-1.2.1%26q%3D80%26fm%3Djpg%26crop%3Dentropy%26cs%3Dtinysrgb%26w%3D1080%26fit%3Dmax%26ixid%3DeyJhcHBfaWQiOjE2ODI3fQ" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--TI-DMmkR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://images.unsplash.com/photo-1530226406379-f84b9edd291b%3Fixlib%3Drb-1.2.1%26q%3D80%26fm%3Djpg%26crop%3Dentropy%26cs%3Dtinysrgb%26w%3D1080%26fit%3Dmax%26ixid%3DeyJhcHBfaWQiOjE2ODI3fQ" alt="Looking Back on C# 7: Out variables"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With C# 8 on our doorstep, I figure it is a good time to reflect on recent additions to the language that have come before. There are some great improvements you may have missed, some that I really enjoy using, and some I consider have reached canonical usage status that I think are all worth some reflection.&lt;/p&gt;

&lt;h3&gt;
  
  
  What are out parameters?
&lt;/h3&gt;

&lt;p&gt;Sometimes you want a method to pass back a value by reference. In &lt;code&gt;C&lt;/code&gt; and &lt;code&gt;C++&lt;/code&gt; this is done by passing the address in as an argument. In C#, we use the &lt;code&gt;out&lt;/code&gt; keyword.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public bool HasCount(string str, out int length)
{
    length = 0;
    if (str.Length &amp;gt; 0)
    {
        length = str.Length;
        return true;
    }
}

string myString = "A String";
int length;
if (HasCount(myString, out length))
{
    // Do some stuff here.
}

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;A method must initialise the out parameter value, but the caller doesn't have to initialise it first. Callers must use the &lt;code&gt;out&lt;/code&gt; keyword when calling a method with an out parameter. This helps with readability making it unambiguous how it works.&lt;/p&gt;

&lt;p&gt;More details of this for those unfamiliar with the concept can be &lt;a href="https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/out-parameter-modifier"&gt;found here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;In the libraries, there are a few methods that use this, for instance &lt;code&gt;Int32.TryParse&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;int number;
if (Int32.TryParse(numberAsString, out number))
{
    // use `number` as an integer value. 
}

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;It also comes in useful when you are building C-style interops. But not something you see very much these days.&lt;/p&gt;

&lt;h3&gt;
  
  
  New out variables
&lt;/h3&gt;

&lt;p&gt;This syntax always felt a bit clunky. Modern APIs would suggest using a return value over an out parameter, and the early use cases tended to be either cross-compatibility with C libraries or parse scenarios. Primarily it was discouraged for readability reasons, though there are benefits from using it in certain places.&lt;/p&gt;

&lt;p&gt;However, with C# 7, a new syntax was introduced, allowing inline declaration of out parameters.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if (Int32.TryParse(numberAsString, out int number))
{
    // use `number` as an integer value. 
}

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;You can now declare the parameter inline, without needing the empty declaration line that was essentially wasting line-count. The other benefit is you can now use &lt;code&gt;var&lt;/code&gt; instead of an explicit type.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if (Int32.TryParse(numberAsString, out var number))
{
    // use `number` as an integer value. 
}

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;In C# 7.3, this &lt;code&gt;out&lt;/code&gt; variable syntax was extended to include field initializers, property initializers, constructor initializers, and query clauses. Basically, you have the power to use this everywhere that you can use out parameters.&lt;/p&gt;

&lt;p&gt;With the new changes, readability has hugely increased, the risk of using the value before initialisation has been removed, and it is probably something worth encouraging using again in those methods that could benefit with having out parameters for clean APIs, and performance.&lt;/p&gt;

&lt;p&gt;A small but simple improvement to the language that I would replace in every place you use &lt;code&gt;out&lt;/code&gt; parameters.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Looking Back on C# 7: Local functions</title>
      <dc:creator>Mark Clearwater</dc:creator>
      <pubDate>Mon, 03 Jun 2019 22:00:00 +0000</pubDate>
      <link>https://dev.to/csmacnz/looking-back-on-c-7-local-functions-2715</link>
      <guid>https://dev.to/csmacnz/looking-back-on-c-7-local-functions-2715</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--TI-DMmkR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://images.unsplash.com/photo-1530226406379-f84b9edd291b%3Fixlib%3Drb-1.2.1%26q%3D80%26fm%3Djpg%26crop%3Dentropy%26cs%3Dtinysrgb%26w%3D1080%26fit%3Dmax%26ixid%3DeyJhcHBfaWQiOjE2ODI3fQ" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--TI-DMmkR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://images.unsplash.com/photo-1530226406379-f84b9edd291b%3Fixlib%3Drb-1.2.1%26q%3D80%26fm%3Djpg%26crop%3Dentropy%26cs%3Dtinysrgb%26w%3D1080%26fit%3Dmax%26ixid%3DeyJhcHBfaWQiOjE2ODI3fQ" alt="Looking Back on C# 7: Local functions"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With C# 8 on our doorstep, I figure it is a good time to reflect on recent additions to the language that have come before. There are some great improvements you may have missed, some that I really enjoy using, and some I consider have reached canonical usage status that I think are all worth some reflection.&lt;/p&gt;

&lt;h2&gt;
  
  
  Lambdas - a recap
&lt;/h2&gt;

&lt;p&gt;All the way back in C# 3 we were given lambdas. These are anonymous functions that can be passed around as what are essentially function pointers.&lt;/p&gt;

&lt;p&gt;"Anonymous" refers to the fact that the function has no name, and is not tied to an actual class or instance. The term comes from functional programming.&lt;/p&gt;

&lt;p&gt;In terms of implementation details, there are two categories of lambdas, those which stand alone and are pure functions, and those that have a captured scope, known as a closure. Closure, again, is a functional programming term. We capture variables from the scope of the parent and encapsulate them into this anonymous function instance.&lt;/p&gt;

&lt;p&gt;Pure functions can easily be refactored into a public static function in a static class very easily, and the compilation is very similar.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
static Action&amp;lt;int&amp;gt; GetRandomValueFunction()
{
    Console.WriteLine("Use static value for counter: {0}", counter);
    return () =&amp;gt; 5;
}

// These two methods are the same as the above
static Action&amp;lt;int&amp;gt; GetRandomValueFunction()
{
    Console.WriteLine("Use static value for counter: {0}", counter);
    return StaticValueFunction;
}

static int StaticValueFunction()
{
    return 5;
}

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;There is no simple construct equivalent for closures. Hopefully, by example, we can see how these transform into simple static methods anyway. (In an example stolen from &lt;a href="https://stackoverflow.com/a/5438331/2118268"&gt;SO&lt;/a&gt;)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt; static Action CreateShowAndIncrementAction()
{
    Random rng = new Random();
    int counter = rng.Next(10);
    Console.WriteLine("Initial value for counter: {0}", counter);
    return () =&amp;gt;
    {
        Console.WriteLine(counter);
        counter++;
    };
}

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Given the above C# code, the compiled code will more closely resemble the below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
static Action CreateShowAndIncrementAction()
{
    ActionHelper helper = new ActionHelper();        
    Random rng = new Random();
    helper.counter = rng.Next(10);
    Console.WriteLine("Initial value for counter: {0}", helper.counter);

    // 
    return helper.DoAction;
}

class ActionHelper
{
    public int counter;

    public void DoAction()
    {
        Console.WriteLine(counter);
        counter++;
    }
}

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Because the compiler generates these, it also controls access and visibility, so that you cannot actually access it in this way from your code directly. But it does all this automatically for you, and with fewer lines of code to achieve the same logical execution. It is also clearer from the lambda version that the calling method is the owner of the function, and no one else can or should share it.&lt;/p&gt;

&lt;p&gt;Clearly, lambdas reduce our lines of code and are superior.&lt;/p&gt;

&lt;h2&gt;
  
  
  working with lambdas
&lt;/h2&gt;

&lt;p&gt;Sometimes, though, your lambdas get complicated. When you have big complicated lambdas inside LINQ pipelines, it gets messy fast.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public List&amp;lt;Widget&amp;gt; GetWidgetsByPlumbob(string plumb, int restrictionNumber)
{
    var restriction = _store.GetRestriction(restrictionNumber);


    // This `where` clause is only going to get more complicated from here.
    _store
        .GetWidgets()
        .Where(w =&amp;gt; (w.PlumbBob.StartsWith(plumbob) || w.PlumbBob.EndsWith(plumbob)) &amp;amp;&amp;amp; w.Restriction == restriction)
        .Select(Map)
        .ToList();
}

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;We have a few options prior to C# 7:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public List&amp;lt;Widget&amp;gt; GetWidgetsByPlumbob(string plumb, int restrictionNumber)
{
    var restriction = _store.GetRestriction(restrictionNumber);

    _store
        .GetWidgets()
        .Where(w =&amp;gt; Filter(w, plumb, restriction))
        .Select(Map)
        .ToList();
}

private bool Filter(Widget widget, string plumb, Restriction restriction)
{
    return (w.PlumbBob.StartsWith(plumbob) || w.PlumbBob.EndsWith(plumbob)) &amp;amp;&amp;amp; w.Restriction &amp;gt; restriction;
}

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;There are a couple of problems with this. We are now passing all the parameters through to the nested function. This is fine, but from a maintenance point of view, we might add more parameters and we now end up maintaining two signatures every time we change.&lt;/p&gt;

&lt;p&gt;Also, we open up for another function to start using the "sharable" filter function. Now we would be coupled to that new function. We can't change our own filter without affecting that other new function, and that adds brittle fragility. Sometimes duplicating logic that has different reasons to change is worth the duplication, but the architecture of this code does not guard against this.&lt;/p&gt;

&lt;p&gt;Another example is to pull the lambda into a variable:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public List&amp;lt;Widget&amp;gt; GetWidgetsByPlumbob(string plumb, int restrictionNumber)
{
    var restriction = _store.GetRestriction(restrictionNumber);

    var filter = w =&amp;gt; (w.PlumbBob.StartsWith(plumbob) || w.PlumbBob.EndsWith(plumbob)) &amp;amp;&amp;amp; w.Restriction == restriction);

    _store
        .GetWidgets()
        .Where(filter)
        .Select(Map)
        .ToList();
}

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Looking at the example, it adds some simplification. Because like the original example this lambda is a closure, the lambda can match the expected signature of the &lt;code&gt;Where&lt;/code&gt; LINQ Extension.&lt;/p&gt;

&lt;p&gt;However, sometimes this approach causes issues with type interpolation. That is, if you pull out into a variable, often you can't use &lt;code&gt;var&lt;/code&gt; or need to add explicit type casting to help the compiler out, or it will not compile.&lt;/p&gt;

&lt;p&gt;I don't think we have actually helped with the readability as much as we would like. It may not be obvious on the first pass of reading the function that this is a lambda, not a statement. This is also a simple example, and they can get more complex fast.&lt;/p&gt;

&lt;h2&gt;
  
  
  Put functions inside your functions!
&lt;/h2&gt;

&lt;p&gt;With C# 7, we can now use a nested function. This gives us the benefits of not polluting the namespace of the class, while also making it more readable. It also makes it clearer that the function is owned by the caller as the only consumer.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public List&amp;lt;Widget&amp;gt; GetWidgetsByPlumbob(string plumb, int restrictionNumber)
{
    var restriction = _store.GetRestriction(restrictionNumber);

    bool Filter(Widget widget)
    {
        return (w.PlumbBob.StartsWith(plumb) || w.PlumbBob.EndsWith(plumb)) &amp;amp;&amp;amp; w.Restriction &amp;gt; restriction;
    }

    _store
        .GetWidgets()
        .Where(Filter)
        .Select(Map)
        .ToList();
}

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Our compiler now ensures no one else can use this function. It is only callable from this method and gives the reader the knowledge that this is a specific implementation detail for this function only and not a shared common piece of logic. (Encapsulation.)&lt;/p&gt;

&lt;p&gt;In this example it also still allows us to use the simplified &lt;code&gt;Where&lt;/code&gt; call.&lt;/p&gt;

&lt;p&gt;The best example of where this is really useful is recursion.&lt;/p&gt;

&lt;p&gt;Often a recursive algorithm has a bootstrap function, that then calls the recursive part. Let's print a tree of items with indentations.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public static void PrintLines(TextWriter out, Tree items)
{
    out.WriteLine(items.Title);
    foreach(var node in items.Children)
    {
        Print(out, node, "");
    }
}

private void Print(TextWriter out, TreeNode node, string indent)
{
    out.WriteLine("{0}{1}", indent, items.Title);
    if(node.HasChildren)
    {
        foreach(var node in items.Children)
        {
            Print(out, node indent + " ");
        }
    }
}

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;For simplicity you can now write this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public static void PrintLines(TextWriter out, Tree items)
{
    void Print(TreeNode node, string indent)
    {
        out.WriteLine("{0}{1}", indent, items.Title);
        if(node.HasChildren)
        {
            foreach(var node in items.Children)
            {
                Print(out, node indent + " ");
            }
        }
    }

    out.WriteLine(items.Title);
    foreach(var node in items.Children)
    {
        Print(node, "");
    }
}

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;This example may not reduce lines of code by much, but the cognitive load of the encapsulation can be hugely beneficial when in a class with more service methods as well.&lt;/p&gt;

&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;The cliché "another tool in the toolbelt" comes to mind but this is certainly that, and sprinkled through code strategically can really help with readability and maintainability. Not a "use often" but certainly something I can and have used in my dotnet apps.&lt;/p&gt;

</description>
      <category>csharp</category>
    </item>
    <item>
      <title>µCon 2019 - Day 3</title>
      <dc:creator>Mark Clearwater</dc:creator>
      <pubDate>Fri, 31 May 2019 22:00:00 +0000</pubDate>
      <link>https://dev.to/csmacnz/con-2019-day-3-2ld5</link>
      <guid>https://dev.to/csmacnz/con-2019-day-3-2ld5</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--6BV6RNX---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://blog.csmac.nz/content/images/2019/05/IMG_20190531_090808-2.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--6BV6RNX---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://blog.csmac.nz/content/images/2019/05/IMG_20190531_090808-2.jpg" alt="µCon 2019 - Day 3"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Good morning day 3. So much to absorb already from &lt;a href="https://dev.to/csmacnz/con-2019-day-1-2-1cmb"&gt;Day 1 and 2&lt;/a&gt; but it isn't over yet.&lt;/p&gt;

&lt;p&gt;This morning's Keynote "Crossing the River by Feeling the Stones" from &lt;a href="https://twitter.com/swardley"&gt;Simon Wardley&lt;/a&gt; is a must see. This was a very educational look at the value of maps, and the importance of knowing the landscape, looking at Evolutionary Flow and not just Process Flow when looking at optimisations. I would recommend the talk from Susanne Kaiser "Preparing for a future Microservices journey" from the day before as a nice companion to this keynote talk, as she used "Wardley Maps" to specifically look at the evolution towards microservices. (Though this keynote also shows that journey towards the end as well).&lt;/p&gt;

&lt;p&gt;"Exploring your Microservices Architecture Through Graph Theory" from &lt;a href="https://twitter.com/techiewatt"&gt;Nicki Watt&lt;/a&gt; was a great look at applying Graph Theory to distributed systems, especially with Microservices to gain insight into where architectural smells may exist using different analysis metrics.&lt;/p&gt;

&lt;p&gt;The before lunch slot was "Awesome CI/CD Data Pipelines for Distributed Data-Sources" from &lt;a href="https://twitter.com/ChrisBurrell7"&gt;Chris Burrell&lt;/a&gt;. This was a walkthrough of mining data sources (load and transform) from Microservices into RedShift in a pipeline approach.&lt;/p&gt;

&lt;p&gt;"An Engineer's Guide to a Good Night's Sleep" had &lt;a href="https://twitter.com/NickyWrightson"&gt;Nicky Wrightson&lt;/a&gt; giving a great Engineers Guide to Ops approach to building software, with 5 rules for building better systems so you don't have to be woken up at 3 am. Slides available here: &lt;a href="https://speakerdeck.com/nickywrightson"&gt;https://speakerdeck.com/nickywrightson&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://twitter.com/matthiasnoback"&gt;Matthias Noback&lt;/a&gt; presented "Beyond Design Principles and Patterns: Writing Good Object-Oriented Code" which was a great look at Object-Oriented code done right, in a nice succinctly laid out path from the ground up. I want to steal the whole thing as a blog post it was so well put together. Although there were code examples (Java?), the concepts given transcended across any OO language and presented in a nice language-agnostic way. Unfortunately, I didn't learn anything new, and I also had nothing to disagree with either.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://twitter.com/mufridk"&gt;Mufrid Krilic&lt;/a&gt; gave an interesting Lightning Talk: "Domain Model in Multi-Language Environment with Examples from Healthcare" which was a brief conversation about ubiquitous language when your code is in English but your domain is in Norwegian. This was from experience with a hospital software system.&lt;/p&gt;

&lt;p&gt;To round out the weeks Lightning Talks was "Don't Rebuild your Monolith!" by &lt;a href="https://twitter.com/PeterAnning"&gt;Peter Anning&lt;/a&gt;. An epic tale of transformation from Monolith, to Microservices, regrets and reaffirmations. An entertaining watch with the takeaway that processes like DevOps, Agile and Ubiquitous Langage that come out of moving to microservices must be maintained and assimilated, lest we forget and the monolith grows back.&lt;/p&gt;

&lt;p&gt;And last but not least, we have the final Keynote: "Temporal Modelling" from &lt;a href="https://twitter.com/mathiasverraes"&gt;Mathias Verraes&lt;/a&gt;. A really good overview conversation into Event-based systems, Event Storming and why modelling the Events of your system is of greater benefit than to use Entity Modelling instead. Another recommended one to expand your thinking.&lt;/p&gt;

&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;And that's a wrap! 2019 µCon is done and dusted. Lots to take in, lots to revisit from the recordings, and a bunch of sessions missed that need to be watched.&lt;/p&gt;

&lt;p&gt;The amazing crew doing the filming have been working away getting all the videos up as quickly as possible (on the day recorded for the most part!). You can head over to Skills Matter and watch them all from the links provided off of the &lt;a href="https://skillsmatter.com/conferences/11982-con-london-2019-the-conference-on-microservices-ddd-and-software-architecture#program"&gt;Schedule here&lt;/a&gt;. Take this and &lt;a href="https://dev.to/csmacnz/con-2019-day-1-2-1cmb"&gt;the previous part&lt;/a&gt; as a guide for where to begin but continue through all the other amazing talks I didn't have time to attend in person as well.&lt;/p&gt;

&lt;p&gt;Happy Learning!&lt;/p&gt;

</description>
      <category>conference</category>
      <category>mucon</category>
      <category>ddd</category>
      <category>microservices</category>
    </item>
    <item>
      <title>µCon 2019 - Day 1 &amp; 2</title>
      <dc:creator>Mark Clearwater</dc:creator>
      <pubDate>Fri, 31 May 2019 08:05:21 +0000</pubDate>
      <link>https://dev.to/csmacnz/con-2019-day-1-2-1cmb</link>
      <guid>https://dev.to/csmacnz/con-2019-day-1-2-1cmb</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--cOqMYmvq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://blog.csmac.nz/content/images/2019/05/IMG_20190529_100637.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--cOqMYmvq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://blog.csmac.nz/content/images/2019/05/IMG_20190529_100637.jpg" alt="µCon 2019 - Day 1 &amp;amp; 2"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After a restful night at a London hotel (I learned my lesson from the last time I came in for a London conference) coffee and breakfast at the Business Design Centre in London, muCon 2019 kicks off. muCon (or µCon) is a Conference on Microservices, DDD &amp;amp; Software Architecture. From what I gather, this year for the first time it is an amalgamation of a DDD and Microservices conference into one. I'm here for three days. At this point, I've gotten into a rhythm of blogging about my Conference Experiences so here we go again!&lt;/p&gt;

&lt;h2&gt;
  
  
  Day 1
&lt;/h2&gt;

&lt;p&gt;We kick off with an excellent keynote from &lt;a href="https://twitter.com/mfeathers"&gt;Michael Feathers&lt;/a&gt; which captures various ideologies and principles applied to team and code architecture both at the class level, microservice level and interpersonal individual and team level as well.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;NEW &lt;a href="https://twitter.com/hashtag/muCon?src=hash&amp;amp;ref_src=twsrc%5Etfw"&gt;#muCon&lt;/a&gt; London 2019 &lt;a href="https://twitter.com/hashtag/keynote?src=hash&amp;amp;ref_src=twsrc%5Etfw"&gt;#keynote&lt;/a&gt; &lt;a href="https://twitter.com/hashtag/SkillsCast?src=hash&amp;amp;ref_src=twsrc%5Etfw"&gt;#SkillsCast&lt;/a&gt;: &lt;a href="https://twitter.com/mfeathers?ref_src=twsrc%5Etfw"&gt;@mfeathers&lt;/a&gt; explores system structures present in design to create simpler systems.  &lt;/p&gt;

&lt;p&gt;Click here for video: &lt;a href="https://t.co/y2Y7F63BrB"&gt;https://t.co/y2Y7F63BrB&lt;/a&gt; &lt;a href="https://twitter.com/hashtag/SystemStructure?src=hash&amp;amp;ref_src=twsrc%5Etfw"&gt;#SystemStructure&lt;/a&gt; &lt;a href="https://twitter.com/hashtag/LegacyCode?src=hash&amp;amp;ref_src=twsrc%5Etfw"&gt;#LegacyCode&lt;/a&gt; &lt;a href="https://twitter.com/hashtag/MicroserviceArchitecture?src=hash&amp;amp;ref_src=twsrc%5Etfw"&gt;#MicroserviceArchitecture&lt;/a&gt; &lt;a href="https://twitter.com/hashtag/Architecture?src=hash&amp;amp;ref_src=twsrc%5Etfw"&gt;#Architecture&lt;/a&gt; &lt;a href="https://t.co/ApXVjdgbNA"&gt;pic.twitter.com/ApXVjdgbNA&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;— Skills Matter (@skillsmatter) &lt;a href="https://twitter.com/skillsmatter/status/1133735092554272769?ref_src=twsrc%5Etfw"&gt;May 29, 2019&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;As usual, the day is split into tracks, so I can only give experience on where I've been and guidance of which speakers and talks I would look out for in the future.&lt;/p&gt;

&lt;p&gt;Following on from the keynote for me was "Microservices from Day One" from &lt;a href="https://twitter.com/rjrodger"&gt;Richard Rodger&lt;/a&gt;. First-hand experience of building Microservices on a greenfields startup after &lt;a href="https://www.manning.com/books/the-tao-of-microservices"&gt;literally writing a book on Microservices&lt;/a&gt; development, a chance to practice what he preached. An interesting takeaway that I liked was to design a message-centric system of components(microservices) and then the transport/routing layer doesn't matter (from a technology point of view). This resonates with me because it aligns nicely with the Ports and Adapters architecture.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;NEW &lt;a href="https://twitter.com/hashtag/muCon?src=hash&amp;amp;ref_src=twsrc%5Etfw"&gt;#muCon&lt;/a&gt; London 2019 &lt;a href="https://twitter.com/hashtag/SkillsCast?src=hash&amp;amp;ref_src=twsrc%5Etfw"&gt;#SkillsCast&lt;/a&gt;: &lt;a href="https://twitter.com/rjrodger?ref_src=twsrc%5Etfw"&gt;@rjrodger&lt;/a&gt; shares how the startup &lt;a href="https://t.co/GHuVLEqlZA"&gt;https://t.co/GHuVLEqlZA&lt;/a&gt; succeeded in using microservices during their first 18 months of development and why it worked.  &lt;/p&gt;

&lt;p&gt;Click here for video: &lt;a href="https://t.co/JJtjx7ccLj"&gt;https://t.co/JJtjx7ccLj&lt;/a&gt;&lt;a href="https://twitter.com/hashtag/microservice?src=hash&amp;amp;ref_src=twsrc%5Etfw"&gt;#microservice&lt;/a&gt; &lt;a href="https://twitter.com/hashtag/architecture?src=hash&amp;amp;ref_src=twsrc%5Etfw"&gt;#architecture&lt;/a&gt; &lt;a href="https://t.co/jnCmbL15zL"&gt;pic.twitter.com/jnCmbL15zL&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;— Skills Matter (@skillsmatter) &lt;a href="https://twitter.com/skillsmatter/status/1133746086038913024?ref_src=twsrc%5Etfw"&gt;May 29, 2019&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Next up, and filling the pre-lunch slot was "Creating an Effective Developer Experience for Cloud-Native Apps" from &lt;a href="https://twitter.com/danielbryantuk"&gt;Daniel Bryant&lt;/a&gt;. A great introduction and overview of DevEx, the idea of building a great experience for developers from coding to prod and beyond in the modern world of cloud-native, Kubernetes and Serverless. Whether it is "build or buy", cloud or in-house hosting, the story for developers to build, debug, test, deploy and monitor should be a first-class consideration of developing software.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;NEW &lt;a href="https://twitter.com/hashtag/muCon?src=hash&amp;amp;ref_src=twsrc%5Etfw"&gt;#muCon&lt;/a&gt; London 2019 &lt;a href="https://twitter.com/hashtag/SkillsCast?src=hash&amp;amp;ref_src=twsrc%5Etfw"&gt;#SkillsCast&lt;/a&gt;: &lt;a href="https://twitter.com/danielbryantuk?ref_src=twsrc%5Etfw"&gt;@danielbryantuk&lt;/a&gt; explores the core concepts of the cloud-native developer experience and the lessons learned.  &lt;/p&gt;

&lt;p&gt;Click here for video: &lt;a href="https://t.co/xaBmX4xpgL"&gt;https://t.co/xaBmX4xpgL&lt;/a&gt;&lt;a href="https://twitter.com/hashtag/continuousdeliveryprocesses?src=hash&amp;amp;ref_src=twsrc%5Etfw"&gt;#continuousdeliveryprocesses&lt;/a&gt; &lt;a href="https://twitter.com/hashtag/dx?src=hash&amp;amp;ref_src=twsrc%5Etfw"&gt;#dx&lt;/a&gt; &lt;a href="https://twitter.com/hashtag/devex?src=hash&amp;amp;ref_src=twsrc%5Etfw"&gt;#devex&lt;/a&gt; &lt;a href="https://twitter.com/hashtag/developerexperience?src=hash&amp;amp;ref_src=twsrc%5Etfw"&gt;#developerexperience&lt;/a&gt; &lt;a href="https://t.co/Ls2iTsagua"&gt;pic.twitter.com/Ls2iTsagua&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;— Skills Matter (@skillsmatter) &lt;a href="https://twitter.com/skillsmatter/status/1133757416120692737?ref_src=twsrc%5Etfw"&gt;May 29, 2019&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;"The Gordian Knot" from &lt;a href="https://twitter.com/ziobrando"&gt;Alberto Brandolini&lt;/a&gt; the importance of culture and the influence architecture plays on affecting that culture. Very interesting and a nice perspective on Conway's Law in many ways, and thinking about affecting change.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;NEW &lt;a href="https://twitter.com/hashtag/muCon?src=hash&amp;amp;ref_src=twsrc%5Etfw"&gt;#muCon&lt;/a&gt; London 2019 &lt;a href="https://twitter.com/hashtag/SkillsCast?src=hash&amp;amp;ref_src=twsrc%5Etfw"&gt;#SkillsCast&lt;/a&gt;: &lt;a href="https://twitter.com/ziobrando?ref_src=twsrc%5Etfw"&gt;@ziobrando&lt;/a&gt; shares how to face a Gordian Knot problem by effectively using a DevOps approach.  &lt;/p&gt;

&lt;p&gt;Click here for video: &lt;a href="https://t.co/4ZSESd9uCx"&gt;https://t.co/4ZSESd9uCx&lt;/a&gt;&lt;a href="https://twitter.com/hashtag/devops?src=hash&amp;amp;ref_src=twsrc%5Etfw"&gt;#devops&lt;/a&gt; &lt;a href="https://twitter.com/hashtag/softwarearchitecture?src=hash&amp;amp;ref_src=twsrc%5Etfw"&gt;#softwarearchitecture&lt;/a&gt; &lt;a href="https://twitter.com/hashtag/processes?src=hash&amp;amp;ref_src=twsrc%5Etfw"&gt;#processes&lt;/a&gt; &lt;a href="https://twitter.com/hashtag/microservices?src=hash&amp;amp;ref_src=twsrc%5Etfw"&gt;#microservices&lt;/a&gt; &lt;a href="https://twitter.com/hashtag/architecture?src=hash&amp;amp;ref_src=twsrc%5Etfw"&gt;#architecture&lt;/a&gt; &lt;a href="https://t.co/VV92qAgS9G"&gt;pic.twitter.com/VV92qAgS9G&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;— Skills Matter (@skillsmatter) &lt;a href="https://twitter.com/skillsmatter/status/1134014101695467520?ref_src=twsrc%5Etfw"&gt;May 30, 2019&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;"Strategic Domain-Driven Design Patterns" from &lt;a href="https://twitter.com/ntcoding"&gt;Nick Tune&lt;/a&gt; was an interesting discussion on DDD grouping. Definitely a topic I need to read the (blue) book on, literally and figuratively. (Although I am told one does not simply "read" Eric Evans' Domain Drive Design...) Some very high-level patterns and approaches to help with finding groupings in your system.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;NEW &lt;a href="https://twitter.com/hashtag/muCon?src=hash&amp;amp;ref_src=twsrc%5Etfw"&gt;#muCon&lt;/a&gt; London 2019 &lt;a href="https://twitter.com/hashtag/SkillsCast?src=hash&amp;amp;ref_src=twsrc%5Etfw"&gt;#SkillsCast&lt;/a&gt;: &lt;a href="https://twitter.com/ntcoding?ref_src=twsrc%5Etfw"&gt;@ntcoding&lt;/a&gt; shares how understanding domain patterns helps you align your microservices and business domain.  &lt;/p&gt;

&lt;p&gt;Click here for video: &lt;a href="https://t.co/9d6ClArZJA"&gt;https://t.co/9d6ClArZJA&lt;/a&gt;&lt;a href="https://twitter.com/hashtag/domainpatterns?src=hash&amp;amp;ref_src=twsrc%5Etfw"&gt;#domainpatterns&lt;/a&gt; &lt;a href="https://twitter.com/hashtag/ddd?src=hash&amp;amp;ref_src=twsrc%5Etfw"&gt;#ddd&lt;/a&gt; #microservices# architecture &lt;a href="https://t.co/8MOMVOS8FG"&gt;pic.twitter.com/8MOMVOS8FG&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;— Skills Matter (@skillsmatter) &lt;a href="https://twitter.com/skillsmatter/status/1134044301514674177?ref_src=twsrc%5Etfw"&gt;May 30, 2019&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;"Event Driven Collaboration" from &lt;a href="https://twitter.com/ICooper"&gt;Ian Cooper&lt;/a&gt; another look at the &lt;a href="https://blog.csmac.nz/geeking-out-at-altnetbrum-2018/#referencedataarchitecture"&gt;Reference Data concept&lt;/a&gt;, with some practical examples of what and how you might go about implementing this. A revision on the concepts of inside mutable data Vs outside immutable data, events, messages and caching.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;NEW &lt;a href="https://twitter.com/hashtag/muCon?src=hash&amp;amp;ref_src=twsrc%5Etfw"&gt;#muCon&lt;/a&gt; London 2019 &lt;a href="https://twitter.com/hashtag/SkillsCast?src=hash&amp;amp;ref_src=twsrc%5Etfw"&gt;#SkillsCast&lt;/a&gt;: &lt;a href="https://twitter.com/ICooper?ref_src=twsrc%5Etfw"&gt;@ICooper&lt;/a&gt; shares how events help us integrate our service architectures.  &lt;/p&gt;

&lt;p&gt;Click here for video: &lt;a href="https://t.co/H7WMrEJtwF"&gt;https://t.co/H7WMrEJtwF&lt;/a&gt;&lt;a href="https://twitter.com/hashtag/eventdrivencollaboration?src=hash&amp;amp;ref_src=twsrc%5Etfw"&gt;#eventdrivencollaboration&lt;/a&gt; &lt;a href="https://twitter.com/hashtag/microservices?src=hash&amp;amp;ref_src=twsrc%5Etfw"&gt;#microservices&lt;/a&gt; &lt;a href="https://twitter.com/hashtag/architecture?src=hash&amp;amp;ref_src=twsrc%5Etfw"&gt;#architecture&lt;/a&gt; &lt;a href="https://t.co/j4MBsnHeo5"&gt;pic.twitter.com/j4MBsnHeo5&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;— Skills Matter (@skillsmatter) &lt;a href="https://twitter.com/skillsmatter/status/1134059400367419393?ref_src=twsrc%5Etfw"&gt;May 30, 2019&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The day wound down with a couple of Lightning Talks. A standout for me was "Continuous Visibility, No More Dashboards!" From &lt;a href="https://twitter.com/JBJamesBrownJB"&gt;James Brown&lt;/a&gt; on Continuous Visibility (CV). Using Alerts and notifications more, and only selectively add trends and maybe CI statuses to a physical dashboard where space is a premium (but don't forget to add GIfs!).&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;NEW &lt;a href="https://twitter.com/hashtag/muCon?src=hash&amp;amp;ref_src=twsrc%5Etfw"&gt;#muCon&lt;/a&gt; London 2019 &lt;a href="https://twitter.com/hashtag/SkillsCast?src=hash&amp;amp;ref_src=twsrc%5Etfw"&gt;#SkillsCast&lt;/a&gt;: James Brown shares his journey on how he and his team evolved visibility on the health of their systems.  &lt;/p&gt;

&lt;p&gt;Click here for video: &lt;a href="https://t.co/H7WMrEJtwF"&gt;https://t.co/H7WMrEJtwF&lt;/a&gt;&lt;a href="https://twitter.com/hashtag/operationalsupport?src=hash&amp;amp;ref_src=twsrc%5Etfw"&gt;#operationalsupport&lt;/a&gt; &lt;a href="https://twitter.com/hashtag/failurerecovery?src=hash&amp;amp;ref_src=twsrc%5Etfw"&gt;#failurerecovery&lt;/a&gt; &lt;a href="https://twitter.com/hashtag/syntheticmonitoring?src=hash&amp;amp;ref_src=twsrc%5Etfw"&gt;#syntheticmonitoring&lt;/a&gt; &lt;a href="https://t.co/DLu8EtKUkV"&gt;pic.twitter.com/DLu8EtKUkV&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;— Skills Matter (@skillsmatter) &lt;a href="https://twitter.com/skillsmatter/status/1134112268600401921?ref_src=twsrc%5Etfw"&gt;May 30, 2019&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Day 2
&lt;/h2&gt;

&lt;p&gt;Day 2 kicks off with another leading Keynote: "Getting to DDD: Pragmatic or Principled?" from&lt;br&gt;&lt;br&gt;
&lt;a href="https://twitter.com/julielerman"&gt;Julie Lerman&lt;/a&gt;. Julie gave a discussion on the DDD journey, engaging with new adopters, and how building on the concepts with a group slowly can be a great way to bring more people on board, without getting hung up on being too principled or having to be all in with everything DDD at once.&lt;/p&gt;

&lt;p&gt;"Preparing for a future Microservices journey"&lt;br&gt;&lt;br&gt;
from &lt;a href="https://twitter.com/suksr"&gt;Susanne Kaiser&lt;/a&gt; presented a journey from custom build through Microservices to Serverless taking all aspects of a hosted piece of software and it's infrastructure concerns transitioning through Build vs Buy, to commoditization.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“Software delivery performance is critical for tech organizations doing business today.” Microservices lessons learned with &lt;a href="https://twitter.com/suksr?ref_src=twsrc%5Etfw"&gt;@suksr&lt;/a&gt; is happening now! 😎 &lt;a href="https://twitter.com/hashtag/microservices?src=hash&amp;amp;ref_src=twsrc%5Etfw"&gt;#microservices&lt;/a&gt; &lt;a href="https://t.co/Ti4xehAkZC"&gt;pic.twitter.com/Ti4xehAkZC&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;— Skills Matter (@skillsmatter) &lt;a href="https://twitter.com/skillsmatter/status/1134036801491034113?ref_src=twsrc%5Etfw"&gt;May 30, 2019&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;"Observable Microservices" from &lt;a href="https://twitter.com/mariascandella"&gt;Maria Gomez&lt;/a&gt; went through the what of observability (logs, alerts and tracing) along with the 'why' for the value it provides to you once your services are in production.&lt;/p&gt;

&lt;p&gt;After lunch, &lt;a href="https://twitter.com/duffleit"&gt;David Leitner&lt;/a&gt; presented "Micro Frontends – A Strive for Fully Verticalized Systems". A nice definition of MicroFrontends and example architectures to add to your toolbox of "it depends" solutions. Very clearly outlined the when and where the different approaches are applicable. Definitely check out his work if your thinking about verticalized splitting your frontend.&lt;/p&gt;

&lt;p&gt;This led into the afternoon Workshop: "Show me the Kubernetes" with &lt;a href="https://twitter.com/denhamparry"&gt;Lewis Denham-Parry&lt;/a&gt; and &lt;a href="https://twitter.com/SoulmanIqbal"&gt;Salman Iqbal&lt;/a&gt;. They walked us through the demos at &lt;a href="https://github.com/CloudNativeWales/ShowMeTheKubernetes"&gt;github.com/CloudNativeWales/ShowMeTheKubernetes&lt;/a&gt; which worked well on a temporarily spun up cluster on Azure, or with a Minikube locally (instructions included in both cases). Further examples were promised so there might be more than the three we went through in the session.&lt;/p&gt;

&lt;p&gt;To round out the second day was a keynote from &lt;a href="https://twitter.com/dianamontalion"&gt;Diana Montalion&lt;/a&gt; on Making a Case for Conceptual Integrity. I'm not too proud to admit that I didn't understand the term "conceptual integrity" at the end and couldn't give you the definition. However, the topic was very interesting and the steps discussed to reach the definition given were very useful and interesting in themselves that to me it didn't matter. Maybe I'm lacking the experience at this stage to accurately grok this, and others with more systems consulting experience and exposure did.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Just one of &lt;a href="https://twitter.com/hashtag/muCon?src=hash&amp;amp;ref_src=twsrc%5Etfw"&gt;#muCon&lt;/a&gt;’s workshops happening this afternoon ⚙️Show Me the Kubernetes by &lt;a href="https://twitter.com/SoulmanIqbal?ref_src=twsrc%5Etfw"&gt;@soulmaniqbal&lt;/a&gt; and &lt;a href="https://twitter.com/denhamparry?ref_src=twsrc%5Etfw"&gt;@denhamparry&lt;/a&gt; offers hands-on experience for anyone new to &lt;a href="https://twitter.com/hashtag/kubernetes?src=hash&amp;amp;ref_src=twsrc%5Etfw"&gt;#kubernetes&lt;/a&gt;! &lt;a href="https://twitter.com/hashtag/SoftwareArchitectures?src=hash&amp;amp;ref_src=twsrc%5Etfw"&gt;#SoftwareArchitectures&lt;/a&gt; &lt;a href="https://t.co/4yiwC0CbEy"&gt;pic.twitter.com/4yiwC0CbEy&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;— IkeAtSM (@IkeAtSM) &lt;a href="https://twitter.com/IkeAtSM/status/1134096839723163648?ref_src=twsrc%5Etfw"&gt;May 30, 2019&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;Of course, most if not all of the talks were recorded and appear online (links added where available) but as usual you have missed the hallway conversations by not being here. These are usually the best part of any conference and this has been no exception. One great conversation leads to quoting the statement that never had anyone said or seen a system that would be described as too gold plated, or too well tested. Most systems instead suffer from not being of a good enough quality or lacking in test coverage.&lt;/p&gt;

&lt;p&gt;In other conversations being able to share structures and strategies gives insight into what is or isn't working for other teams and companies and gives a relative look at where they are on their journey compared to you with yours. But based on the guidance and experience of others here, we all seem to be heading in a similar direction through SOA to DDD and Microservices.&lt;/p&gt;

&lt;p&gt;Stay tuned for a summary of my day 3 experience.&lt;/p&gt;

</description>
      <category>conference</category>
      <category>mucon</category>
      <category>ddd</category>
      <category>microservices</category>
    </item>
    <item>
      <title>Looking Back on C# 7: throw expressions</title>
      <dc:creator>Mark Clearwater</dc:creator>
      <pubDate>Mon, 27 May 2019 22:30:00 +0000</pubDate>
      <link>https://dev.to/csmacnz/looking-back-on-c-7-throw-expressions-2cc</link>
      <guid>https://dev.to/csmacnz/looking-back-on-c-7-throw-expressions-2cc</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--TI-DMmkR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://images.unsplash.com/photo-1530226406379-f84b9edd291b%3Fixlib%3Drb-1.2.1%26q%3D80%26fm%3Djpg%26crop%3Dentropy%26cs%3Dtinysrgb%26w%3D1080%26fit%3Dmax%26ixid%3DeyJhcHBfaWQiOjE2ODI3fQ" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--TI-DMmkR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://images.unsplash.com/photo-1530226406379-f84b9edd291b%3Fixlib%3Drb-1.2.1%26q%3D80%26fm%3Djpg%26crop%3Dentropy%26cs%3Dtinysrgb%26w%3D1080%26fit%3Dmax%26ixid%3DeyJhcHBfaWQiOjE2ODI3fQ" alt="Looking Back on C# 7: throw expressions"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With C# 8 on our doorstep, I figure it is a good time to reflect on recent additions to the language that have come before. There are some great improvements you may have missed, some that I really enjoy using, and some I consider have reached canonical usage status that I think are all worth some reflection.&lt;/p&gt;

&lt;p&gt;Throwing Exceptions is both a blessing and a curse in C#. You can throw from anywhere to unwind the stack. But adding exception throwing and handling code can cause overheads that you need to be wary of. Not to mention making the code harder to reason about with control flow.&lt;/p&gt;

&lt;p&gt;Regardless, we have them, and we use them, so the language should make that as easy as possible to do so. with C# 7 this was enhanced to support using &lt;code&gt;throw&lt;/code&gt; as an expression. Up until this point, it was always a statement, which means there are places in the code that throw could not go.&lt;/p&gt;

&lt;p&gt;One new language feature that only supports expressions and not statements is the Elvis Operator (or Null Conditional Operator, which we &lt;a href="https://blog.csmac.nz/looking-back-on-csharp7-throw-expressions/looking-back-on-csharp6-elvis-operator/"&gt;already looked back at&lt;/a&gt;) and another is the null coalescing operator. When it comes to validating code, these two features shine together.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public MyClass(string firstArg, string secondArg, Widget widget)
{
    if(firstArg is null)
    {
        throw new ArgumentNullException(nameof(firstArg));
    }
    if(secondArg is null)
    {
        throw new ArgumentNullException(nameof(secondArg));
    }
    if(widget is null)
    {
        throw new ArgumentNullException(nameof(widget));
    }

    _firstArg = firstArg;
    _secondArgLength = secondArg.Length;
    _widget = widget;
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;So verbose! wouldn't it be nice to collapse it together a bit? With throw expressions, we can.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public MyClass(string firstArg, string secondArg, Widget widget)
{
    _firstArg = firstArg ?? throw new ArgumentNullException(nameof(firstArg));
    _secondArg = secondArg?.Length ?? throw new ArgumentNullException(nameof(secondArg));
    _widget = widget ?? throw new ArgumentNullException(nameof(widget));
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;So much shorter and more concise. This saves typing time and reading the time. The magic is that the right-hand-side of the null coalescing operator has to take an expression that evaluates to the right type. Because throw is now an expression, it can do exactly that and satisfy the compilation.&lt;/p&gt;

&lt;p&gt;Also remember how we looked at &lt;a href="https://blog.csmac.nz/looking-back-on-csharp6-expression-body-members"&gt;Expression body members in C# 6&lt;/a&gt; and &lt;a href="https://blog.csmac.nz/looking-back-on-csharp7-throw-expressions/looking-back-on-csharp7-more-expression-body-members"&gt;more in c# 7&lt;/a&gt;? Well as the name suggests, the body &lt;em&gt;is&lt;/em&gt; an expression. Now that we have throw expressions, the bodies can use them too!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public class Widget
{
    public Widget() =&amp;gt; throw new ArgumentException("Requires arguments, none provided.");

    public ~Widget() =&amp;gt; throw new NotSupportedException("What are you building that needs a destructor, anyway? (Just curious.)");

    public string MyValueProperty =&amp;gt; throw new NotImplementedException();

    public decimal CalculateTheAnswer() =&amp;gt; throw new NotImplementedException();

    private T[] _items = new T[100];
    public T this[int i]
    {
        get =&amp;gt; _items?[i] ?? throw new Exception("Not initialised somehow.");
        set =&amp;gt; throw new NotSupportedException("An interface made me do this.");
    }
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;There are other use-cases out there, expressions are used all over the place. But I will leave that as an exercise to the reader to discover along the way.&lt;/p&gt;

</description>
      <category>csharp</category>
    </item>
    <item>
      <title>Looking back on C# 6: Initializers</title>
      <dc:creator>Mark Clearwater</dc:creator>
      <pubDate>Mon, 29 Apr 2019 23:30:00 +0000</pubDate>
      <link>https://dev.to/csmacnz/looking-back-on-c-6-initializers-1h2k</link>
      <guid>https://dev.to/csmacnz/looking-back-on-c-6-initializers-1h2k</guid>
      <description>&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimages.unsplash.com%2Fphoto-1502426899022-660e3522a15a%3Fixlib%3Drb-1.2.1%26q%3D80%26fm%3Djpg%26crop%3Dentropy%26cs%3Dtinysrgb%26w%3D1080%26fit%3Dmax%26ixid%3DeyJhcHBfaWQiOjE2ODI3fQ" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimages.unsplash.com%2Fphoto-1502426899022-660e3522a15a%3Fixlib%3Drb-1.2.1%26q%3D80%26fm%3Djpg%26crop%3Dentropy%26cs%3Dtinysrgb%26w%3D1080%26fit%3Dmax%26ixid%3DeyJhcHBfaWQiOjE2ODI3fQ" alt="Looking back on C# 6: Initializers"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With C# 8 on our doorstep, I figure it is a good time to reflect on recent additions to the language that have come before. There are some great improvements you may have missed, some that I really enjoy using, and some I consider have reached canonical usage status that I think are all worth some reflection.&lt;/p&gt;

&lt;p&gt;Initializers have had a few upgrades since the early C# days. But before we look at more recent changes, we will review what came before.&lt;/p&gt;

&lt;p&gt;Initializers or Object Initializers is a name given to code that performs the initial setup of a piece of memory (a struct or an object). Constructors are part of this but the idea goes more towards the holistic setup of the object data for all of the state you care to set up.&lt;/p&gt;

&lt;p&gt;Taking a look at C for even more background, we have initializers like so:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;struct MyType { char s; int n; };

// We can initialize a variable using a curly brace syntax:
MyType x = { 'a', 42 };
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;What we see above is that we are initializing our variable &lt;code&gt;x&lt;/code&gt; to have its data for &lt;code&gt;.s&lt;/code&gt; and &lt;code&gt;.n&lt;/code&gt; set to &lt;code&gt;'a'&lt;/code&gt; and &lt;code&gt;42&lt;/code&gt; respectively. This is initialization. Now using C#, something more familiar:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public class Foo
{
    public string Name { get; set; }
    public int Number { get; set; }
}

// Without using initializers:
Foo myFoo = new Foo();
myFoo.Name = "a";
myFoo.Number = 42;

// In C# we can initialize in a similar way to C.
// This code compiles to the same instructions as above:
Foo myFoo = new Foo() { Name = "a", Number = 24 };

// Collections also support initialization
int[] myArray = new int[] { 1, 1, 2, 3, 5, 8 };
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I won't go into how C has advanced its own initializers, that it a different topic. Instead, we will look at how C# has taken this simple initializer above and enhanced in C# 6 on top of this initial syntax in C# 3.&lt;/p&gt;

&lt;h3&gt;
  
  
  Add Extension support for collections
&lt;/h3&gt;

&lt;p&gt;When Initializers were implemented (or not long after if my memory deceives me) there was a little magic that made this work. Namely, the code written was simpler and more concise, but the implementation transformed into something more familiar.&lt;/p&gt;

&lt;p&gt;The same is true for Collection initialization. If we review the example from above we can see this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Collection initialization
int[] myArray = new int[] { 1, 1, 2, 3, 5, 8 };

// The same code, more verbosely:
int[] myArray = new int[];
myArray.Add(1);
myArray.Add(1);
myArray.Add(2);
myArray.Add(3);
myArray.Add(5);
myArray.Add(8);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Basically, the syntax is a shorthand for calling &lt;code&gt;Add(&lt;/code&gt; on the collection. This allows for more complex situations where &lt;code&gt;Add&lt;/code&gt; can take multiple arguments.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var myDict = new Dictionary&amp;lt;int, string&amp;gt;() { { 1, "One" }, { 2, "Two" } };

// This worked the same way as the last example. The same code is:
var myDict = new Dictionary&amp;lt;int, string&amp;gt;();
myDict.Add(1, "One");
myDict.Add(2, "Two");
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Again, this is all existing syntax. With C# 6, an ability was added so that instead of needing to implement &lt;code&gt;Add&lt;/code&gt; on your type, you could create extension methods as well:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public static void Add(this Dictionary&amp;lt;int, string&amp;gt; dict, Foo value)
{
    dict.Add(value.Number, value.Name);
}

Foo foo1 = new Foo() { Name = "One", Number = 1 };
Foo foo2 = new Foo() { Name = "Two", Number = 2 };
var myDict = new Dictionary&amp;lt;int, string&amp;gt;() { foo1, foo2 };
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;At this point, the possibilities are endless and fully customizable to create your own Domain-Specific-Language (DSL). You don't even have to use Collections because anything can have an &lt;code&gt;Add&lt;/code&gt; overload added via an extension.&lt;/p&gt;

&lt;h3&gt;
  
  
  Index Initializer
&lt;/h3&gt;

&lt;p&gt;Dictionary syntax is a bit odd. Add isn't really the right approach. And we already have indexer syntax:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var myDict = new Dictionary&amp;lt;int, string&amp;gt;();
myDict[7] = "seven";
myDict[9] = "nine";
myDict[13] = "thirteen;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Why not extend Initializers to use the indexer as well? They did. C# 6 again.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var numbers = new Dictionary&amp;lt;int, string&amp;gt; {
    [7] = "seven",
    [9] = "nine",
    [13] = "thirteen"
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Works as expected, and is the same result as the code above. This works off of the same existing indexer pattern( in a similar manner to the &lt;code&gt;Add&lt;/code&gt; usage earlier), so works with any custom indexer on any custom type.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Using an existing type from Newtonsoft.Json:
var x = new JObject { ["x"] = 3 };
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Auto property initializers
&lt;/h3&gt;

&lt;p&gt;That is a bunch of consumer side initialization. There was more added behind the scenes in C# 6 as well.&lt;/p&gt;

&lt;p&gt;The humble Auto Property:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public int X { get; set; }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;First, we can now give a default initialization:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// This is the same as `X = 4` in the constructor
public int X { get; set; } = 4;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And to make this trick even more complete, we have the getter-only property:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public int Y { get; } = 42;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As well as the ability to initialize this from a constructor instead:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public class MyFoo
{
    public int Y { get; };    

    pubilc MyFoo()
    {
        Y = 42;
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Sometimes you may have many constructor overloads, using the property initializer is less code duplication. Sometimes you may want to have different values for different overloads, then you can initialize in the constructor.&lt;/p&gt;

&lt;p&gt;Either way, this gives you true power over you read-only without the verbose equivalent you used to have to write:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Same code as above in "full":
public class MyFoo
{
    private readonly int _y;
    public int Y
    {
        get
        {
            return _y;
        }
    };    

    pubilc MyFoo()
    {
        _y = 42;
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The newer way is much more concise, especially when there are many properties:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Just imagine how many lines of code this would be the old way!
public class MyFoo
{
    public string X { get; } = "Foo";    
    public int Y { get; } = 42;    
    public decimal Z { get; } = 54m;
    public object Key { get; } = new object{};

    // Other read/write props
    public int Another { get; set; }
    public bool Widgets { get; set; }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Wrapup
&lt;/h3&gt;

&lt;p&gt;Object initialization had a major revamp in C# 6. How many of these do you use regularly? How many do you notice in your own code bases? These have been around for a while so expect only to see more of it. Do yourself a favour and start using it if you haven't already. Very readability, much fewer keystrokes. Canonical? You betcha!&lt;/p&gt;

</description>
      <category>csharp</category>
    </item>
    <item>
      <title>Looking back on C# 6: String interpolation</title>
      <dc:creator>Mark Clearwater</dc:creator>
      <pubDate>Sun, 14 Apr 2019 23:30:00 +0000</pubDate>
      <link>https://dev.to/csmacnz/looking-back-on-c-6-string-interpolation-627</link>
      <guid>https://dev.to/csmacnz/looking-back-on-c-6-string-interpolation-627</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--VC6frUv8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://images.unsplash.com/photo-1502426899022-660e3522a15a%3Fixlib%3Drb-1.2.1%26q%3D80%26fm%3Djpg%26crop%3Dentropy%26cs%3Dtinysrgb%26w%3D1080%26fit%3Dmax%26ixid%3DeyJhcHBfaWQiOjE2ODI3fQ" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--VC6frUv8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://images.unsplash.com/photo-1502426899022-660e3522a15a%3Fixlib%3Drb-1.2.1%26q%3D80%26fm%3Djpg%26crop%3Dentropy%26cs%3Dtinysrgb%26w%3D1080%26fit%3Dmax%26ixid%3DeyJhcHBfaWQiOjE2ODI3fQ" alt="Looking back on C# 6: String interpolation"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With C# 8 on our doorstep, I figure it is a good time to reflect on recent additions to the language that have come before. There are some great improvements you may have missed, some that I really enjoy using, and some I consider have reached canonical usage status that I think are all worth some reflection.&lt;/p&gt;

&lt;p&gt;String Interpolation is a great feature that I now use everywhere I can (Except logging - see below).&lt;/p&gt;

&lt;p&gt;We have efficient libraries to format strings for us, so we don't have to concatenate all the time. This is both convenient and performant.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var string1 = "My name is " + "Mark";
var string2 = String.Format("My name is {0}", "Mark");
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;The resulting string above is equivalent but there are many benefits to the second option:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;faster internal string building for larger strings with multiple parameters&lt;/li&gt;
&lt;li&gt;Lazy execution means you can pass &lt;code&gt;template&lt;/code&gt; + &lt;code&gt;args&lt;/code&gt; down the stack and format later (or never as an optimisation when necessary such as Debug/Verbose logs)&lt;/li&gt;
&lt;li&gt;Potentially more readable as a template than the concatenation would be (depending on the message).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The problem becomes we have all these index positions. It is very easy with many arguments to either get the positions wrong or to change it and make a mistake.&lt;/p&gt;

&lt;h2&gt;
  
  
  String Interpolation
&lt;/h2&gt;

&lt;p&gt;You can think of String Interpolation as the compiler automatically turning your string into a &lt;code&gt;String.Format&lt;/code&gt; for you. (Oversimplification but useful way to conceptualise it.) The first piece of magic is the &lt;code&gt;$&lt;/code&gt; character. Adding this to the start of a string makes it into an interpolated string. This now grants special power to the braces (&lt;code&gt;{}&lt;/code&gt;). When you have a block of braces inside the string, this essentially becomes an expression. You can put whatever code you want in here, and it becomes a format argument. This gives improved readability.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var oldWay = String.Format($"{0} is {1} years old.", p.Name, p.Age);
var newWay = $"{p.Name} is {p.Age} years old.";
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Mistakes are easier to spot&lt;/li&gt;
&lt;li&gt;compile-time checks performed on the string and its format&lt;/li&gt;
&lt;li&gt;performant - same benefits of &lt;code&gt;String.Format&lt;/code&gt; applied for optimisations&lt;/li&gt;
&lt;li&gt;readable - reads like a sentence with clearing understanding of where the arguments come from&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can still use &lt;code&gt;{&lt;/code&gt; in your string, you just have to escape it with another &lt;code&gt;{&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var name = "bob";

// This becomes: {"name":"bob"}
var json = "{{""name"":""{name}""}}";
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;This is a canonical language feature, and you will expect to see most string-related code using it. That is if you are not already yourself.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why "Except Logging"?
&lt;/h2&gt;

&lt;p&gt;Turns out, there is a massively useful feature with logging using &lt;code&gt;Microsoft.Extensions.Logging&lt;/code&gt; and ILogger. Semantic Logging, also known as Structured Logging.&lt;/p&gt;

&lt;p&gt;Semantic/Structured Logging supported is up to the implementor of the logging, but Serilog, Application Insights, NLog and others tend to support this feature, and it is &lt;a href="https://docs.microsoft.com/en-us/aspnet/core/fundamentals/logging/?view=aspnetcore-2.2#log-message-template"&gt;defined as a first-class part of the API&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The main difference to &lt;code&gt;String.Format&lt;/code&gt; is you give named parameters in the template rather than numbered.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;String.Format("My name is {0}", "Mark");
_logger.LogInformation("My name is {FirstName}", "Mark");
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Anyone who has actually monitored their logs knows that templates are really valuable. You can find all instances of a log message quickly with templated arguments, rather than having to do a wildcard search with inlined values because each message is a unique snowflake. Most logging frameworks add the arguments as named metadata, using the value from the string (in the above example that would be &lt;code&gt;FirstName&lt;/code&gt;).&lt;/p&gt;

&lt;p&gt;This works great. As long as you don't use the new and useful String Interpolation when you log. String Interpolation results in a string passed to the logger, rather than passing a template and arguments, so it's one or the other at this time.&lt;/p&gt;

&lt;p&gt;As you would expect, &lt;a href="https://stackoverflow.com/questions/52200484/why-logging-doesnt-use-string-interpolation"&gt;people really want this&lt;/a&gt; to reverse-engineer from String Interpolation into Semantic Logging automatically, but the argument is that it is both unexpected and a breaking change so you probably won't see that anytime soon &lt;a href="https://github.com/NLog/NLog/issues/825"&gt;without a custom library or API involved&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>csharp</category>
    </item>
  </channel>
</rss>
