Video 1: Joke Machine

Within this first episode, it covers how to install Visual Studio with the .NET framework, how to create a GUI, and how to write very basic code. This application is a small program that tells jokes.

Video 2: Clicker Game

This second episode covers creating a clicker game. This game gives the player a certain amount of time to click the two buttons as much as they can.

The third episode covers extending the previous game, from scratch, and creating a clone of the popular game Cookie Clicker.

Video 4: Constructs and Random Colours

Now that we have created some sample projects, we go more towards theory. We discuss the constructs of computer science and programming, sequence, selection and iteration, and program a random colour generator.

Video 5: Functions (and Timecode Apps)

This episode covers how to create functions, as we create a complex timecode application.

Video 6: Loops and Iteration

Iteration within C# can be implemented in a few differing ways.

for

for(int x = 0; x < 5; x++){
    //do something
}

foreach

int index = 0;

foreach(string element in (List or Array)){
    //do something
    index++;
}

while

int index = 0;

while(index < 5){
    //do something
    index++;
}

do …​ while

int index = 0;

do {
    //do something
    index++;
} while(index < 5)

Video 7: Errors & Breakpoints

This episode is more theoretical, and goes into the types of errors that can occur when programming. It also covers how the IDE handles different debugging features.

Syntax errors

A syntax error is an error that occurs since the syntax of the language is not respected. This is usually because one of the rules of the language is not respected in your code. This might mean that there is a forgotten semi-colon to end a line, or a bracket is in the wrong place or missing. This means C# cannot process that line correctly, causing the application to not be able to compile properly. Luckily, C# has a feature that shows any issues with syntax during the compile stage, in the error box.

Logic errors

Logic errors, on the other hand, are errors caused by the actual algorithm being incorrect. The wrong output would be given given, as the actual algorithm to get to that final result is wrong. For instance, a function could be labelled "multiply()", but the code inside could instead minus the values. This would be a logic error as the code and it’s syntax is correct, but the logic is wrong.

Semantic errors

These are usually due to incorrect usage of C# statements. For instance, if you were to reference a library not imported, this would be a semantic error. Another example would be referencing an array index that is out of bounds. This would also cover casting errors, so if you are trying to minus two numbers, but the data-type is a string. Finally, it could also cover variables that have not been initalized.

Compile time vs Runtime

Errors can occur at two different stages of the application: whilst the application is trying to compile, or whilst the application is running. The IDE usually catches any syntax errors, whilst compiling the software, and underlines them in a red swiggly line in Visual Studio. However, logic errors occur whilst the application is running, meaning the program will output the wrong value. Finally, semantic errors can occur both at runtime and at compile time.

Breakpoints & Stepping Through

Within Visual Studio, you can create breakpoints. These allow you to pause the application at a point, and look inside the variables that have been declared. This is nice if you are trying to debug a logic error.

Within this, you can also step through your code. The easiest way to do this, is to create a breakpoint at the start of the function to step through, and then run the application. Once it breaks, you can click the Step Into, Step Over and Step Out buttons in the toolbar.

  • Step Into allows you to execute the current line, and moves onto the next line. If that line is a method (function or procedure), it will enter that new method. Once that has completed, it returns back to where it was called.

  • Step Over allows you to execute the current line, but when the line has a method call, it doesn’t move inside it. This means you can focus on the single method you are debugging.

  • Step Out allows you to run the entire current function until it ends. This is useful if you accidently enter a method using Step Into, as it will skip back out of the current method.

Exception handling

When dealing with user inputs, inputs that can break a system (for instance, if the user inputs a string instead of an integer, causing a casting error) will cause a crash or error. As such, you can create exception handling code, to catch any errors before they crash the code.

As an example, you can use the following code to handle a casting issue:

try {
	//Code to try, such as a type cast
}
catch (Exception e){
	//Code to handle the exception
}

Return to home…​