Names are important.
27 Apr 2021Names are important.
I like to write readable code. As much as possible, the code alone should be easy to read. Comments used sparingly as comments can lead to unnecessary confusion if they are not properly maintained.
If we don’t convey meaning and context through comments - then the code must do this alone.
Therefore, names are important. Variable and function names need to accurately describe what they contain or perform in order to self-document the process.
Comments of course have their place - complex ideas and procedures need explanation. They shouldn’t pepper code too liberally but can’t be absent either.
All this is to take the long way round of excusing an excessive refactor.
I named the “node” in my tree data structure Transform
instead of Node
as
this is they way I saw it done elsewhere (in Unity). This name is misleading -
for my use anyway. In Unity it is used to manage the position through
translations and rotations relative to a root - these transformation operations
give the object the name. In my uses, the object still handles positioning
relative to a parent but, importantly, is used to manage attachment of a thing
to a scene. If a transform is a child of a scene, it is included in the
rendering process, as well as the physics simulation. So it seems like my
“Transform” isn’t really about transforming. It is really just a way of joining
together data points in an overall structure - a ‘Node’.
Time to go re-name a whole bunch of objects across my codebase…
Questions? Comments? Get in touch on Twitter!