Building an Online Store with Platform UI and Hugo
With the release of our CSS Framework, Platform UI, it might be fun to actually build something with it! At RitterIM, we have an interna...
CSS Frameworks Static SitesWith the release of our CSS Framework, Platform UI, it might be fun to actually build something with it! At RitterIM, we have an interna...
CSS Frameworks Static SitesIt’s been a few years, several great people, an awesome company, and a cool thing we made 😀 Once upon a time, we had a mixed bag of fram...
CSS Frameworks RIMdevI’m a huge fan of animation on the web, especially when it comes to user interaction. A simple way to include such a thing on webpages is...
CSS SCSS JavaScript UI/UX frontendI dedicate this blog post to all the QA testers that expose all the flaws in my code. For a few years now I thought I had it all figured...
CSS SCSS Mobile UX UI/UX frontendOne of the perks being with Ritter, and on the dev team, is you can choose the hardware that makes you happy and productive! Team members...
macOS RIMdevAs a technical writer, I create software documentation. But many times, I find myself looking at in-product copy and wondering about cont...
Documentation Technical writing UX writing Content designDocs and contextual help We recently started a push towards integrating Docs content into our software platform. The goal is to pull in...
Documentation Hugo XML RSSHave you ever wanted to change the value of a Sass variable based on screen size, a state, or for any other reason that might require cha...
css SassEver been confused about naming a branch with Git? Looking for a good naming convention? Well, I might have an answer for you. I’m not sa...
GitHubWe often use GitHub to create a compare view, and list pull requests (PRs) for releases. However, GitHub limits the number of commits you...
Documentation GitHub GitUsing our Hugo-based documentation site, we typically publish release notes once per week. My usual process includes the following: M...
Documentation Hugo ArchetypesAs someone who basically gets by when it comes to writing Javascript, I tend to look at things from a “I bet I could do this with CSS” st...
CSS SCSS Mobile UX UI/UX frontendThis is an updated post of the original here. Whether you’re new to the frontend at RIMdev or looking for more about our Frontend team...
Team RIMdev FrontendIf you’ve ever worked in Azure Data Studio, you may find tab colors very useful. They allow you to visually separate different connectio...
Documentation Azure Data StudioIf you’re not familiar with Platform UI, it’s a utility rich CSS framework we created. As we look to migrate all of our apps and static ...
UI UX CSS SassGet ready to celebrate because, as of Friday, September 18, 2020, Evan You, creator of Vue.js, announced Vue 3 is officially released. He...
vue3 frontend developmentTypically with ASP.NET Core 3.1 when no specific authorization requirements are set all endpoints are publicly accessible. When you’re wo...
asp.net coreIf you have used slots in Vue, you know that it provides a clean way to vary content that is displayed in child components. For example, ...
VueJS Slots Scoped Slots JavaScriptWe’ve been using Swagger via Swashbuckle for some time with our ASP.NET Full Framework applications. As we’re moving toward ASP.NET Core ...
asp.net coreWe’ve spotted some strange behavior before with ASP.NET Core and JSON serialization/deserialization, and I eventually made it back to try...
asp.net coreC# being an Object Oriented Programming (OOP) language, we have access to inheritance. Like any feature of a programming language, you should use it appropriately and understand how to use it. In this post, I’ll show you some code that may be easy to get past a code review but cause some strange behavior. Ready?
using System;
public class Program
{
public static void Main()
{
Shape shape = new Square();
Console.WriteLine($"The shape is {shape.Name}");
}
public abstract class Shape
{
public string Name {get;set;} = @"¯\_(ツ)_/¯";
}
public class Square: Shape
{
public new string Name {get;set;} = "Square";
}
}
What would you expect the output to be? If you guess the following, then you are correct.
The shape is ¯\_(ツ)_/¯
Why did this happen? While we are using inheritance on our Square
class, we can’t actually override the Name
property. We attempted to “fix” the extensibility of our base class by using the new
keyword. The issue is that our new
keyword only works when accessing our Square
type. When our Square
type is cast to Shape
, the compiler will be accessing the Name
from our Shape
class. The polymorphic behavior we expected can’t and won’t happen.
What’s the fix? If you own the base class, you need to set the virtual
keyword on your base class.
public abstract class Shape
{
public virtual string Name {get;set;} = @"¯\_(ツ)_/¯";
}
On your inherited class, be sure to use the override
keyword.
public class Square: Shape
{
public override string Name {get;set;} = "Square";
}
Inheritance is an important pillar of OOP, but it is important to recognize what you can extend, and when you may be causing issues for yourself. The new
keyword has its place, but understand that polymorphic behavior can be broken and cause issues with unexpected outcomes and null reference exceptions. Seasoned developers may understand this, but developers just getting into .NET development will likely be bitten by this bug.