C# Traps and Traps

Recently, on behalf of my employer, I spoke at the IT Academics Day, a small .NET conference organized by the West Pomeranian University of Technology. Together with Mateusz, we have presented some of the traps that a C# developer might encounter and how to recover from those. I would like to share three of ten such traps in today’s blog post, the rest will follow.

When inheritance is dangerous

The first one is a dangerous design trap, a bomb with a long fuse. Let’s take a look at the following code:

internal class BaseData
{
   protected string data = null;

   public BaseData(string data)
   {
       this.data = data;
       this.InitializeState();

       Console.WriteLine("BaseData created");
   }

   public virtual void InitializeState()
   {
       // Some basic initialization logic.
   }
}

Do you see anything dangerous yet?

Continue reading “C# Traps and Traps”

Scope – the inconspicuous project killer

There are many things that can go wrong while working on a project. And I mean not only technical difficulties, interpersonal relations, lack of time and experience, et cetera. They all can get in the way, but in my opinion, nothing breaks the spirit more effectively than a badly estimated scope.
Continue reading “Scope – the inconspicuous project killer”

Using validation attributes in .NET Core

There are a number of ways you can implement validation of your forms, models or uploads. One of the most common methods of doing that is using validation attributes. Not only are they very easy to use, they can also be customized freely according to your business’ requirements. Today we’ll take a closer look at how to use them based on a real-life example from our project.

Continue reading “Using validation attributes in .NET Core”