Coupling Code

I like the word ‘coupling‘ when talking about writing software, as opposed to what we don’t want: entangling. The way I think of it is that we want to attach code together in sequence, but avoid tangling up the code by attaching tendrils everywhere.

In a talk that I watched the other day, the speaker used images of train tracks to represent code, which made a lot of sense. We want data to come in, get processed, and get spit out the other end. We also sometimes want to redirect code, a lot like switches on train tracks.

The reason I bring this up is that I’ve been learning OpenGL again, and I’m in dire need of some good abstractions that couple my code together. While I’ve been following the tutorial, I frequently make changes in one place, while forgetting to change related code in another place. When I find good ways to prevent that mistake, making changes will be much safer and easier.

Avoiding too much abstraction is also important, because I don’t want to get into entanglement land. Once stuff gets braided together, it becomes a huge mess.

The goal is to think carefully about how each abstraction might affect the rest of the code.



Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life.