My Introduction To CSharp Or How I Had To Build A GUI Game As My 'Hello World'

A brief rant on how I was forced into the realm of software development in a week.

My Introduction To CSharp Or How I Had To Build A GUI Game As My 'Hello World'

Introduction

In semester 1 2019, I had to complete my first programming assignment. To create, in any language of choice the game MasterMind. MasterMind is a simplistic yet popular code-breaking game traditionally played by two players.

In this game, the game is played using three main components; a decoding board, code pens consisting of 6 colors, and additionally several variants of key pegs.

  • A decoding board, with a shield at one end covering a row of four large holes, and twelve (or ten, or eight, or six) additional rows containing four large holes next to a set of four small holes;
  • Code pegs of six different colors (or more; see Variations below), with round heads, which will be placed in the large holes on the board; and
  • Key pegs, some colored black, some white, which are flat-headed and smaller than the code pegs; will be placed in the small holes on the board.

In this game, the two players take up two separate roles. One player becomes the code-maker, the other the codebreaker. The code-maker develops a code consisting of four distinctively different colored pegs, duplicates permittable and the codebreaker attempts to determine it. Whilst the code breaker has a limited amount of turns usually 8-10, per turn he is given several hints and clues determined from the key pegs, not pertaining to order, with white indicating a correct color code in the wrong position and black being incorrect.

Whilst for most developers this "assessment task" may seem trivial. At the time of development, I was new to programming as a whole, just being taught for & while loops and conditional logic just weeks before in an antiquated niche language with poor documentation, little community support, and constant bugs & crashes SmallBasic. As a result, after consistently struggling to do even the most basic things such as reversing a string, taking hours in this language, and then being told to create a video game. This felt like a near-impossible task, as such I knew something different had to be done.

C# & The Discovery Programming Can Be Fun

Now whilst any developer worth their salt can say "Languages don't matter, if you're competent you should be able to make an application in any language without needing to pick a new one up" at the time, and even now, I felt jumping languages was a necessity. Whilst being thrown into the deep end of programming from reversing strings to building a game in a week may seem like a somewhat extreme jump. Having a week to transfer programming languages from a more or less procedural language to one which heavily emphasizes object-oriented programming and has the ability to use functions with polymorphic overloading, conditional overloading, interfaces, inheritance, generics, threading and so much more and to top all that develop a game in that within a week, is even more so. Giving this to a complete beginner is I feel one of the worst ways to teach a beginner how to program.

But as it was necessary and had to be done, it was done. And as a result over the past week, I spent every spare waking hour developing, and refining my application. Whilst I made a few mistakes here and there, and skimmed over a bit too much tutorial wise which lead to issues later on, at the end of the day it was done and so with it my first real program and "game" if you could even call it one.

My End Result, MasterMind Built Within A Week Of Learning C# Alone Using WinForms

Whilst I made numerous amount of mistakes and skimmed over sections I shouldn't have, at the end of the day I was able to finish a "working" game at the end of the week, though in hindsight there are several things I would've done differently.

1. First and foremost, instead of wasting hours studying and watching tutorials teaching the introductions of C# from start to end with varying degrees of teaching on YouTube, I'd instead start out directly with the Yellow Book and branch out from there. The Yellow Book is a FREE & open-source book that details the C# programming language in intense detail whilst keeping the information engaging and understandable from beginner to expert levels.

2. Instead of building this application in WinForm I'd jump to WPF. During my research, there were conflicting opinions on which framework was superior, WPF or WinForm. Whilst WinForm is the older of the two, and thus has better pre-existing documentation for development. WinForm is antiquated and struggles with higher resolution screens and newer versions of windows, as it slowly moves to be unsupported and deprecated. WPF on the other hand excels with modern software developer practices emphasizing design patterns, specifically MVVM & as a whole acts as a way better graphical framework for software development than WinForms.

3. Learn C# sooner. Whilst I didn't learn much from my high-school teacher and after this semester, I more or less understood and appreciated the role of self-directed studies, the time lost learning SmallBasic was time I could've spent learning C# more thoroughly without being pressured into rushing it. Whilst I do understand his point of it is introductory, the language stripped out so many fundamental programming concepts that it counter-intuitively made it a pain to let students learn and create things. This flawed fundamental logic is similar to telling a student to "Learn assembly, as it's simple and basic, having a limited set of instructions allowing you to pick it up quickly and easier.". Whilst this is true to an extent, anyone who's actually used assembly in practice will detest saying that it's hard and doing anything practical in it, and god-forbid making a graphical game would be incredibly time-intensive and a technical feat of prowess that surpasses any difficulty pertained from learning an object-oriented programming language.

As a whole, whilst this experience was an incredibly painful and stressful one, during situations like this, whether we like it or not we achieve our best and make the seemingly impossible possible. Whilst I'd like to not do this again and I wish I was taught a bit more thoroughly by my high-school teachers instead of being thrown into the dark and then independently learning myself beyond that, I do, however, appreciate the skills I've learned from that. As a result of this challenge and many others ahead of this, I've learned to become self-driving in my journey of learning languages and technologies and have for the most part become language agnostic, being able to jump between languages seamlessly without hours upon hours of tutorials and reading documentation. Whilst I wish I was taught better, and funnily enough, I ended up teaching myself more than my teacher, it was definitely an insightful experience and has to some degree, impacted and shaped aspects of me as a software developer that I'll carry within me for my foreseeable career.

To view the source code of this project or to use it yourself, it is available on GitHub here:

ShaanCoding/MasterMind-Application
MasterMind Game Application Coded In C# As My First Project - ShaanCoding/MasterMind-Application