Unnecessary code executions in loops

I’m about half way through this section but I’m really missing one thing in the course so far.

I don’t know if its approached on in later lectures, but I notice that most of the times when you change over from one time execution to a loop, you leave a lot of code in the loop that should be placed just before the loop.

As a quick example that I just noticed, in lecture 38 around the 8 minute mark, you leave line 71:

int32 CurrentTry = BCGame.GetCurrentTry();

inside the loop. This means it gets executed every time the loop executes, but the CurrentTry doesn’t change and, as such, it should be just above the loop.

I know in a case like the BullCowGame it doesn’t matter too much if it gets executed multiple times, but its a good habit to form to only do things once if it doesn’t need to change.

I come from a web development background in which it is more important, but even in a normal application its a good idea to only execute it if its necessary.

Anyway, that is so far the only real issue I have with the course :slight_smile: Great lectures so far.
Despite being a reasonably seasoned programmer I’m still following the full course and I did pick up a few things (I didn’t know about using FString = std::string for example) so I’m glad to run through it :slight_smile:

Thanks for the great course!

Privacy & Terms