When programming in Desmos, I use a set of naming conventions for identifiers. This helps massively when managing increasingly large projects with many identifiers to keep track of.
It’s by no means a perfect convention, but I’ve found it to be quite intuitive and efficient. I document it in depth here for anyone who wishes to use it.1
Overview
Identifiers take the form , where is the base. This is hugely preferable to single-letter naming, which quickly drains available variable names and results in clashes.
Global variables use an uppercase base, while functions, actions and their parameters use a lowercase base.
The subscript is all in lowercase. Short subscripts are preferable to reduce clutter, but increasing length may become necessary to avoid naming collisions.
Words are not separated with any separator due to Desmos limitations. This clearly has issues, but it’s preferable to camelCase
and still holds up fine with some extra effort in naming appropriately.
Variables
letter | semantics | description | notes | instance |
---|---|---|---|---|
colour | Stores an RGB colour. | |||
global | A global variable, whether dynamic or static. | |||
tick | A tick variable for timing events. | |||
world | A globally accessible store of game data, often objects. | |||
render | The output of a rendering function. |
Functions / Actions
letter | semantics | description | notes | instance |
---|---|---|---|---|
action | A general action. | Specifically those intended to be manually triggered. | ||
control / core | A core action for running the game. | |||
draw | A function for rendering polygons to the viewport. | |||
function | A pure function2 that performs computations instead of modifying state. | Intended for commonly used utility functions. | ||
new | An action for creating new objects (internally). | |||
move | An action for moving something forward in time – either literally or by processing its frame updates. | for velocity in physics, literally changing position. | ||
handle | Abstraction upon , usually for branching between different depending on conditional. |
Parameters
letter | semantics | description | notes | instance |
---|---|---|---|---|
index | A number that can be used to index a list. | |||
list | A list of objects. | The type of the objects can be described in the subscript, like for a list of points. | ||
number | An integer. | |||
point | An pair of values. | Must be a point, cannot be a list (will be accessed via or ). | ||
parameter | A generic parameter. | |||
time | Progression along a spectrum. |