Naming conventions*

A convention is an unwritten “rule” not enforced by the language itself.

Conventions are a tool, an optimisation, that also has a cost. They are very helpfull, but they should be kept to a handful few. Everybody can have around 5 conventions in their mind, and these make the code clearer with less verbiage, but if the convention list grows above 10 for example, cost of keeping and remembering conventions becomes to great. Then it’s better to just be explicit. So we have them, but they should serriously be kept at bay.

  1. ’?’ at the end of the word means ‘get-’. Usually the word is a noun, a property, so instead of get-height get-length get-color we have height? length? color? functions
  2. ’!’ at the end of the word means that the function changes values in place. If the word is a noun, it’s usualy a property like account .balance! 120, but it can also be a verb for example account .deposit! 30
  3. functions that return boolean values start with ‘is-’. So we don’t have empty empty? but is-empty
  4. returning functions start with ‘^’. Returning functions are quite specific in behaviour, so we want to make them visible and obvious in code.
  5. Generic functions start with Upper case letter
  6. If kinds are defined inside a context, first word of a kind is the name of the context

Dillemas and reasoning

When is something in base library a generic function vs a normal function?

Generic functions work with “Kindered?” value types like Native and Uri. They both are unspecific and only their kind determines the behaviour and related functionality and hence related generic funtions.

Naming symmetries

  • Load <=> Save
  • Read <=> Write
  • Open <=> Close