Well, I have some problems with procrastination and whatnot, but those get infinitely worse, when I cannot remember what I should be doing.I mean, I know my project, I wrote 100% of the code so far, and I knew more or less what I was doing, but I don't remember exactly what, I don't remember what file I was editing and why.How I get back on track? (because right now my technique of opening the source code and staring at it is not working)
How you return to a code when you don't remember what you were doing?
programming practices
I assume you are not using an issue tracker for your project. Else it would be trivial to trace your previous steps.Finding the latest changesFinding the file you were working on before procrastinating should not be much of a problem. If you are using a source code management (SCM) tool like Git, reading the history should help. If you aren't using any SCM or version control system (VCS), you can still sort your files by modification date (here's how to do this in a UNIX shell).Remembering your intentionsThe difficult part is to remember why you were doing something. If the code is so hard to read that its intent is unclear, I perform static code analysis. I do this the same way I would do it to understand code that was written by someone else. While trying to follow the program flow, I draw UML diagrams (mostly class and activity diagrams, in really bad cases also sequence diagrams). This does not only help with getting to understand the code but also serves as a future documentation.Avoiding the problem in the futureFirst of all, if your main problem is that you cannot remember you previous intents because the code is so difficult to comprehend, this is the time for refactoring. It will save you a lot of trouble in the future. If, however, the problem is that you have multiple unfinished code structures and you cannot remember what to finish first, you might want to try one or more of the following:SCM: If you're not using SCM/VCS, start doing it. In case of tracking your previous steps, SCM helps you if you keep a clean history (remember the principle: commit early, commit often). It also prevents you from irrevocably deleting files (e.g., with UNIX' rm).Issue tracker: If all this still does not help you avoiding your problems, start using an issue tracker. There are countless free and light-weight tools available to help you keep track of your changes.Unit testing: Another method that can help you to quickly find the place to continue your work is to create unit tests. There are frameworks for all the widely used languages (e.g., Java, C, Objective-C, ...) and some languages even have a such a framework in their standard libraries (e.g., Python). If you think that unit testing might help you, also take a look at test driven development (TDD). For many developers it seems really weird not to start programming right away but to write tests for something that isn't there. However, it can lead to a whole new perspective of software development. If all of these suggestions seem to be too much of an overhead, you could just write TODO comments in your code. This is not the cleanest and safest solution but the easiest and fastest.