How to properly comment methods in Unreal Engine

Feb, 19 2021— #basic

Code commenting is a very important programming task not only for the customer, but also for the developer himself. It often happens that after a few months, when a developer turns to his code, he cannot understand the meaning of certain methods that he himself once wrote, and it becomes very difficult to delve into this code. In order not to waste time on this, you should always comment on your code, no matter how simple the task seems.

If we comment on the method, then it should look like the following pattern:

/**
  * Small method description
  * @param ParamName1 Description of the first parameter
  * @param ParamName2 Description of the second parameter
  * @return Return value description
  */
FString FunctionSample(bool ParamName1, bool ParamName2);

Complete list of all styles: @param, @return@warning, @note, @see, and @deprecated

For example, let's say we have the following method:

bool IsNetworkAvailable(int32 PlatformID);

So there should be a method after commenting:

/**
  * Determine if the network is available for a specific platform.
  * @param PlatformID - Platform number for which to determine network status
  * @return Whether the network is available or not
  * @warning The function is not reliable and does not always return the correct value 
  */
bool IsNetworkAvailable(int32 PlatformID);

That's it.

More detailed documentation on coding standards, including code commenting

By Georgy Treshchev

Unreal Engine Developer. Contact for any questions. Telegram chat, e-mail, Github.