Icon with a green woodpecker. Next to it a quote from Ada Lovelace: "The Analytical Engine has no pretensions whatever to originate anything. It can do whatever we know how to order it to perform"

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#.

Blog

  • Clean Code with YAGNI, KISS, SRP, SoC and IOSP, an Example (h4-10)

    Tiles painted with colors from Woopec example. Copyright by Frank Kruse

    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)

    A wooden board painted with colors from Woopec example. Copyright by Frank Kruse

    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?

    Graphic showing the days on which the winter solstice, Western European Christmas, Eastern European Christmas and New Year fall today

    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)

    A game board with 5 rows containing several rhombuses. Each rhombus has a different color.

    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)

    A game board with blue hexagons on top.

    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

    Pie chart. One third for conceptual work. Two thirds for all other 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

    Screenshot of the GameOfLife program showing the 46th iteration of the "Gosper glider gun" seed configuration.

    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)

    An input window for numerical input. Values between 0 and 7 are allowed. The mouse arrow is on the Cancel button.

    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)

    An image created with the Pen class of the Woopec library. On the left, a hexagonal figure drawn with green lines. On the right, a pentagonal figure drawn with blue lines.

    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)

    In the left half a Visual Studio debugger with a C# Turtle program, in the right half the Main Window with the drawn Turtle graphic.

    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)

    Image with Visual Studio compiler errors: CS1002 ; expected. CS1003 , expected. CS1022 Type or namespace definition, or end-of-file expected. CS7036 There is no argument given that corresponds to the required parameter. And more.

    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 to fly with C# (h4-01)

    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

    Woopec: Drawing Spirograph Hypotrochoids with C# turtle (Link to Animation)

    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)

    Woopec: Drawing stars with C# turtle graphics (Link to Animation)

    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, process B displays these objects on the screen. To do this, the objects must be transferred from A to B. The tools for this are quickly found: The objects can be serialized to a string with System.Text.Json in process A and deserialized in process B. Anonymous pipes can be used to transfer the strings from A to B. 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