Avoid refactoring without tests!
Here is a flow chart that the author used to illustrate decisions about test, refactor or implement. You can tell from this diagram that refactoring is a small part of the decision process and it relies heavily on having testing in place.
Another major discussion in the first part of the book is on understanding functions as six basic components and the author provided some general advice for each of them:
- keep lines of code and complexity low in each function
- could be explicit, implicit or non-local, but prefer explicit over non-local
- avoid returning a null or undefined, or returning different types of values
- Side effects
- keep to a minimal or nonexistent
- this: the implicit input to functions
- have it well-defined when possible