01. Common Naming Patterns

Naming is crucial for readable and maintainable code. Try to be consistent in the naming style throughout your code.

1.1 Do

  • IsX: Often used for naming logic variables to ask a question (for example, IsEmpty).

  • OnX: An overloadable function called by the framework.

  • SubscribeX: Subscribe to framework event named X, often passing an OnX function to it.

  • MakeC: Make an instance of class c without overloading the c constructor.

  • CreateC: Create an instance of class c, beginning its logical lifetime.

  • DestroyC: End the logic lifetime.

  • C:c: If you’re working with a single instance of class c, it’s fine to call it C.


1.2 Don’t

  • Decorate type names. Just call it thing, not thing_type or thing_class.

  • Decorate enumeration values. Not color := enum{COLOR_Red, COLOR_Green}, use color := enum{Red, Green}.

Was this helpful?