Unreal friendly naming

In this lesson we cover good naming and self documenting our code.

We also make sure to name our variables in Unreal’s preferred naming convention which is UpperCamelCase, also known as PascalCase.

Why does good naming matter? How does self documenting code help us?

I find that giving variables meaningful names makes it so much easier for me to understand my own code and also to know what each variable contains, particularly several weeks down the line when I’ve added more code and forgotten everything before it.

Also other people can follow your code more easily if you are seeking help on forums or if you are working in a team.

Same is to be said for commenting your code.

Personally, I overlook comments. Too many comments are bad in that if you change how something works then you have to change the comment as well and if you forget then it gets all sort of confusing and more time is lost over just having good names for everything.

Ideally, you want to quickly look at something without comments and know how it works. If you can’t do that then its too difficult or the naming is bad.

Of course, there are times where it makes sense to comment like for documentation of a Function others will be using such as with UE and may need to know how to obtain specific value(s) can be passed. Ie id… well what id because it could be anything? Since naming might not work there, documenting it does.

All questions can be anwered by : for readability reasons.

The more code it is added, the less it is readable, even if there is only one person working in the project. Thus, comments and naming conventions help us to work more efficiently.

Writing good names to our variables is used to know how that variable is going to be used, documenting our program serves to make as much as we as others understand our code and thus to know exactly what each part of the code does.

My TripleX game goes this way for now:

Here is my TripleX program

image

Good naming is just good practice, it reduces the amount we need to actively remember and allows us to read our code and file saving structure better.

Self-documenting allows us to remind ourselves and others about the reasoning behind parts of code e.g. what a certain bit of it is doing there.

Here is my terminal triplex-terminal

Good naming matters because it makes for better readability, and self documenting code helps us understand what our code does just by reading the code.

my current code

Mi console output below!

Good naming plays a similarly role to good commenting: it’ll help you not to get lost asking yourself what was that variable for. In the same way it helps other people who reads your code to understand better what you are doing.

Good naming conventions and self documenting your code helps by making the intentions of the code you write clear and consistent, both to yourself when you come back to pieces of code later, and to others that might work on a program that you’re coding for.

progress screenshot:

image

it’s been like four days since I was last here. Gonna try my best not to fall off the wagon and keep a good pace. I’ve been writing simple programs in a physical notebook just to make sure I don’t forget anything I’ve learned

1 Like

The Terminal.

My progress so far: 72%20(3)

Decided to add an screenshot of the code itself rather than just the terminal, cause why not!


Here is a quick screenshot showing how my program is coming together so far. As for the questions

Why does good naming matter?

Good names let us figure out what something is just by looking at it in code. This makes it far easier to understand what is happening, preventing mistakes.

How does self documenting code help us?

If the code is well self documented then other people, or ourselves in the future. Can figure out what code was meant to do, or what we were thinking when we wrote the code. Improving their understanding of how everything has been built and therefore make it much easier to be able to work on that code without introducing nasty bugs.

Good naming matter because it makes it so code is easier to read and isn’t ambiguous.
This also helps with not accidently assigning the wrong value to the wrong variable.

Self documenting code helps with readability and thus making it so you have to comment less about what a particular function or variable is doing in the program.

Good naming helps you or someone reading your code to know what the variables are used for or what values they are supposed to hold. Self documenting helps you to remember what your code does, say you start working on some code and you stop for whatever reason. Then you come back to it days or weeks later, you’ll know what you were doing or if you pass the code to someone else they’ll know what your code does.

Here is my TripleX code and output so far:

image
My TripleX coding.

This is my TripleX game

Good naming matters because it helps explain what’s going on in the code, even without comments. Self-documenting code keeps us from losing track of what’s what. It also helps if someone else needs to work on the same code.

I wanted periods at the end of my sentences, but the way I did it looks ugly – gotta be a better way. I’ll figure it out eventually.

1 Like

Privacy & Terms