Experiencing Flow While Coding

Yesterday, I experienced a flow state where I became manically obsessed with perfecting a script I was working on. I think it’s beautiful code, about 100 lines long without docstrings. It solves a real need and it felt great to write it. Some scripts feel terrible to write and you know they’re bad. However, this one felt like one of the best I’ve ever written.

Flow seems like a mythical, unattainable state these days as portrayed in media, but we can all agree… we love it. When you’re in flow, you know it and you feel a grace in improving your work. For coders, maybe it’s by wrapping up a few lines here and there into functions. Refactoring, reordering, handling loose ends or edge cases, writing docstrings with supporting documentation and clarifying that you really understand what’s happening… these things are all mundane at times but critical to writing reliable code.

While doing these typical tasks, you’re attaining skill and mastery, one of the highest dopamine hits humans can register legally in all 50 states. You know how much better this iteration of code is than when you first learned to write software. You take bits and pieces from past projects and fit them all together into a cohesive, purposeful program. For example, I was tickled to use Python’s readlines() file reading function to get the last line of a text file. I learned about this function in my first ever free Python course on Coursera, 7 years ago. Thanks again Dr. Chuck!

This time, I realized my flow when researching ISO 8601 time format strings and guiding them into an HTTP request with the requests library. A new solution emerged, regurgitated from a prior project and mashed up into a more refined form to satisfy the project’s requirements. I combined old and new ideas into a better solution than I had ever thought, a fitting complement for the API at hand. Time will tell if the solution will actually work as well as I hope.

Flow is real. You can find work that puts you in a flow state, and it doesn’t have to be super interesting work to get there. The learning process pays rewards in competency when exposure to different domains combine. Einstein knew a form of this as “combinatory play”. Repetition enhances this effect and solidifies your foundation. Flow makes it fun! Only rarely do I feel the highest level of engrossment in my work. I sensed I was flowing on this recent project. You can find these types of challenges too. Keep searching for your flow!