Coding Best Practices

Principles for structured coding

Inner Loop Design Concepts

1. Function in Form

  • Thoughtfulness around the design of the following things will save you great pain:
    • Global variables
    • Variable, function, and folder names
    • Imagine having to describe every aspect of your project in a tree structure. Nothing should occur twice within the project.
  • If you find you’re using something in 2 or more locations, log it into a central location so that you don’t have to keep redefining it.

2. One Idea per File

  • Similar to this blog, every file (like a post) should contain a single codified idea.
    • In the past, I always found this practice difficult because the way that I wrote scripts before was so that everything was in one place. But after following a distributed approach to development (where I work with more than one person on a project) this is an absolute must.

3. Refactor Often

  • Build refactoring into the development process so that your design doesn’t get away from it’s intended form.
  • Another way of thinking about this is that as you work, the mental definition around how you can create your newest iteration needs to be refocused. Think expansion and contraction, with each cycle a rebirth of your project. Sometimes it will be close to what you originally came up with… and other times it will change drastically. This changelog of definition is just as important to be able to describe the value of what you are building as the code itself.

Outer Loop Concepts

4. The Outer Loop - Teaching Patterns to Yourself

  • Consider the behaviors that I am learning when removing errors. Linting is essential. If I do not learn to remove errors, then code editors will be filled with distractions that I won’t be able to remedy myself. I am training myself that the norm is to have errors in my code. If I ignore the recommendations of my machine, how can I effectively fix it when it truly has a problem?
Written on March 19, 2020