Skip to content

Instantly share code, notes, and snippets.

@johnmcfarlane
Last active July 21, 2025 08:47
Show Gist options
  • Save johnmcfarlane/fb365c6b81a23195897d7cf461d336ce to your computer and use it in GitHub Desktop.
Save johnmcfarlane/fb365c6b81a23195897d7cf461d336ce to your computer and use it in GitHub Desktop.
Essential

Essential Principles

Commonly occuring good advice aimed at improving maintainability.

Brevity

  • Avoid duplication, tautology, repetition, duplication, and saying the same thing over and over in different ways.
  • Everything (words, statements, comments) should have a clear purpose.

Resources

Complexity

  • Avoid complexity.
  • Encourage simplicity.

Resources

Coupling and Cohesion

Examples

  • Functions
  • Classes
  • Source files / modules
  • Packages / projects
  • Teams

Build Systems vs Toolchain Configuration

Many well-meaning projects store toolchain configuration in their build system description. Here's an example of a C++ project combining the concerns of configuring a specific compiler, with describing build targets. This is very common because CMake makes it easy to do. In reality, a CMakeLists.txt file should never contain a compiler flag because this couples the description of what targets to make (a build system concern) with what flags to pass when building (a toolchain concern). The result is a brittle configuration which breaks immediately when a novel toolchain is used.

Cyclic Dependencies

  • Avoid cycles in your graphs.

Examples

  • Recursion
  • CI pipelines which are triggered by pushes, and also cause pushes (see GitLab guidelines).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment