I like software development. In my job I work as a software architect, but in my spare time I also do some programming. Most of the time I’m on the road with C# and .NET. My current spare time project is Woopec, an easy to learn graphics library for C#.
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?
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#
newkeyword. 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.
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.
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.
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…
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 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.
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.
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.
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.
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.
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.
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.
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).
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.
The task: I have two processes. Process
Acreates graphical objects, process
Bdisplays these objects on the screen. To do this, the objects must be transferred from
B. The tools for this are quickly found: The objects can be serialized to a string with
Aand deserialized in process
B. Anonymous pipes can be used to transfer the strings from
B. The difficulties lie in the details…
As of today, the first version of the Woopec library is available on NuGet.
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