Coding guidelines for an easier life

submited by
Style Pass
2021-06-16 12:30:08

If you write software for long enough you begin to develop instincts about the relative difficulty of different problems and some of those solidify into rules of thumb. The following are some of the guidelines that direct my work on a daily basis.

Many problems are graph problems of one sort or another. Resolving dependencies in a package manager, traversing a file system, exploring friend connections in a social network, all of those are examples of graph problems. There's a hierarchy of increasing complexity of graph types:

All of those are technically graphs, but the amount of work you need to do to operate on them gets noticeably harder as you work your way down the list. If you can constrain your requirements to allow you to use structures nearer the top of that list you will have fewer implementation bugs.

Sometimes you can't avoid a cyclic graph, but by remembering that it's harder than the others you should stop and think "do I need more tests for this?"

Leave a Comment