Skip to content

Coding Standards

Theo Ruefli edited this page May 21, 2026 · 41 revisions

Naming Conventions

No numbers in names except for image files!
Variable and function names should be descriptive of their purpose. NEVER USE abbreviations or acronyms.

  • It’s alright to use basic variable names (“k”, “num”, etc) when they’re being used to iterate through in a for loop.
  • Foreach loops referring to objects should still be descriptive of their purpose/nature.

Variables:

  • Name: camelCase
var exampleVariable

Constants:

  • Name: ALL_CAPS
const EXAMPLE_CONSTANT

Enums:

  • Name: PascalCase
  • Members: ALL_CAPS
enum ExampleEnum {
WALKING,
IDLE,
JUMPING
}

Functions:

  • Name: snake_case
  • Parameters: camelCase
func example_function_name():

Classes:

  • Name: PascalCase
class BaseEnemyClass

Files/Scenes/Scripts:

  • Name: PascalCase
res://LevelFolder
TutorialLevel.tscn
PlayerScript.gd

Commenting

Always include a single space between the start of a comment and the first word, additionally always capitalize the first letter!
When writing particularly complex code that might be hard to follow, provide adequate description.

Variables:

  • 1 Hashtag
  • Appears above declaration
  • Related variables/comments grouped together for clarity, groups separated by spacing
# My cool variables
var myVariable: int
var myOtherVariable: bool = true

# My monetary variables
var dollars: int
var cents: int

# My unrelated variable
const myUnrelatedVariable = 42

Functions:

  • 2 Hashtags
  • Appears above function
  • Summary of the functions
  • Descriptions of the fields
  • Return value
  • Comments in code blocks where necessary describing complex sections
  • Include any references/resources used
## Adds two numbers together
## x: First number 
## y: Second number 
## Returns the sum of both numbers
## https://stackoverflow.com/questions
func add_nums(x: int, y: int) -> int:
	# Adds both numbers together
	return x + y

Tags:

  • 1 Hashtag
  • Appears above related section
  • ALL CAPS no spaces
  • Use tags throughout code for actionable/notable items
# BUG: [Description of bug]
# TODO: [Description of work that still needs to be done]
# STRETCH: [Short description of stretch goal that would go here]

Styling

  • ALWAYS USE SEMICOLONS TO END LINES;
  • Maintain proper indentation
  • Utilize white-space to help divide distinctive sections of code into blocks for increased readability.

Principles

  • DRY (Don’t Repeat Yourself)
    • If the same process is being repeated in several areas, turn it into a helper function.
  • Strict typing (ALWAYS)
  • Keep functions on the shorter side, if possible break them up when they get too long (> 40 lines as a rough number)
  • Composition > Inheritance
  • Focus on modularity
  • Any function that encounters an error condition should return 0 for debugging.
  • NEVER use “$NodeName” to get a reference to a node.
  • ALMOST ALWAYS use @export to reference another node in a scene.
  • AVOID navigating the tree in code multiple times if not absolutely necessary.
  • NEVER optimize prematurely. BUT DON’T THROW CAUTION TO THE WIND.
  • Use scenes like prefabs wherever possible.

Clone this wiki locally