z-index Is Confusing, but It Doesn't Have to Be
CSS
Debugging web applications can be difficult sometimes. When debugging a failed HTTP GET request in Application Insights you have all of t...
.NETSupporting IE comes with challenges if you are using es6, and while babel helps greatly there is a few gotcheas. One of the main one is u...
JavaScript IE 11For a long time, we were dependent on the CSS frameworks of others – and we were quite happy. 😀 As our needs grew, we needed a framework...
Sass Dart SassAutofac is an inversion of control container for .NET. It allows developers to register items and then later use those registrations to i...
.NETWorking with dates can seem a little daunting sometimes. We need specific formatting, and hopefully we don’t have to deal with timezones ...
JavaScript Vue HTMLWe recently started using SendGrid to send emails in production. As part of that, we noticed that emails to outlook.com, hotmail.com, msn...
SendGridHave you found yourself getting lost in large Vue components that have multiple features? The Composition API is a new optional syntax in...
vue3 composition frontend developmentAccording to https://www.chromestatus.com/feature/5088147346030592 at the time of this blog post Chrome 80 is targeted to default cookies...
.NETOur RimDev.FeatureFlags library uses Newtonsoft.Json as part of roundtripping the on/off state in SQL. With that we use TypeNameHandling....
.NET.NET’s LINQ library has extension-methods that will return a default-value if not found in a collection. These are a great time-saver if ...
.NET LINQHow are we building our websites? Are they truly for everyone or if we ask ourselves honestly are they just for us? The way we currently ...
care performance UI/UX frontend developmentWorking with NPM packages locally can feel a little bit overwhelming at first. Over the last year, we have transitioned some of our infra...
npm tgzIn order to avoid having large files in our Git history we’ve been using Git Large File Storage (LFS). It commits a marker in the Git rep...
GitHow do you not overwhelm the user with a wall of content? When thinking about user experience, this question often comes to mind as we d...
UI/UX frontend SEOIf your idea of accessibility is making sure your site hits a specific WCAG score, you’re probably leaving out some users. Maybe accessib...
Accessibility UI/UX frontendAbout a year ago, RIMDev started a DevOps transformation. As part of that transformation, we started to use slots in Azure app services, ...
devops rimbot chatopsOver the previous year we’ve been working to improve our overall uptime. While we aren’t prepared to offer 99.999% availability in the wa...
Azure DevOpsOur starting point This past year we’ve been on a DevOps journey. While we haven’t been in a state of stagnation or chaos as a team, we’...
Azure DevOps TerraformI never thought ordering of relational static fields and properties in C# mattered. And, then, I started getting NREs on a property I know was set to a static-instance…
public static void Main()
{
Console.WriteLine(Person.Empty == null); // prints 'True'
}
public class Person
{
public static readonly Person Empty = empty;
private static readonly EmptyPerson empty = new EmptyPerson();
}
public sealed class EmptyPerson : Person { }
If you were to step-through the code, the first-time Person.Empty
is called, empty
is null
and gets returned as-is. Then, empty
is initialized. But, it’s too late since Empty
is static and will only get “initialized” once. But, if we swap the ordering…
public class Person
{
private static readonly EmptyPerson empty = new EmptyPerson();
public static readonly Person Empty = empty;
}
Now, empty
is an instance of EmptyPerson
when Empty
is called and everything is good.
The problem above is only a problem for static
fields/properties. If either were to be an expression-member, then ordering doesn’t matter:
public class Person
{
public static readonly Person Empty => empty;
private static readonly EmptyPerson empty = new EmptyPerson();
}
// This variation also works...
public class Person
{
public static readonly Person Empty = empty;
private static readonly EmptyPerson empty => new EmptyPerson();
}
public class Person
{
public static readonly Person Empty = new EmptyPerson();
}
But, I opted to use the private
member in several other spots within my code…
Just as a final warning, don’t do this because while you have a getter
-only (i.e. readonly), you’ll also create a new instance of EmptyPerson
every time Empty
is called. 🤯
public class Person
{
// Don't do this!
public static Person Empty => new EmptyPerson();
}