34 points · by erdo · 5y ago · 66 comments
For this to work, the next day I need to be able to remember what I was in the middle of before I left.
What techniques do you use when coding, to make sure you can pick up from where you last left off (without spending half an hour trying to get back into the flow)?
Personally I write "here" in the IDE to break the compilation, so the IDE will bring me back to that place in the code when I next try and compile. Sometimes I also add a line or two describing the very next thing I want to do e.g. "finish this off and then maybe move it to the viewmodel" etc
Anyone else?
I always worked until I had something done and I always stopped when I knew what was going to happen next. That way I could be sure of going on the next day…These days I keep a worklog for each day that I can flip through, and mark various items as TODO in the log. That allows me to track state over more days, which is useful when there are half a dozen projects to track.
I find tmux much more effective for this than just arranging windows on my laptop, because ALL the tmux panes are work related, as opposed to windows on the desktop which get littered with email, websites, calendar, chats, etc. This is mentally hygienic for my productivity -- the terminal is where work happens similarly to how the bed is where sleep happens, so it is easy to get back into the flow based on the context.
I don't feel as productive and lose context a lot more when I had to load up an IDE each morning. If you have to use an IDE, I would recommend leaving it on overnight by hibernating the machine or similar, so you have all your code arranged, breakpoints set, navigation history/undo history etc. This helps me remember where I'm at when I start again in the morning. I'll even often leave the debugger at a breakpoint! I also recommend using the terminal within your IDE if it does not suck (I know it does suck in some IDEs). This allows you to keep all programming operations in one context similar to tmux.
I've known many people who finish the workday by clicking Shut Down on their workstation, and start the next workday with a fresh boot. That is so alien to me; I click Suspend, so each day everything is exactly how it needs to be to continue working, including terminal output, running processes, open windows and their state, etc. This saves me time, and jump-starts my brain by basically loading in the swapped-out mental context I was in yesterday instead of reinitializing the same mental state from scratch.
1. Don't get to that point. Don't back away from the keyboard when the clock strikes 5; move away from the keyboard when you're at a natural stopping point. If that point is 3:30, and you know that the next block of work you'd like to do is going to take you three hours, don't start it. Commit, push, and consider yourself done writing code for the day.
2. I keep a journal of what I do throughout the day. This probably is at a higher level than what you're looking for, but occasionally I'll post links to github with the file and line number where I left off.
3. Sometimes, I don't commit everything; hopping back on in the morning, a `git diff` shows me what I'm working on. This obviously doesn't work if you've changed a thousand lines, but that goes back to point 1 - have reasonable stopping points.
4. Break tests. If you know you need to finish something, write a test for it that doesn't work.
It should be added that just because you're "done" at 3:30, there's probably plenty to do. I spend the last bit of my day doing other things that are important such as checking email, responding to pings, writing documentation, updating tests, catching up with coworkers, etc.
When in the code and need to jump around different thoughts all in progress, I also tend to put "%%" and/or "%%$%" as a marker for "come back to this". (It helps that it doesn't compile, and works across platforms or different editors, so I don't have to change the habit over time.)
When something of higher priority comes up, I enter that at the top.
When things are done, I add "DONE" against those tasks.
Once in a while, I clean up all the "DONE" tasks.
It is a mangled mess, but it has helped me survive for one decade now.
Regarding implementation, I tried pen and paper/notebook, folders (hängeregister), git-repos for every project (even non coding projects) in gitlab with issues to keep track of todo's.
But for me, the best thing so far to implement GTD with a journal is a personal/private blog using a static site generator. Editing happens in Sublimetext, all under version control. I use Nikola because it's written in Python and easy to customize. I use a daily blog-post as inbox for all thoughts/notes/todo's during the day. And at the end of the day I write down what I did and what needs to be done tomorrow. And every project has it's own project-page with outline, milestones, journal, etc. From time to time, sometimes at the same day, sometimes at the end of the week I review and move content from the daily posts to their corresponding pages.
If the code is very simple to reason about at a high level, you won’t need to remember many details. If your dev environment is stateless such that simply “opening the project” (for me, cd-ing into the project directory in my terminal) will automatically set up everything you need to start iteratively developing, you won’t have to focus mental energy on project setup.
This leaves you free to really only worry about the exact thing you were doing.
I find it helps clarify/organize and speed up my coding process, and makes it easier to write code even when not in a "flow" state. And it's much easier to, say, write a suite of unit tests in one sitting than to write a working implementation.
I have a batch file called remember.bat, stored in my %PATH% so I can call it from anywhere (I usually use the start menu run box). It simply ECHOes the time, date, and any command line arguments to a text file. Like this:
(First post. Sorry if the formatting breaks.) (edit: yeah, formatting broke.)
time /t >> %userprofile%\documents\notes.txt
date /t >> %userprofile%\documents\notes.txt
echo %* >> %userprofile%\documents\notes.txt
echo. >> %userprofile%\documents\notes.txt
exit
I also have a log viewer application called CMTrace.exe (from Windows SCCM) in my startup folder, pointing at that notes.txt file.
So when I log in to my computer, CMTrace tails the notes file, highlighting a bunch of key words in different colors to make severity more obvious.
When I need to add something to the list, I just start\run, type "remember whatever I need to remember" (without quotes) and the file is appended with:
06:47 AM Thu 01/14/2021 whatever I need to remember
If you want to view it live, you can use anything that can tail a file instead of CMTrace if you don't have access to it. Otherwise it's available to refer to anytime with your text viewer of choice.
If I need to remove something from the notes, I can open it in Notepad++ or whatever and save it, but I find myself leaving everything there for future reference.
I realize the post starts with "When coding", but I imagine this could work there, and I know it works elsewhere, so I figured I'd share anyway.
My working memory is essentially non-existant, so this is necessary every day.
An old writer's trick: stop in the middle of a paragraph, or even a sentence. That way, there is something to do at the beginning of the next writing session, without having to think to hard about it.
https://www.loom.com is what I use.
It's a free, low friction service, just click a few buttons and you can record a screengrab with voiceover.
I separately keep a TODO file with the list of next major task items, and I break them down into subtasks if necessary.
This allowed me to do a side project in 15-minute chunks on my train ride to and from work for a year
The notes I write aren't that specific to code though. Like, I'm not gonna write "I was looking at x file at code line y" but I'll write "Finishing serializer up" and any other notes that might help.
But usually, especially if it's complex, I enjoy the clean state. If it's too difficult to pick up later, then I ask myself: did I really automatize the things that should be automatized e.g. with a script or makefile? Is my project/code navigatable?
To remember what I'm doing I either look at my last commit or my staged file changes. I'm surprised to learn people are resorting to comments / broken code, tbh.
After an hour of cleaning up loose ends, it can be nice to take stock and replan the day. While it can feel nice to finish a commit or model at the end of one day, it can actually lead the next morning to be unproductive.
When I get back to work the next day, I look at the output of `git diff @~` and I'm back in the flow of things within a minute or two.
If I'm in the middle of a larger task, add a failing unit test with a few thoughts about what I need to do next
If I've come to the end of a block of work, ensure that the top of my TODO list has an actionable, and quick item to start off with before I stop.
Another is not to keep going until you get to a neatly wrapped up stopping point. Leaving something partly done makes it fast to get back into the groove--just make it clear what's completed and remaining.
After opening a project back up I just press undo a few times to see what the last edits I made were.
- recall by what was open last
- recall by hitting undo a couple times
- stash with notes if I worry that won’t be enough context