Accelerate Video Game Development
Featured Unity3D

Why clean code is important?

Leszek Król

Nowadays, developers are relatively easy to start creating their own games. They can easily find tons of tutorials on youtube, vimeo, blogs (like this one ;)) or in a books. However, programming is a tricky profession – it is easy to learn but hard to master. Coding is a very flexible job – you can create things on different ways. Some of them are easy at the beginning but often the easiest way can cause some troubles when your project become more complex.

For example, on youtube, authors of courses show the simplest way to solve some problem. In tiny issues like the topic of certain tutorial it is no a problem. Later programmer will remember some bad habits from simple tutorials and he is willing to reproduce it later during development the real projects. Today we are going to talk about clean code – set of rules that allow programmers to be more efficient in their work. In this part, I will show you a "fat and ugly" Main.cs class which I find in one of projects.

Super main class

Notice this is only 1800 from 2873 lines of this class code ;)

Why meaningful names are good?

Names are really important in programming. They are everywhere in software. We name variables, methods, arguments and classes. We continuously set names. Because we use it so much, we should do it well.

Use clear intention-revealing names

Good name of a variables, methods or classes should reveal our intentions – it should answer all of important questions. Good names should tell you why it exists, what it does and how to use it. If name of variable require extra comment – it isn’t good name.


Simple example from *Main.cs* class “How do not name variables”

The name hvdestroyCount did not give us a lot of informations. We better should name it something like that:

int horizontalAndVerticalActiveRoutinesInFirstDestroyCounter;
int horizontalAndVerticalActiveRoutinesAfterFirstDestroyCounter;

You can notice that those names are pretty long. But please not use it like an argument for use short and not clear names (like hvdestroyCounter). You have available an amazing tool called IntelliSense in Visual Studio so you can no longer complain about long (and readable!) names.

This post is for paying subscribers only

Sign up now and upgrade your account to read the post and get access to the full library of posts for paying subscribers only.

Sign up now Already have an account? Sign in
Your link has expired
Success! Check your email for magic link to sign-in.
Please enter at least 3 characters 0 Results for your search

May we suggest an author?

Leszek Król