Do I need to prefix function names that return a boolean with b?

Hello internet friends! I hope this answer is helpful.

Do you need to prefix a boolean with a b? No. However, it does seem to be a best practice for Unreal Engine.

What we’re talking about here is called Hungarian Notation. Generally, I would frown on using Hungarian notation. Refactoring your program latter can be challenging. What if you don’t want it to be a bool anymore? But that might be the precise reason it is a best practice for Unreal.

Unlike systems programming or other flavors, we create an API between the Editor and the compiled C++. It is very important for people to know that something is a bool in the editor. In fact, just like the Editor transforms CamelCase into Camel Case it also transforms bIsRunning into Is Running in the label presented to the Editor.

You don’t need to use b prefix. Unreal will work just fine. But, I encourage you to use Hungarian Notation and prefix those variables because that’s the convention of Unreal and you should adopt and follow the established conventions. If you don’t, people will be more confused when working with your great works because you do things unlike everyone else.

Respectfully,

Aaron Greenlee

1 Like