I don't program in my job, so coding in free time has been a wonderful creative outlet. These past few weeks, however, have been a slog to open the IDE; often distracting myself instead with watching edu material on writing better unit tests, binge reading HN, etc.
One new habit which has somewhat worked was inspired by Neil Gaiman's writing process (ie. sitting in a quiet place where the only two choices are to write or do nothing until boredom inspires writing) - I've started sitting at home, without music and with a notebook, where the only two choices are to do nothing or write pseudo code for the immediate next exciting feature.
As you may have guessed, at this moment this new process isn't quite working; curious to hear from anyone who enjoys coding at home / in free time: what does your lifestyle around those programming hours look like? Thanks!
There is no inherent pleasure in the process itself.
In solving puzzles - yes, in overcoming obstacles - sure, in seeing final product working and not failing - of course.
But coding itself is a boring but inevitable process of reaching some goal(s).
Thus the only reliable and long lasting source of motivation is a specific idea (product) in mind you want to create (no matter how small or simple).
This what can drive you no matter whats snacks or laptop or wifi you have. Without any rituals.
But pushing yourself to code without a good goal is a waste of time.
This is akin to playing a game in a half-assed way, and before you know it, you take off your jacket to really play. If you were told to come with the proper attire, you probably would have declined or postponed or procrastinated, hence removing friction works.
I recently have tried putting on sounds. Nature sounds. There are tracks that go for more than 8 hours. These cover "Dirac impulse" like sounds in my physical location, which can burst my bubble. I'm fine with noise in a bus (I've coded entire projects while commuting).
One 'hack' to improve productivity is to work disconnected from the internet and with an unplugged charger. I had a laptop that could only hold about two hours, and boy that was greatly motivating to code something up before the laptop shut down. Even with my crurrent laptop, there just is something about working with 'finite energy'. Removing frictions and adding restrictions seems to work.
My key to staying interested is automation of all the things. I mean spending the extra time to finding new ways to perform test automation, automation to keep documentation up to date, adding new lint rules. With better automation in place there are fewer barriers to validating or executing new ideas.
For many years I have had this humorous fantasy of having a bare room with little but natural rock walls and irregular rock paving flooring, a fireplace, and a ceiling consisting mostly of a huge sky light. with only a little desk for furniture as a place to work with no distraction. My contractor is now designing that room to put on the top of my house.
I can't recommend it because I have no idea if it will be the happy place I have always imagined, lol! But I think it will. :)
What I can say is imagining that kind of peaceful natural hermit-able place was one of my visualizations that helped me get into the zone many times in the past.
What code we would write if we all lived in lighthouses?
Set a small goal and only when it's finished start working on something else, make a kanban board with small tasks. Don't think too far ahead with "oh, I'd like to add x in the future, so I should architect y so that's possible". Don't endlessly review and refine the code you've already written trying to achieve perfection.
By all means capture these next features in a notebook, but act like you're working on a 'real' project and have an actual deadline. It might also help to make commitments to show other people what you've done, I always work best when I have an audience otherwise I quickly fall into the trap of trying to make the perfect system because I know there's no hard-limit on my time. YMMV obviously.
I don't do open source contribution a lot so it's mostly my own stuff.
( the number of "F" varies over time, but tend to reduce... )
[1]https://medium.com/1-one-infinity/discipline-beats-motivatio...
If that doesn't work it is pretty likely you have ADHD.