Blog
Sometimes I worry about software development or I look for solutions to C# problems. If I come up with anything useful, I’ll post it here.
Blog Archive
Latest Posts
A Beginner's Guide to downloading Code from GitHub (h4-11)
A lot of source code is freely available on GitHub. Here I briefly explain how you can download code from GitHub to your own computer. If you want to write your own blog, you can also use GitHub. I also explain the first steps for this.
Clean Code with YAGNI, KISS, SRP, SoC and IOSP, an Example (h4-10)
From the very beginning, you can write code that is easy to understand and easy to extent. Even beginners can try to follow some principles right from the start: You aren’t gonna need it (YAGNI), keep it simple, stupid (KISS), separation of concerns (SoC), single responsibility (SRP) and integration operation segregation (IOSP).
Introduction to C# Methods, and a Rule for it: Do not change the Values of their Parameters (h4-09)
Programs can quickly become complicated. The first remedy for complexity is to divide the program into methods. To get started, you just need to know how to define methods and how to deal with parameters and return values. One rule also helps here: Do not change the values of method parameters. C# records help you to follow this rule.
Why are the Winter Solstice, Christmas and New Year not on the same Day?
Winter solstice, Christmas, New Year. All close together, but not on the same day. What’s more, Christmas is celebrated on different days in different parts of the world. Why is it all like this?
Create new Instances of a C# Class and store them in a List (h4-08)
We want to use several objects in our C# program. For example, we want to draw many rhombuses on the screen. For this we need the C#
new
keyword. If we keep these objects in a C# list, we can do other things with them later. For example, give each rhombus in our list a different color.First think about a Concept, then take the next Coding Step (h4-07)
Software development has a lot to do with finding good solutions. Sometimes this is easy, but often it is complicated. In these cases it makes absolutely no sense to start programming immediately. If you do that, it will take you much too long to find a good solution. It is much better to design a good concept first and then start programming.
One Third for Conceptual Work
The search for a good concept is and remains important. Agile approaches do not change this. The article “A plea: 1/3 for conceptual work” describes an approach that in my view fits well with the Agile Manifesto.
Clean Code C# Coding Kata - Conway's Game of Life
Conway’s Game of Life is a very simple game. I’m sure I can implement it in an hour with C#. At least that’s what I thought at first. But the implementation is supposed to be clean code, and I also wanted to have a graphical display. That’s not so easy after all…
0 is not equal to null. Definition and Use of the appropriate C# Types (h4-06)
C# provides many data types. For example double, int and string. A string variable can have the value null. This null value has a few pitfalls to be aware of. Value types like int and double cannot be null, but you can define nullable value types. This post explains that in more detail with simple examples. At the end it will be explained how to use if and else statements to execute different parts of the program.
It is never to early to write Clean Code (h4-05)
It is not enough for your code to do what it is supposed to do. You should strive to write clean code from the start. Even as a beginner, you can use code conventions and follow the DRY principle. This will help you write code that is easier to understand and extend. In this post, we use C# variables and loops to improve code that draws a hexagon.
C# Debugging for Beginners (h4-04)
Great, you’ve managed to write your first C# program. Unfortunately, the program doesn’t do what it’s supposed to. The best thing you can do then: Learn how the C# debugger works and use it as often as you can. I’ll show you the most important things a beginner needs to know about the Visual Studio Debugger.
Why is this simple C# Program not working? Fixing Compiler Errors (h4-04)
You have written your first C# program and it compiles with errors? This is quite normal in the beginning. Don’t let that stop you from learning C#. Here I explain some of the most common errors and how to fix them.
Draw a filled hexagon using simple C# commands (h4-03)
The previous post showed how to write your first C# program. Now we will extend the program to draw a filled hexagon. We use the Woopec library to do this. Visual Studio IntelliSense helps us understand the available commands.
How to easily write your first C# program with graphics (h4-02)
I’ll start from the beginning and explain what you need to install on your computer and how to write your first C# program. We start here with turtle graphics, because it makes it easier to get started with programming. For programming we use Visual Studio. With the debugger of Visual Studio we can start the program and understand what it does.
Learn C# step by step, the HexaFour Game (h4-01)
Is it easy to learn C#? Sure, as a beginner you can quickly learn to write a few small console programs. But what’s the next step? You need something more difficult, but it shouldn’t be too difficult either. This is the beginning of a series that uses a graphical game to show how to program C#.
Developing Software is just as easy as Building Airplanes (h4-00)
Is it easy to build an airplane? Of course it is: I can learn to make paper airplanes very quickly. But what’s the next step if I want to build a real airplane one day? For example, I can build a radio-controlled airplane. Is it easy to develop software? Sure: I can quickly learn to write a few small console programs. But what’s the next step? I have an idea…
Cache data in memory and update it regularly via a background service (.NET Core MinimalAPI example)
Suppose we have a backend that takes a long time to collect and return the necessary data. Then it would make sense for the backend to cache the data so that it doesn’t always have to recalculate it. There are mature solutions for this (see for example Caching in .NET), but I have made my own small example here anyway, for the following reasons: I want the data to be generated in the background and the business code should be as decoupled as possible from the rest. Secondly an immediate update of the data should be possible. And last but not least I wanted to implement my own small minimal API example.
Serialization and deserialization of polymorphic objects with System.Text.Json and .NET 7
Six months ago, I described how to serialize and deserialize polymorphic objects using System.Text.Json in .NET 6. This was a bit complicated in .NET 6. In .NET 7 it has improved significantly and is now quite simple.
Drawing spirograph curves (also called hypotrochoids) with C# turtle graphics
A while back I owned a Spirograph Set that could be used to draw figures like the example above. Mathematicians also call such curves Hypotrochoids. In last post we drew polygons and stars with turtle graphics, now we draw spirograph curves. We use some more advanced Woopec features (transparent filling, individual shapes and synchronized turtles).
Drawing polygons and stars with C# turtle graphics (and GCD calculation)
Suppose you have a fixed number of vertices. How can you connect them to a regular polygon or a star? Here we need some math: prime factorization and GCD (Greatest Common Divisor). And with Woopec C# Turtle Graphics we can then calculate and draw that.
IPC with polymorphic objects and System.Text.Json Serialization
The task: I have two processes. Process
A
creates graphical objects, processB
displays these objects on the screen. To do this, the objects must be transferred fromA
toB
. The tools for this are quickly found: The objects can be serialized to a string withSystem.Text.Json
in processA
and deserialized in processB
. Anonymous pipes can be used to transfer the strings fromA
toB
. The difficulties lie in the details…Woopec release 1.0.0
As of today, the first version of the Woopec library is available on NuGet.
Turtle graphics for C#?
C # is a great programming language with endless possibilities.
There are great introductory pages for C# beginners - for example Learn to code C#. But getting started with graphics programming is not easy.
subscribe via RSS