My focus is on making software, coaching Agile/Scrum teams, and being a husband and father--definitely not on blogging--so please do not expect very frequent posts here.

Tuesday, October 21, 2025

Don't complain about your stakeholders; instead, collaborate, then build trust

Sales might say "Don't bother us in sales, we're too busy selling!", which makes it hard to build software that meets their needs. In manufacturing, the attitude was the opposite: "Please work with us to make the line run better!", which makes it hard to prioritize and triage all the incoming requests. In both cases, getting into a truly collaborative relationship with stakeholders and key users, then building trust, helps more than anything to cut through the chaff inherent to the "feast or starve" alternatives.

Monday, November 25, 2024

The way to do a no-op (do nothing) action in GitHub Actions is `run: exit 0`

You'd think echo or : would work, but echo results in extra unexpected cruft, and : isn't recognized as a command, presumably due to the YAML interpreter.  Hope this helps!

Saturday, August 17, 2024

Readability Above All Else in Code Reviews

In my last post, I made a case that code reviews cannot be relied upon as the main activity to achieve defect prevention, correctness, robustness, usability, or learning. Even so, these goals are worth pursuing in code reviews, though other practices such as unit testing and QA should be the primary driver to such goals. Aside from those goals, code reviews can indeed be the primary driver of other areas of improvement for a software team. It is arguable (comments welcome), but I say above all else code reviews routinely and consistently improve code readability. Highly readable code might not be the first measure of software quality or of team competency that you'd list, but it should be. Code is typically written once and revised a few times, but read dozens of times. Programs are for humans to read and only incidentally for computers to execute. I or any competent developer can deal with any code that we can understand, and the quicker we can understand it, the faster it will be to troubleshoot, maintain, and enhance. Readable code gives us more than a fighting chance. Too often, when teams are under the gun and avoiding spending any time or effort into code review, we get indecipherable, weird, arcane, and confusing code, and this incurs troubleshooting, maintenance, and enhancement costs to go way up in the future, and in unpredictable ways.

The most important imperative in generating highly-readable code, I say, is: write your code so that the reader can immediately and intuitively discern what it actually does. Don't make me think too hard. Make the code obvious. As a reviewer, you can make this your top priority when recommending changes to the code under review. A reviewer ought to first point out where she or he doesn't understand what the code is doing and try to collaborate with the author to make it obvious. As an author, when a reviewer doesn't immediately grok what you wrote, your first thought shouldn't be "Okay, let me explain it to him" and certainly not "I should probably add some comments that explain this". Instead, think "If he didn't get it, others won't get it either. What code should change to make this more obvious?"

More often, the reviewer already understands what the code is doing but quickly thinks of a better way to express it--"better" here being synonymous with "more readable". Code review is the only practice I know of that presses code into a more readable state routinely and reliably. These can often be the quick wins: the reviewer says "try this instead", and very often the author can quickly agree and integrate such a change. As an author, I am very apt to take my coworker's suggestions, certainly when I am ambivalent and even when I mildly disagree. The rapport and mutuality gained from adopting a reviewer's recommendation in code review might be more valuable than the change itself. And several times I have looked back on such changes after several months and been convinced in the end--turns out my teammates are really quite good at this programming stuff!

We should all write our code so that the mapping from the code itself to our intent is as simple and as straightforward as possible. For example, if I intend for a method to calculate and then save, naming it CalculateAndSave is better than naming it Save. In a code review, pointing out "this is doing more than saving" will at least result in a renaming of the method. Then, that name then might lead us to question if the calculation should be done in a separate method for better separation of concerns. Conversely, if I named a method ValidateAndSave but there is no validation code in the method at all, my teammate would immediately point out that I intended to validate but never actually did so. Pointing out the differences between apparent intent (or mutually-understood requirements) and actual code is a top benefit of doing code reviews.

So what makes code highly readable?  Sometimes "it depends" (of course). Sometimes, shorter code is more readable (e.g. omitting redundancies), and sometimes longer code is more readable (such as declaring a semantically meaningful temporary reference). Sometimes clever code is more readable (i.e. when your cleverness came up with the apt statement; please not when cleverness is needed to understand it); sometimes "dumb" code is more readable (especially when familiar and unastonishing). Sometimes more abstraction (more layers) is more readable; other times, collapsing layers makes it more readable. When these questions come up in code, the important thing is that the team is deciding together which way to go in each case. If the team is skilled and genuinely cares, I trust them to make a decision, even if I disagree with that decision. The difference between my idea of good code and my team's idea is usually tiny compared to code that isn't reviewed for readability at all.

However, there are some good readable-code rules-of-thumb that are almost always true. Simple beats complex. Boring beats exciting. Code written as others expect beats astonishing code. Conventional code beats innovative code. Pattern-following code beats trailblazing code. Linear code beats nested code, and shallower nesting beats deeper nesting. More short methods are better than fewer long methods. I think we all appreciate simple, boring, as-expected, conventional, patterned, linear, shorter code--so as a code reviewer, be eager to give your recommendations to make it such.

And there is one more rule-of-thumb that I hold to be the most important: refactored code beats original code every time. Code can almost always be made more readable by being revised, especially when there is no pressure to change its behavior. This is exactly where team peer code review shines: It allows for code to be refactored mere minutes or hours from when it was originally written, with zero added cost of extra testing, when you are most familiar with both the desired and actual behavior of the code in question, when such refactoring is typically least costly and most welcome by all concerned parties. It is the biggest no-brainer when it comes to code review: seize the opportunity to refactor your code to be more readable, and leverage code reviews to spur changes for readability.

Of course, even if all that is agreed among team member, opinions will still differ as to what is easiest to read. One thinks nested ternary conditionals are easier than using elseif; their teammates think they're nuts. Some like indenting via tabs, some like spaces. When these differences are aired in a team peer code review, a quick resolution is likely. If the teams uphold the value of others' work and want to come to a consensus, a disagreement in a code review will result in the team either proposing a common practice that all can and should agree on, or it will result in the team agreeing that either way is fine and toleration of unimportant inconsistencies (if any). The important concern is that the team be empowered to consider and decide themselves, and that any team member can speak up to raise the issue (both within the code review and in initiating a broader team discussion).

Making the code more obvious and making the code reflect the intent of the author will result in big long-term wins for the product and for the team. Something curious happens once a team gets a little experience at this: they inevitably start forming team norms that lead to more efficient and productive coding. Often it also leads to agreed coding standards that take further time-consuming discussions (or arguments, or fights) out-of-play. These benefits result in snowballing productivity and team happiness as well, so I'll explore that in my next post. I've only scratched the surface on some other benefits of code review, which will also be coming up. 

Do you have a piece of code you'd like to make more readable?  Post it here (maybe a link to a GitHub PR or commit?) and I'll give it a crack.

Thursday, August 15, 2024

Code Reviews Are Overrated (but not how you think!)

When I first began leading a "two-pizza" software team in 2007, our code reviews focused on code robustness and correctness. Our architect would choose code to print out--usually around 4-6 pages' worth each week. We would gather in a conference room and spend an hour scrutinizing, and ultimately arguing, about what in that code should change. A few months into the job, he turned over that duty to me and I knew both the printed approach and the goals we were pursuing had to shift! Since that time, tools have greatly improved, code review practices have become easier and more widely known, and the way we structure code is less novel and more relatable. On top of these improvements, developers expect to review code more commonly and with a much healthier attitude; the benefits are more intuitive to all. However, after doing code reviews on most days for the last 17 years, I have come to see that some of the supposed benefits of code review are overrated. Let's acknowledge the limitations of code review toward those goals and consider other goals for which code reviews might be the primary means to gain.

Most importantly, code reviews are not great at finding defects (bugs) in the code. I hesitate to even mention this first: indeed, my teams have used code reviews to find and fix thousands of defects in our code over the years--perhaps making code reviews worthwhile for this benefit alone. Furthermore, bugs found in code review can be fixed much more easily and cheaply than those found in any round of testing, or in the worst case, found by actual users in production. Nevertheless, if we relied on code review as the main way to prevent defects, our quality would dramatically drop. Most defects are simply not obvious enough in code reviews. We need testing in all its forms. We need mutual understanding of requirements, use cases, and/or user stories. We need collaboration and an ongoing conversation about what our software should do and what our users' experience should be. We need an overall team culture growing in software quality and technical excellence. There is not one way to prevent defects; we need all the ways. Certainly code reviews are one tool for higher quality software, but the answer to "why did this bug make it into production?" never comes back as "Eric reviewed the code poorly."

Now let me restate that overrated does not mean nonexistent; let me repeat that code reviews do often find bugs; they just aren't great at doing so. Much as a .300 hitter (that is, a 30% successful hitter) in baseball is an all-star, the value in preventing defects via code review is large despite its failure to detect them more often than not. Keep looking for bugs in your code review effort--just don't expect to find most of them that way.

A concept related to defect prevention is correctness. Does the code do what the author intended it to do? Code reviews are overrated in revealing incorrect code. After all, unless the review somehow expresses what the author intended separately from the code that implements it, the reviewer cannot tell where the intent of the code differs from the code. Reviewers often proceed assuming the best intentions of the author and also assume that the code written accurately reflects those intentions. If a reviewer encounters code they didn't expect, he might think "well, she thought this through and I haven't. She must be right." The wise reviewer will ask questions instead of assuming the best and use the review as a jumping-off point for discussion and collaboration, but no one will be able to question enough or in the right places all the time. Fortunately, there is a proven practice that is explicitly and mainly about checking the code written against the author's intention: unit tests are exactly what we need, especially when they are written side-by-side with the implementation code, either immediately after ("code-then-test") or before (e.g. via TDD). If you aren't using unit testing and instead relying on code reviews to ensure correctness, a lot of misunderstandings and mistakes will slip through to QA or beyond.

The flip side of defect prevention is the completeness and robustness of the code. Does the code do all that it should? Again, code review only examines what the code does. Code review isn't so good at flushing out what the code isn't doing but should be. A really good reviewer will have a strong understanding of the intent and end goals of the code under review and thus can and should question the author on what might be missing. However, sometimes the author is already the person who knows best about what code should be doing, and other reviewers might assume too much given the code they see. Again, use the review as a jumping-off point for discussion and collaboration. But even this healthy attitude will only get you so far. Code reviews are no substitute for a team-wide mutual understanding of the both the user's needs and the big-picture direction of the software effort. It takes many other practices to build the product right; these include product planning time, technical design meetings, pairing, prototyping, and frequent review/discussion with the product owner and users.

Code reviews aren't good at revealing UI/UX shortcomings because code doesn't show the interface or how users interact with it. Testing, especially user-acceptance testing, of any user interface cannot be replaced by code review. A team must engage in UI/UX reviews, both among the team and with their users or user representatives. However, I do highly recommend expanding the idea of "code" reviews to more than code: include mockup/prototype reviews or even reviews of nearly-finished screenshots. Reviewing a screenshot, a UI mockup image, or a photo of a whiteboard is far more valuable than merely reviewing the code that might generate such an interface.

Technical non-coders can't rely on code review to stay in the know. Architects and tech leads who require that all code changes be reviewed by them do their teams a disservice. They are hindering all three of Pink's factors of job happiness: they are blocking their team member's autonomy, preventing them from attaining mastery, and de-emphasizing the purpose of building the software product. At best, they make themselves a necessary impediment to getting the job done. At worst they become the lowest level of rubber-stamping bureaucrats. Instead, architects and tech leads should be sure they are occasionally authoring code just as they did as senior developers, and they should sacrifice time doing code review if necessary to achieve it. By all means architects and tech leads should participate in code reviews (and their recommendations should be valued by all), but the team should be primarily responsible for reviewing each other as peers. The team should be empowered to approve and complete code reviews quickly and to do whatever necessary to prevent code reviews from becoming any kind of delay.

Finally, code review is a poor substitute for cross-training, mutual team learning, and team-wide ownership of the requirements, code, and software deliverables. Code reviews are just too narrow to be our main teaching tool. Because teams that do code reviews well will tend to shorter reviews in higher quantity, any given code review will not expose enough of the software to generate the kind of conversations needed to genuinely spread knowledge around. We can hope that code reviews will help spur on broader conversations about our software, but we cannot depend on them as the main tool for doing so. Furthermore, the deep knowledge needed to grow as a team can only come from implementing or improving that software. Reviewing does not make the reviewer as knowledgeable as its author. Planning, team organization, daily scrums, pairing, and swarming can all help with this. These practices and more will automatically happen the more your team takes on a mindset of collective code ownership.

Thus are you discouraged about the benefits of code review? Don't be. The supposed benefits above can still be had, just not to the extent that you might have hoped for in code reviews We can gain some defect prevention, correctness, robustness, usability, and learning from code reviews; we simply cannot rely mainly on code reviews for these goals. Supplement code reviews with other practices tailored to these goals.

But I haven't yet written of the underrated first-class benefits of code review. Turns out there are many gains for which we can rely on code review--and especially on team peer code review. Compared with my team in 2007, today we review lots more code more efficiently and with different goals. I'll explain a few in my next posts!  Till then, let me know how I can help with your team's code reviews or perhaps review your code myself as freelance side work.

Thursday, April 18, 2024

Full-stack? How about "Full Scope"

Hi, I’m Patrick Szalapski.

I make software and help others to make software.

I lead teams to make the most optimally-scoped business web apps and tools, often with .NET, growing such teams to deliver faster, better, and less expensively. I have a proven track record at multiple companies saving businesses millions of dollars and thousands of hours. I can lead or support the effort to figure out what you need, partnering with stakeholders to attack problems and quickly move to building solutions. My teams quickly grow to be highly productive, technically excellent, self-organizing, and happy.

Best of all, I pivot among these roles to whatever a team most needs for sustainable success. 

Wednesday, June 22, 2022

Catch me presenting on Blazor at Minnesota Developers Conference 2022 on June 22 in Minneapolis

I'll be presenting at the Minnesota Developers Conference, June 22, 2022 in Minneapolis on Practical Blazor.  I hope you can come and introduce yourself!

Also presenting will be some of my favorites, including Kamran Ayub with a fantastic approach to personal finance, Erik Onarheim on building a game engine in JavaScript, and Robert Boedigheimer on Regular Expressions in .NET.    So good to finally get back to an in-person conference!

EDIT: That's today!  Here's my slide deck for reference.

Friday, March 25, 2022

Avoiding unnecessary rendering in Blazor

In my previous post, I laid out the fundamentals of what can cause a Blazor site to be slow due to re-rendering. By far the most common cause of such slowness is when hundreds or thousands of components all need to re-render multiple times based on changes to parameters or explicit calls to StateHasChanged(). Often it is the case that only a few of the component instances in question truly need to re-render, but Blazor has no way to avoid such re-rendering, so it is up to the developer to worry about this concern whenever dealing with a proliferation of component instances.

The parent component

This potential slowness is often manifest in lists, grids, or tables where the content of each item is non-trivial. Imagine a UI with a grid of product images: a ProductGrid.razor something like…

<button @onclick="Add">Add new to top</button>
<ul>
  <Virtualize Context="productViewModel" Items="Products">
    <ProductTile Product="productViewModel" @key="productViewModel.Code" />   
  </Virtualize>
</ul>
@code {
    [Parameter, EditorRequired]
    public List<ProductViewModel> Products { get; set; } = null!;
    private void Add() => Products.Insert(0, new());
}

Note here we have used the Virtualize component to avoid rendering components for items in the List that aren’t currently shown (due to scrolling). We are sure also to use a @keyattribute on the root child element or component inside Virtualize.

So this parent component seems pretty simple and already optimized using Virtualize; how could it be a problem?

Narrow edits can cause wide re-renders

Note there is a button to add a new empty product. When this button is clicked, Blazor re-renders the home component, which means every child component will re-render as well. In our case, this probably means our ProductGrid and the 50+ shown ProductTiles, and suppose each of which has a dozen small components it shows and thus has to rerender. So that’s easily 770+ rerenders needed just to show the new item.
Ideally, when clicking the add button, there would only be a re-render of the ProductGrid, exactly one ProductTile (the new one), and all the small components (but only those in that one instance): thus 14 re-renders.

The reason each of the ProductTiles has to rerender is that its parent is rerendering, and it takes a ProductTileViewModel (one of our domain classes) as a parameter. Blazor cannot determine that nothing has changed in the fifty shown products, as it cannot interrogate all the contents of ProductTileViewModel and compare them to the previous value–remember, Blazor automatically avoids rerendering based on values only when all parameters are of certain well-known immutable or primitive types.

The main way to address this in the ProductTile component is to override OnParametersSet to detect to store the previous values for every part of the parameter that affects the displayed state, and override ShouldRender on the ProductTile component so that it will return false when the previous values are all the same as the current values.

But such logic comparing “previous to current” would have to be repeated in every component, yet customized for each one to ensure you are tracking all the properties you care about. I’ll avoid showing you the example code for this since it is not the way I recommend doing it.

Avoiding the re-renders

So here’s where my Nuget package Sz.BlazorRenderReducers comes into play. Using its DisplayHashRerenderComponentBase and implementing the protected override string DisplayHash get-only property, I can simply return a string that is unique for each display state that is possible; usually, this is just going to be a string that contains the value of every property that affects the display state in any way.

This has the benefit of reducing the code required to finely control re-renderings to two lines of code in most cases: one line to inherit from DisplayHashRerenderComponentBase and one line to override the DisplayHash getter. So, such a ProductTile.razor will look something like:

@using Sz.BlazorRerenderReducers
@inherits DisplayHashRerenderComponentBase
<li class="product-tile">
    <ProductImage Product="@Product" />
    <div>
        @if (!Product.IsInStock)
        {
            <OutOfStockBadge />
        }
        <ProductCode Product="@Product" />
        <ProductPriceTag Product="@Product" />
    </div>
</li>
@code {
    [Parameter, EditorRequired]
    public ProductViewModel Product { get; set; } = null!;

    // when this value is unchanged, supresses unnecessary re-rendering
    protected override string? GetDisplayHash() =>
        $"{Product.Code};{Product.Price};{Product.IsInStock}";

    // write a console line on every render
    protected override void OnAfterRender(bool _) =>
        Console.WriteLine($"Rendered {GetType()}");
}

Here, the DisplayHash get-only property can return anything that is uniquely determined by the data that affects what could be rendered by the component. True to its name, it is a hash for the display of the component. In this example, I’ve just shown a simple concatenation of the values that influence the display, but you could have any function here you’d like – perhaps using hash functions implemented on the parameters themselves, or serializing them using System.Text.Json, but I have found often a interpolated string is simplest and easiest to understand. The base component DisplayHashRerenderComponentBase will then properly store the previous and current values of this hash, and ShouldRender will return true or false appropriately, removing the need to reimplement such custom ShouldRender code in each component.

Drawbacks

Of course, one drawback to this approach is that it requires that all such components must inherit from DisplayHashRerenderComponentBase, thus removing the possibility of inheriting from any other base component, abstract or otherwise (unless of course you can in turn make that base component inherit from DisplayHashRerenderComponentBase). Fortunately, I have not seen much need to inherit a component from anything other than ComponentBase (which DisplayHashRerenderComponentBase itself inherits from), so this has not yet been an issue for me.

If you’ve followed along to this point, perhaps you can imagine the bigger drawback to this approach: it requires that the developer specify every potential source of changes to the display state. In effect, you have to “register” (by including in the DisplayHash getter logic) every property that might affect the GUI in each component, including its children components (after all. if a parent component avoids re-rendering, there’s nothing to cause its children to re-render either). As you can imagine, this can lead to confusion as to why a component isn’t re-rendering when it needs to–sometimes parameter properties are used but forgotten to be added to the DisplayHash. No error results and no cue is possible to tell the developer that they forgot to tweak the DisplayHash because of a new binding or some other new code indirectly affecting a bound reference.

However, even this latter drawback seems lower-risk than the frequent errors and confusion that results from manually making every component have a ShouldRender method that would itself need to take into account every relevant property and also would need to track the current and old values of each such property in order to determine if a render is necessary. So this technique seems to be a distinct improvement over having such nuanced and perhaps repetitive (though custom) ShouldRender overrides in many components.

Demo

So try it now on this demo page. To the code from above, I’ve added a toggle checkbox at the top to enable and disable the technique. We can open the console an d add an item, you’ll see a console line was written on each ProductTile render. With GetDisplayHash implemented, we’ve reduced the number of ProductTile renders from dozens to one–but don’t forget the child components that are unchanged: we’ve reduced the total number of components that render from several hundred to five. In my experience, this often cuts the “lag” after the user clicks the button from a few seconds to imperceptibly fast. On apps where users do lots of navigation or small manipulations, lag of a few seconds can kill your perceived performance, so this is a big win.

So if you have (or suspect you have) hundreds or thousands of unnecessary renders happening on many changes, give Sz.BlazorRerenderReducers a try to help drastically reduce the re-rendering that is needed. You can read more on the BlazorRerenderReducers project GitHub page and leave an issue with any concerns or questions, or just reply to this post.

Wednesday, March 16, 2022

Is your Blazor site rendering thousands of times?

When you think about it, data-bound real-time DOM updates are weird. We update values; then other code that we didn’t call knows somehow to call our code, then our libraries update the DOM based on those results. In Blazor, React, and Vue, it all just seems to work–but sometimes there is a nagging slowness to sites that bites our users on every click. What causes this? Usually, it is slowness in rendering.

This is a Blazor post, but first let me quickly contrast Blazor against the JavaScript framework/libraries React and Vue, which both have a robust “reactivity” implementation. In Vue, references for data binding are exposed in each component’s data and computed properties. Then, the magic of Vue automatically injects code using JavaScript’s prototype system so that on every set, code is run that causes every relevant getter to rerun, thus causing Vue’s internal representation of the DOM (called the “virtual DOM”) to update itself from the relevant data in memory. This is automatically followed by the internal code that updates the real DOM from the virtual DOM and then allows the browser to repaint the screen. This is actually quite elegant and it is all hidden from the developer. React does something very similar.

But in Blazor, there is no setter injection, as C# does not provide this capability natively. So instead, the Blazor component base classes internally rely on a simpler but less elegant approach: anytime the parameters to a component change, all the properties and methods that are bound in that component, and recursively in all its child components, will run. Since ideally the parameters to a component uniquely determine the values used therein and therefore determine the DOM for that component, this is seemingly good enough: everything updates immediately. Microsoft’s Blazor docs call this process “rendering” the component. We consider “rendering” in Blazor not to include the time it takes for the browser to paint this DOM, which is seldom (but not never) significant.

However, this can result in at least two pitfalls. First, the time to render (again, think “run C# code for my component”) can indeed be significant. In theory, I thought this would not be a problem; after all, hypothetical C# code run via the CLR (for example, in a unit test or command-line app) would take nanoseconds, and even if there were thousands of components on a page, we’re still talking microseconds here. The problem with this theory is that Blazor code run via WebAssembly isn’t run via the CLR, and so the time it takes a unit test to run a fragment of your component’s code is not the same as it will take a browser to run it. In fact, this difference can be small or it can be 100x or 1000x, and there isn’t always a good way to predict where this slowness will come. (In particular, I’ve noticed that deserializing is slow.) However, there is no simple way to profile Blazor WebAssembly yet, so it can be tough to isolate this kind of rendering slowness.

Secondly, when properties of parameters may have changed but didn’t, Blazor will unnecessarily re-render that component and all its children. This often causes lots of unnecessary re-renders; for example, consider when a property is set to the same value it already has. Blazor cannot look within user-defined objects to see that nothing has changed, so it presumes that something may have changed and it triggers a re-render. A corollary to this: unnecessary child re-renders will happen when a parent component re-renders even when the parameters to the child haven’t changed. Imagine updating the title of a large table when none of the cells have changed. C# can’t tell if this might have impacted a child, so it plays it safe by re-rendering all children anytime there is a chance that changed data affects the DOM rendered by the children.

So why is everybody having such a great time with Blazor WebAssembly and seemingly not complaining of these re-renders? Thankfully, Microsoft already has reduced the impact of these re-renders as much as can be expected. First, Blazor is pretty dang fast. Your site may be doing hundreds or thousands of re-renders in one second without you realizing it. Perhaps it’s bad, but just not bad enough for you to have noticed. Just add the following…

protected override OnAfterRender() => 
    Console.WriteLine($"Rendered {GetType()}");

…in all relevant components and see how much they re-render. You might be surprised at all the plate-spinning going on under the hood. Paradoxically, the speed of Blazor WebAssembly masks the theoretical slowness, and this theoretical slowness tends to grow as development of a site progresses till it becomes actual slowness as experienced by users.

Also mitigating re-render slowness is that, if a component’s parameters are entirely certain known immutable types (such as bool, int, decimal, string, DateTime, and Guid), then Blazor will cut off the re-rendering when the values haven’t changed. So, if you can make a component depend on a few strings or bools rather than one instance of a user-defined type (be it a class, struct, or record), do so.

Another good practice to mitigate the re-rendering penalty is to ensure that rendering or parameter changing does not repeatedly cause loading data from a web service or any other asynchronous operation. Structure your C# component code so that data is loaded only when detecting a change that requires it–often, when the previous value differs from the current value–rather than simply loading that data every time in OnParametersSetAsync or OnAfterRenderAsync. Also, do not bind the invocation of any such asynchronous method directly to a displayed element (e.g. <div>@(GetNameFromServer())</div>); instead, bind to a property and some other event should invoke the method call to populate that property, usually on user action or based on conditional logic within a lifecycle event handler. In short, assume your component will be re-rendered many thousands of times, and the mere act of re-rendering should not do any heavy lifting except when something relevant has changed. Do not make components that require parent components to carefully limit re-rendering.

Is frequent re-rendering causing a long list, table, or other repeated components to bog you down? Most loops in your Blazor markup can be replaced by instances of the <Virtualize> component. This component is a godsend: it will render only the iterations needed to provide a good user experience. The component often is a no-brainer drop-in replacement for a @foreach loop, so learn it and use it often.

Finally, Blazor provides the protected override bool ShouldRender() method. If you have some logic where you can decide when a rerender is necessary, just implement ShouldRender to return false in the cases. Don’t worry about coding the first render as a special case: ShouldRender doesn’t get called on the very first render of a component, so you don’t need to add code to cover the first render case. (Also note that if ShouldRender returns false, then child components will also not be rerendered.)

Even with all these partial solutions, you may well find yourself in the situation where you’ve optimized all you can and many components are still re-rendering too often. How do you reduce unnecessary renders when dealing with non-primitive parameters without adding lots of non-intuitive, custom complexity in ShouldRender? I’ll have a solution for this in my next post.

Sunday, December 13, 2020

C# ascendant: Nuget packages to try (and some that are no-brainers)

 

I feel like with the advent of Blazor, the power, usefulness, and ubiquity of C# and .NET in general has kicked up a notch.  At the same time, the growth in functional programming (LINQ in C#, F#, Clojure, Scala) and separately, dynamic typing (Javascript, Python), and fluent APIs/DSLs all give us better ways of both thinking about and writing our code--we can be more expressive and simpler while being less error-prone.  C# is becoming the best of all worlds as these paradigms become nearly fully enabled in C# with the variety of NuGet libraries enabled.

​Here are some interesting NuGet packages that I haven't used yet, but might take advantage of soon.

  • FluentValidation - On my current work project, we just wrote a bunch of complicated (though not complex) validation code, all custom, and mostly with nested if statements.  I wonder if this would be more readable and intuitive using a library like this?
  • Humanizer - So much of our code is just variations on mapping identifiers, timestamps, or logic into human-readable forms.  This package provides a ton of methods for doing this in a simpler and more intuitive way.
  • FluentMigrator - So far, I've never worked on a project that has successfully kept its database schema in code, other than by retaining SQL scripts.  Could this library help?
  • Polly - Retries, timeouts, and more - I've often written custom methods to deal with various service accessing needs.  Next time I feel like I should, I'll have a look at Polly.
  • OneOf - I see often where I need to return two different types--one for success and one for an expected failure or "nothing to do" case.  Functional languages have handled this better than OO languages from the start, but maybe this library could bring me the ability to return OneOf<bool, FailureMessage> or any other union that might be useful.
  • Dynamic LINQ - Could it help or hurt to be able to dynamically build your LINQ logic depending on runtime state?  I've often wanted to, but understood why C# can't do it by default.  Could this package enable such power? Or would it do more harm than good?

These are of course in addition to the ones I've already used repeatedly--if you don't know them well, take a look for sure:

  • Dapper - EF is great but I still think it is overfkill for most needs, especially if your team is proficient in writing SQL (and they should be).  I cannot bear the thought of spending an hour to make EF do what I want when I could just write my own SQL and be done with it.  Dapper does the part I want (Mapping rows to objects) and leaves out the part I don't (Mapping code to queries).
  • FluentAssertions - It is so much better to write intuitive assertions in my tests than to even take the 20 seconds to write it with traditional MSTest assertion syntax. Goodbye Assert.IsTrue, hello result.Should.
  • Moq - There seems to be nothing better for detouring/mocking in your automated tests.  Even though .Setup and It.IsAny<T> get tiresome, I haven't found anything better.
  • Swashbuckle with Swagger and SwaggerUI - This trio gives my API documentation with hardly any effort.  Nice!
  • Serilog - We finally have a winner in the logging library fight.  Everyone loves it; you will too.  Ditch Log4net, nLogger, or anything else you might have struggled with before.

Sunday, April 12, 2020

See me at the all-online Minnesota Developer's Conference, May 4, 2020

On May 4, 2020, I gave a talk on Practical Refactoring in C# at the Minnesota Developer's Conference, live online. The all-day virtual conference was only $20 and has some of the best speakers around on C#, Blazor, Javascript, Azure, and soft skills for developers.

My session is all about how to make your C# code better and to do it more routinely and with high-confidence. Too often, we are afraid to refactor because we might break something--but we err on the side of false caution, because our dirty, confusing code causes more bugs than a refactoring would. I'll show my favorite refactorings and demonstrate how to get into the habit of always improving.

I also am excited to see my colleagues Kamran Ayub, Erik Onarheim, and Elsa Vezino present there, and I always love more Benko-tips and wisdom from Ward. Thanks a ton to Jason Erdahl and his team at ILM for moving this thing online rather than cancelling--I've never been as interested in a live online conference before!

Video: Practical Refactoring in C#

Slides

Demo Code
My favorite refactorings:
  • Tool-assisted:
    • Rename
    • Extract method
    • Move
    • Remove unused usings
    • Reduce nesting: Invert if; combine singly-nested Ifs;
    • Extract interface
    • Restrict access modifiers
    • Code against nonexisting members then generate
     
  • Manual:
    • Simplify boolean logic
    • Early return
    • Reduce newline usage
    • Convert If-else to ternary
    • Eliminate/simplify loops with LINQ
    • Iterate instead of repeat code (try lambdas or private classes)
    • Replace Start/Stop methods with an IDisposable
    • 7 steps to add dependency injection
Other sources:

Sunday, February 2, 2020

Presenting at Twin Cities .NET User Group, Thu Feb 6 at 5:00

On Thursday, February 6, I will be presenting at the Twin Cities .NET User Group on Practical Refactoring With C#. It is at 5:00 PM at General Mills in Golden Valley, MN. Please introduce yourself afterward if I haven't met you before. Hope to see you there.

Monday, May 13, 2019

Easy screen resolution changes

I’m using the following AutoHotKey shortcuts to quickly change my screen resolution on my 27” 4K display from 4K (normal work) to 1080p (or “2K”, for screen sharing over Skype, MS Teams, or Slack).  I simply press Win+Alt+2 for 2K and Win+Alt+4 for 4K. Enjoy!

#!4::
ChangeResolution(3840, 2160)
Return

#!2::
ChangeResolution(1920, 1080)
Return

ChangeResolution(Screen_Width := 1920, Screen_Height := 1080, Color_Depth := 32)
{
     VarSetCapacity(Device_Mode,156,0)
     NumPut(156,Device_Mode,36)
     DllCall( "EnumDisplaySettingsA", UInt,0, UInt,-1, UInt,&Device_Mode )
     NumPut(0x5c0000,Device_Mode,40)
     NumPut(Color_Depth,Device_Mode,104)
     NumPut(Screen_Width,Device_Mode,108)
     NumPut(Screen_Height,Device_Mode,112)
     Return DllCall( "ChangeDisplaySettingsA", UInt,&Device_Mode, UInt,0 )
}
Return

Thursday, May 9, 2019

Billy Hollis on interaction design

Image result for billy hollisI just finished attending NDC Minnesota 2019.  One of the highlights of the conference was Billy Hollis’s session on UX Principles, as well as his workshop on practical steps to tackle a design task.

Big takeaways:

  • Users have much Inattentional blindness--they shut out anything other than the things we want to see or expect to see.  Don’t fight this.
  • When trying to improve or iterate upon a app’s design, first make observations about the user’s experience and write them down in short, simple, English sentences.  (These sentences do not go onto the product backlog yet—they are unactionable observations, not user stories.)  Then sort by importance, filter, and dedupe them, and then discuss as a team, and only 6-10 design tasks (or stories) to go onto the product backlog.
  • Know what is most important to the users.  Most experiences suffer for lack of emphasis or visual cues of relative importance.
  • Sketch/mockup designs.  Use a low-fidelity tool or just pencil or whiteboard. 
    • Sketch 3 or 4 designs, not just one.  One sketch usually results in very particular, nitpicking feedback, but 3 or 4 sketches gives the opportunity for a range of reactions on the things that matter most
    • Shoot for a “traditional” sketch, an “innovative” sketch, and a pushing-the-envelope sketch.  Often this gets the stakeholders pushing themselves in the right direction.  Don’t pigeonhole yourself to a
  • The point of good aesthetics is to give impression of high-quality software; always focus on actually having high-quality software without putting lipstick on a pig.

Hollis is one of my favorite presenters; if you get a chance to see him, I highly recommend it.  He has a Pluralsight course on UX principles and speaks around the country. 

Saturday, November 18, 2017

Tweaking Scrum

I presented a short talk called Tweaking Scrum at Agile Day Twin Cities 2017. I hope to write a longer post on it, but for now, here is the slide deck, as well as notes from the followup open space discussion.

Thursday, May 11, 2017

Microsoft Build 2017 conference Liveblogged notes

Let me know if you want further thoughts on anything below.  What a busy conference!  It is more crowded than I thought, and I definitely not bored.

TLDR: Go to Build 2017 on MSDN Channel 9 to search for the videos that interest you the most.  The best education for me was the New in .NET “three runtimes” session by Hanselman and Hunter, but the most impressive was certainly Saqib Shaikh’s blind coding demo in the first five minutes of the “what’s new in Visual Studio” session.

Full notes:

  • Keynote 1 – Satya Nadella, Scott Guthrie

    • IoT/Cloud and “Intelligent Edge”: now able to sync logic in Azure cloud to devices apart from the cloud
    • Hanselman: Azure CLI, .NET Standard, PostgreSQL and MySql on Azure; SnapPoints (see breakout sessions)
    • AI / learning APIs: language, text, audio, more
  • New in .NET: Scott Hanselman & Scott Hunter
    • .NET Core is highly wanted; C# is #3 language, growing, talked about
    • Architecture Guidance now available; see http://dot.net/architecture: samples, guides, etc.
    • .NET Standard - formerly PCLs; a contract - allows sharing code, binaries,
      • No change to the way code works
      • For libraries, not for UI apps
      • UI might be Framework 4.7, Core, UWP, Xamarin, Unity, etc.
    • .NET Core 2.0 has one package reference for ASP.NET All
    • VS 2017 Update 3: more refactoring features, live unit testing, C#7.1,
      • File globbing: drop files into folder; appears in solution explorer
      • Can edit .csproj without unloading
      • Live unit testing of .NET Core and Framework too.
      • Debugging: tells you WHY exceptions are thrown
      • Ctrl+T, "F" for file, "M" for member, etc. – reduces need for Resharper
      • Suggesting variable names, add a property with Ctrl+. – reduces need for Resharper
      • VS2017 Code style conventions and enforcement – reduces need for Resharper
      • Preview of FxCop live suggestions; live fix for you
    • Can build .NET Core on Mac using new Visual Studio for Mac
    • Azure
      • now has dependency map with warnings, key stats, errors; example errors are given with full detail
      • automatically takes snapshots (dumps) of state with errors from items running on Azure
      • Can set additional snappoints (not breakpoints) to get these dumps: doesn’t stop anything or slow things down; can do it in prodution; can look at with “snapshot debugger” – need to start collection and get snapshot as soon as it happens, but app doesn’t pause
      • Azure Functions: serverless functionality; based on .NET libraries; can debug locally or remote debug
        • can run functions based on triggers
  • Containers with Kubernetes and Docker: Brendan Burns & Gabe Monroy
    • Most outages are self-inflicted: our systems are complicated.  We have understanding of our local space, but not about how our changes affect something else. 
    • Usually we have Application, Server Cluster, Kernel/OS, and Hardware to worry a bout
      • “DevOps” is mostly about the Application layer, but it also should be about the rest of  layers
      • Container Cluster Managers, Containers, IaaS/vitrualization decouple us from other layers
    • New system for Kubernetes orchestration: “Draft” making containers easier for developers; reduce conceptual overhead; demo:
      • "draft create” – scaffolds a docker app
      • “draft up” – sends app to ACS Docker Container cluster, automatically
      • Do not have to install Docker or Kubernetes on client, just need a remote ACS Docker Container cluster running (E.g. as set up from web hosting team)
    • New tool Helm – a package manager for your Kubernetes cluster
      • Helm needs to be installed as an app on Kubernetes cluster, then you can go nuts with packages without hassle
      • “helm search <term>” to look for packages
      • “helm install <packagename>” – installed, but also helps you configure it
    • Still need application management for multiple devs, source control, CI tools: example from GitLab
      • set up a file .gitlab-ci.yml
      • uses a pipeline as set up in GitLab
        • spin up container, run build, deploy, spin down container
        • so close to Kubernetes that we can customize the actions in the pipeline
      • That’s great, but what if we aren’t using Gitlab?
    • These systems are becoming modular, more accessible to all. 
      • We don’t make GUIs anymore, we rely on existing OS and tools to do so
      • E.g. Kube Lego simiplifies LetsEncrypt to automate certificate acquisition whenever needed in a Kubernetes cluster – never need to manage certs
  • Azure CLI - Kamaljit Bath:
    • To manage Azure, you can use GUI, PowerShell, or new Azure CLI 2.0 (for general use) or 1.0 (for ASM services)
    • Natural and idiomatic integration with bash and GNU/Linux tools
    • Meant to fully support Azure services
    • Can be installed on any OS with a native installer, or use the web version
    • Examples:
      • “az” list all commands
      • “az account list” list subscriptions on my account
        • “az account list –o tsv” for tab-separated values
      • “az vm list” list VMS on my subscription
        • “az vm list –o json > file.json” get JSON version in a file
      • “az vm show –h” help with all the parameters for az vm show
        • “az vm show –g <TAB>” for autocomplete on groups
        • “az vm show –g MyresourceGroup –n Mynewdemovm –show-details”
      • “az find –q plan” – help on commands with "plan”
      • “az vm list –o json | jpterm” – show JSON on left side and query results of a JMESPath expression on right side in jpterm
        • “az vm list –query ‘[]{JmesExpression}’ – same thing without the tool
    • Interactive mode – “az interactive”
      • Gives much intellisense-like help, more examples to choose, help text
      • “vm create ::1” runs first example for vm create
      • Can go into specialized scopes, e.g. “cosmosdb”
        • create –name MyCosmosName"….
    • Search for “Get started with Azure CLI 2.0” on microsoft.com
  • Angular and Typescript – Rob Wormald (Google)
    • To be clear: “AngularJS” is Angular 1; Angular 2+ drops the “JS”
    • Angular apps are made of components, and put together with decorators
    • Everything Google does runs on Angular
    • TypeScript and Open Source CLI tools have not been used inside Google – instead were using Google Closure Javascript that no one likes – now transitioning to TypeScript because:
      • has inline types
      • fast to recompile
      • decorators
      • is Google Closure-compatible (side-by-side)
      • IDE support
      • Use bazel.build instead of Grunt/gulp/webpack
  • WCF microservices in containers is a work in progress– Jeff Fritz
    • WCF is big and heavy, lots of power
    • Must use Windows containers for WCF.  Linux containers won’t work.
    • Windows containers are big but easy to use.  Good to get rid of managing VMs. We’ll have better SoAs.
    • We support HTTP(S) and TCP bindings, IIS-hosting and self-hosting, anonymous endpoints “very easy” in a container
      • Do not support MSMQ or HTTP authentication
      • Can’t pass in environment variables on the command line, can’t orchestrate very easily – looking into extending Configuration Manager
    • WCF dockerfile example
    • Sample code
    • Visual Studio with standard ASP.NET project doesn’t understand WCF on Docker, nor debugging it
    • Maybe better to use a self-hosted WCF host (“BasicHttpHost” in the sample code) – still can’t debug
    • How to do it: Install Docker for Windows, pull the latest microsoft/wcf image, try lift-and-shift an existing service,
  • Keynote 2: Windows – Terry Myerson, Joe Belfiore, Abolade Gbadegesin, Alex Kipman
    • Windows 10
      • Fall Creators Update: new app Windows Story Remix (photos, videos, Paint 3D, work with phones): automatic videos and compositions like Google Photos; automatic sync with phones, ink notes that can be anchored to things in videos; Devs will have access to 3D/mixed reality features via APIs
      • Fluent Design System will start influencing apps with light, depth, motion, material
      • OneDrive Files On-Demand: mix of file on hard drive, cloud, or both in Windows Explorer; more automatic synching
      • Windows Timeline: keeps track of all tasks from earlier; search; automatic syncs tasks across devices
      • Connect your Android/iPhone to your Windows Phone
      • Cloud-powered clipboard – copy/paste across devices (e.g. integrated into SwiftKey)
      • XAML Standard 1.0 coming: will unify UWP + Xamarin UI code
      • UWP features: pen integration, material, fluid transitions
      • Graph APIs for people, activities, devices – built in to Windows 10, available via “Project Rome SDK” for Android and iOS
    • Windows Store + UWP apps
      • Visual Studio Test Cloud will have full support for UWP and many devices
      • Windows 10 S is a version of windows that is only for Windows Store Apps (for schools, other specialty apps)
      • Apps like Spotify, iTunes, SAP Digital Boardroom, Autodesk Sketchbook or will be in Windows store
    • Dev Tools
      • Ubuntu, SuSE Linux, Fedora soon be apps in Windows Store
      • Xamarin Live Player: .NET C# Xamarin apps deployed to iOS device with full debugging capabilities, instant sync on UI changes
      • Narration on every Windows 10 PC – can tell what the visually impared will experience; Narrator developer mode to put self in the shoes of a visually-impared person
    • Windows Mixed Reality: VR, AR; PCs, Consoles, and holographic computers/headsets
      • Motions controllers: optical sensors, trigger, stick, touchpad – no external cameras
      • headset + controllers from Acer for $400 coming 2017Q4 – can preorder at http://windows.com/mixedreality
  • Private conversation: F# could be good for creating DSLs or anything where composing/manipulating functions would be complicated in C#. Using duck typing-like type inference simplifies coding.  Don’t be afraid to have most of an app in C# but a key part in F# if necessary.
  • Developer’s Guide to the Galaxy – snippets of various demos or talks
    • Mixed reality is hard to develop?  Who does all the 3D?  It is possible to dev with only a PC and webcam.  Using Unity, add a camera and a image to the scene.  Add a 3D model from a .fbx (e.g. from Remix via Paint 3D), add to hierarchy, scale and position it.
    • Chris Barker on MyPeople in Windows 10 Fall Creator’s Update: API is simple; can use toaster popup with XML
    • David from France on WebVR and BabylonJS: full 3D and VR in the browser
      • Render 3D scenes
      • switch between plain view and stereoscopic fisheye view e.g. for Cardboard
      • Can use C# and Typescript;
      • Detect gaze, select objects, even gather video texture from webcam
    • JD - Progressive web apps:
      • A “Service worker” runs independent of a browser frame – can speed up if the feature is available, enables offline functionality, not distruptive otherwise
      • Use PWA Builder to help get started – gets a service worker ready for you to drop into your app
      • Can also use hardware from Javascript web app
    • UWP Community Toolkit Sample App in the Windows Store – can copy XAML code, etc, from it
  • .NET Q&A Panel – Damian Edwards, Mike Harsh, Immo Landwerth, Rich Lander
    • Portability Analyzer tells us what changes apps need for .NET Core.  Tips:
      • Use .NET Core 2.0.  .NET Core 1.0 has much lower compatibility.
      • Error messages have good suggestions (click the triangle)
      • Compiler messages might be easier to start
      • Be sure to use VS2017 Update 3
    • .NET Core still supports P/Invoke, even on Mac & Linux – COM interop is not supported, MSMQ not yet supported but would be Windows-only if it is supported; System.Drawing and Directory Services not supported
    • Must call ConfigureAwait(false) all the time on the server?  See also this Q. The default of “true” is still better.
    • Need Core 2.0 or Framework 4.6 for snappoints/debug snapshots
    • Why use .NET Core rather than Framework for web apps:
      • Cross-platform (Linux, Mac OS, ARM)
      • Self-contained .NET libraries (don’t need to install new framework on server)
      • .NET Core is changing quicker and getting more new features (it is also open-source)
      • Some performance advantages
    • Other Framework vs. Core ideas
      • .NET Framework is not going away, support will continue, but it won’t get too many new features
      • Can run .NET Framework apps in containers – don’t rewrite things
      • Can use a ASP.NET Core API in front of a Framework library
      • Not recommended to run ASP.NET Core on .NET Framework—it is really meant for .NET Core
    • TLS 1.2 support in Framework 3.5 is in a hotfix, and must be enabled via registry key.  It is fully in Framework 4.0
    • Web Assembly support in .NET?  Nothing decided yet (probably not)
    • How to load different versions of the same assembly?  e.g. may get TypeEquivalenceExceptions – very hard to overcome with an easy way.  Still using the later version is the easiest way.
    • There is one specific use case that `async void` is for (event handlers); never use it otherwise.  Probably need a way to catch it in Code Analysis.
    • Can run Kestrel on Raspberry Pi? Not with UWP on Windows IoT.  Can run a C++ Console app on Windows IoT.  Not easy.
    • Managed Add-in Framework not on .NET Core.  No one cares about it.
  • Deep Learning demo:
    • Started with audio data for leaks in a pipe; using a Jupyter notebook to walk through: run microphone ball through pipe, get WAV file, get integer values from it, Fourier transforms to get an array of arrays, then make images, then colorize them, then build a neural net, then train the model, then run model against any image to predict probability of an image showing a leak; show results in a 2x2 confusion matrix; then figure out ways to improve the model
    • Real-world: trained with 2000 images was good enough
    • Transfer Learning can help you train the model
  • Visual Studio 2017 and the CI pipeline: Ahmed Metwally & Mark Wilson-Thomas
    • Can configure CI in Azure and VSTS right from Visual Studio; build failure would happen right in Visual Studio status var - Not useful with Jenkins
    • Visual Studio now has tighter feedback: see problems as soon as they are made when coding
      • When “in the zone”, don’t always want to fix all the little issues.  VS can help us understand what Code quality is at..
      • Change pending indicator is in the status bar
      • New “Build & Code Analysis results” in the Changes pane helps you commit with confidence (or fix issues before you do)
    • Continuous Delivery extension for Visual Studio is new.  Road map:
      • Today: Support for ASP.NET, CI Build failure notification, link to build results,
      • Next: in-IDE pull requests, code analysis in pull request
    • join on slack aka.ms/cd4vs_slack
  • Visual Studio 2017 Coding at 88 MPH Tips and Tricks: Justin Clareburt and Alison Buchholz
    all at aka.ms/vsnavshortcuts, below are the ones that were new to me:
    • Git Repos from other machines show up on Start Page – easy cloning
    • Folder view supported in solution explorer – do not need projects
    • Shift+Alt+Enter: full screen mode
    • Esc: go to main text editor – Alt+F6 go to recent tool windows
    • Shift+Esc: close current tool window
    • Suggested mappings:
      • Window.Dock: Ctrl+Insert
      • Wondow.DockAsTabbed: Ctrl+Shift+insert
      • Window.AutoHide: Shift+Insert
      • Windows.HideAll: Shift+Alt+Ins
    • Move to next/prev tab Ctrl+Alt+PgDn and +PgUp
    • Ctrl+T: Go to all box with filters
    • Shift+F12: find all references
    • Ctrl+Alt+Home: keep previewed doc
    • Alt+W, L: Close all documents
    • Ctrl+Shift+F12: go to first error
    • Solution Explorer: Sync with active document button (or track active document option on )
    • Extensions
      • Git Diff Margin:
      • Solution Error Visualizer
      • Fix Mixed Tabs
      • Hot Commands
      • Open Output Folder
      • Add Folder to Solution
      • Multi Edit Mode
  • The future of Visual Studio – Amanda Silver, Tim Sneath
    • Blind coder demo – Saqib Shaikh.  Pretty amazing how a blind person can code efficiently.
    • Visual Studio is the most popular IDE for web developers; C# is the third-most popular language
    • VS2017 version 15.3 will be out soon; lots of new features
      • Emphasis: Catching issues early (“shift left”)
        • Realtime experiences for unit tests, violations
      • New installer, choose only the parts you need
      • Live unit testing
      • Refactorings: sorts, null checks, string interpolation, many more
      • Code Analysis extension
      • “Enable Docker Support” in new Project dialog
      • True Linux C++ development in Visual Studio
      • Visual Studio Data Scientist mode for R
    • Visual Studio for Mac
    • Experiment: VS can infer EditorConfigFile for style rules
    • Linux subsystem – full Linux apps
  • The future of C# – Dustin Campbell, Mads Torgensen
    • C# 7 and 7.1
      • tuples, tuples with named items
        • Infer names of Tuple items in C# 7.1
      • async Task Main now allowed
      • new Task types – ValueTask (good for memory intensive tasks
      • Deconstruction: get values underneath a tuple
        • underscore for items we don’t care about
      • Local functions
      • Pattern matching (types or constants), even in switch, even with conditions
      • Inline variable declaration `out int i`
    • VS features
      • New braces connected with faint lines
      • depend on C# version autofix in C# 7.1
      • “convert to binary” refactoring
      • Better “go to references” and “find references”
      • Find references of literals
      • Auto complete for partially typed namespaces/types
      • Suggested parameter names (intellisense)
      • Autofix for git-style merge complete
      • Press enter to split a long string into concatenated strings
      • Refactor to initialize property (like Resharper), separate nibbles
    • C# 8
      • Default implementations inside interface (avoids requiring all implementations to implement new members)
      • Annotated possibly null (e.g. `string? s` as a return value)
      • foreach await, using await
      • more flexible extension methods
      • Records (automatically generated classes)
  • Supercharging debugging in Visual Studio – Kaycee Anderson
    • Execution Control
      • Remember to add command-line args in Project Properties – Debug
      • Can start debugging with F10 – first point
      • Recent function returned values now show in locals; to see in watch window with “$returnValue1”
      • New choice “step into specific” instead of stepping to the first one
      • New icon for “run to click” just like run to cursor, but more discoverable
      • Can “run to cursor” from call stack window, instead of step out, step out, step out
      • `if (debugger.IsAttached) Debugger.Break();` – hardcoded breakpoint
    • Data inspection
      • Choose among several visualizers in data tips
      • Alt+F12 for peek window
      • Hold Ctrl to hide intellisense overlays
      • Can right-click to add expressions to pinned watch snips
      • “Make Object ID” makes a reference $1 that you can use in watch window even when other references change
    • Breakpoints & Diagnostics
      • Breakpoint actions: make conditional, make tracepoint
      • quick and dirty profiling – see pertips at the right side of each recently-executed line
      • consider keeping Diagnostics tools window – now has more useful summaries
        • take snapshots to compare two points in time e.g. memory
      • Coming soon: historical debugging via “Step back”
    • Exceptions: New exception helper in debugging – has…
      • inner exception scroller
      • more information on cause of exception,
      • optional exception settings (also there’s an exception settings window)
    • Multithreading
      • Parallel stacks window: shows visualization of all threads
      • Parallel watch window: see values across all threads
        • Can freeze thread in parallel watch window, run all other threads
      • After a breakpoint is hit, remove breakpoint to avoid hitting the same breakpoint in other threads (step around)
        • can filter breakpoint to a thread ID
    • aka.ms/vsdiagsamples – the samples for the above
    • aka.ms/diagnostics
    • aka.ms/SuperChargeYourDebugging
  • Miscellaneous notes on the side
    • .NET Conf 2017 is Sep 19-21: free online conference
    • .NET Fringe conference June 4-6
    • Recurring theme: increasing reliance on CLIs, especially ones that look like bash

    Sunday, May 7, 2017

    Presenting at DevJam's ProductConf 2017 on Tweaking Scrum

    I know it's last minute, but I will be leading a talk on Tweaking Scrum for Better Products, this Monday May 8, 2017, at DevJam's ProductConf in St. Paul  It looks like there is still time to register!

    It is a mistake to leave the product decisions to the Product Owner alone. Every member of an always-improving, self-organizing Scrum team will help to make the team's work and the product better. This highly collaborative session will have a section on prepared insights on how to tweak typical Scrum practice as learned from several years of software development on Scrum teams; then the bulk of the time will be open for your insights on how you have tweaked Scrum that you might share with the group. However, this discussion will not simply be show-and-tell time; instead, we will think through the suggestions from a product lens in order to see if the potential impact is outweighed by missing out on the benefits from "untweaked" Scrum. We will avoid dogmatic thinking but not controversy as we tweak Scrum together.

    If you are coming to ProductConf, be sure to come over and say hi!

    Update: here is the slide deck for that talk: https://www.slideshare.net/secret/M66bvQ8EzQvVvf

    Tuesday, March 28, 2017

    I'll keep this short as it isn't software-related, but I started a new "amateur philosophy" podcast called "Objections to Objectivism", which explains, explores, and criticizes the philosophy of Ayn Rand. Check out the Objections to Objectivism site, the O2O podcast feed, or find it on any podcast app like iTunes, Stitcher, TuneIn, or Podcast Addict.

    Tuesday, November 1, 2016

    Scrum Guide updated to include valuing commitment, focus, openness, respect, courage

    Recently, Ken Schwaber and Jeff Sutherland updated the official Scrum Guide to include SchwaberSutherlandJuly2016the Scrum values, which are:

    • Commitment
    • Focus
    • Openness
    • Respect
    • Courage

    Sutherland emphasizes that teams adopting Scrum must have a commitment to change and to take your company into the future. Without embracing this change, "you can't get there" and Scrum will be of little value to you.

    Schwaber highlighted that focus to work on nothing but the sprint goal will yield the best results; working on other items destroys your productivity. Sutherland noted that doing twice the work in half the time is only possible if the teams focus on the sprint goal alone.

    Stakeholders and the team alike need to have a spirit of openness. Sutherland stressed that all happenings must be visible; only when everyone knows what is happening can you best decide how to adjust and how long work will take. We should go so far as not to work on anything that isn't visible.

    These are only possible with respect for each other; blame and cover-ups result in poor outcomes. If we respect everyone where they are, they can be empowered to grow and achieve. Sutherland says this applies even to high-pressure cutthroat venture capital-driven startups. Schwaber stresses that respect creates a positive hubbub, a buzz that is charged up with work getting done.

    Courage, both to do the right thing and to attempt hard things, is necessary because change is risky. Leaders have a big role to encourage taking wise risks and accepting the downside that sometimes results. Schwaber emphasizes that Scrum provides a safety net--you will never waste more than a sprint's worth of work.

    Scrum has the power to make your work life more fun, more balanced, and happier.

    View the Scrum Guide: http://www.scrumguides.org/scrum-guide.html - The newest changes are near the beginning, under "Scrum Values".

    Friday, February 12, 2016

    A compact layout bookmarklet for Azure DevOps / Azure Boards work items

    UPDATED 2026-09

    Do you want your UI controls and whitespace cruft taking up half your browser window, like the default view in the first image?  Wouldn’t you like your Azure Boards backlog (in Azure DevOps) to instead show as much info as possible, as on the second image below?

    Azure Board fix  ← Drag this to your bookmarks/favorites bar (Ctrl+Shift+B to toggle it in Edge/Chrome).





    Then, whenever you have Azure DevOps web work items or the task/story board open and you want to see more content and less cruft, click it.  Be sure to use "full screen view" in Azure Boards and in your browser as desired.
    I’ve also made it available as a gist.

    [Bookmarklets are tiny programs stored inside bookmarks or links. Similar to (but simpler than) add-ons and extensions, they add new tools to your web browser. Bookmarklets are shared on web pages as web links. To add a bookmarklet to your browser, right click on its link and choose the bookmark option, or drag it to your bookmark bar. To use it, simply click on the new bookmark you added.]