Skip to content

Coding Practice

How Far Behind Are Your Dependencies?

The world keeps turning and when you do not actively spend time to update the dependencies of your projects, you will fall behind. First one minor version, then another and before you know, there are a few new major versions released and your project is full of security risks.

We all know that his happens and even when we try to keep everything up to date, sooner or later we fall behind. We cannot give up, then that makes it even worse. There is only one way forward: Update your projects. But where should we start? And how bad is it now?

How to Use DbUp Without Embedded Scripts

I use DbUp for all my database migrations. It is super simple and when something goes wrong, you can fix it without much effort. So far, I never had any problems with the embedded scripts approach as it is explained in the Getting Started section of the official documentation and in my blog post.

However, while trying to get Docker working with DbUp I noticed that I must do a lot of extra work when I need to create a separate DbUp image for every migration project I use. It would be much simpler when I could reuse my DbUp project and only replace the SQL scripts. Unfortunately, the embedded scripts approach requires a rebuild of the project and I am back at the beginning.

How to Generate a Missing project.assets.json in Azure DevOps

We started a few weeks ago to target .Net Standard in our class libraries. While our applications remain for the foreseeable future on the .Net (Full) Framework, we like to start moving code towards .Net Core. Building our solutions in Visual Studio worked without any problems, but as soon as we try to do that in Azure DevOps, we run into this error:

C:\Program Files\dotnet\sdk\2.2.105\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets(208,5): Error NETSDK1004: Assets file 'c:\agent\_work\95\s\***\obj\project.assets.json' not found. Run a NuGet package restore to generate this file.

Working with Temporary Files in .Net

Working with files in .Net is straightforward. You can use the File or FileInfo classes and call the method with the self-explaining name to create, copy, move or delete files on your system.

However, sometimes all you care about is to write some temporary data to a file. In this case the Path.GetTempFileName() method is exactly what you need. This method creates a uniquely named, zero-byte file in the user's temporary folder and returns the full path of that file.

Partial Interfaces in C# - They Exist and There Is a Use Case for Them

Partial classes are a great way to keep (automatically) generated code away from manually written one. All you need to do is to use the partial keyword in front of your class definition and the compiler will combine those partial classes to one single class.

At work, we currently try to figure out a way that would offer us the same flexibility but for interfaces. We have generated classes and can generate an interface for their methods, but we want to be able to extend the functionality with partial classes for the more complex cases. How can we get those methods in the (manually written) partial class in the same interface, without risking those changes to be overwritten with the next run of the generator?

The Most Undervalued Refactoring: Slide Statements

When we refactor our code, we want to make it better. Not just a tiny bit better, a lot better. Therefore, we look at refactorings that change our code in big steps, like extract method or extract class. However, tiny little risk-free steps can bring us to insights that we miss otherwise. Sliding lines of code around is such a tiny little step and often overlooked. What could possibly be gained if a single line of code is moved to another place in the same method? As it turns out, a lot!

3 Great Resources to Start with Docker (& .Net)

Popular technologies come with an enormous amount of "promotional" material. Docker is no exception to this rule: you find an endless stream of things to read, to watch and to listen to about Docker and containers. With only a limited amount of time at your hand, where should you spend it?

A few weeks ago, I was facing the same problem. I found many things that were not so useful, and I spent far too much time on them. However, at the same time I found the 3 resources I like to share with you today. I hope they can be of great use for you too. I am still new to the topic and appreciate if you post your favourite books, videos and tutorials as a comment to this post.

What Exactly Do You Mean with 10x Developers?

Over the last few days there was a big discussion on Twitter about 10x developers. Shekhar Kirani claimed many things about what 10x developers do and how one shout accept their oddities because they are so much better than the other developers and that they single-handedly will solve all problems. If you did not already have read any of those ideas, you can find them here:

Tweet: 10x engineers 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. OK, here is a tough question. How do you spot a 10x engineer? — Shekhar Kirani (@skirani)

Use Visualising Git to Understand What Is Going on with Your Git Commands

Git is a powerful version control system for which you only need a few commands to get your daily tasks done. However, Git can do a lot more - but those commands are hard to remember and when you use them wrong, you may mess up your repository.

You can find many great resources to learn Git on try.GitHub.com. One of the more impressive ones is Visualizing Git. This browser-based "Git" visualises the effect your commands have on your repository. You can commit and branch as you like, while this tool updates the graphical representation of your actions. I find this a great help to understand the more advanced commands of Git.