Some friends and I recently started a medium-size project. We already covered the design part (at least the first attempt) and now we are moving into coding. We already have implemented some objects of the design, just to test if everything is going as expected (we are beginners, so we do not really trust our programming skills).
The project is growing really fast but I do not really know when to start documenting the code. If I do it too soon the code will probably change, and so the documentation.
Is there any "golden rule" for when to start documenting the code? Is there any time which is optimal to start? or it just does not matter?
Thanks!
EDIT: I changed "commenting" to "documenting" because I realized it is not the same. Sorry.
ANSWER
Thank you all for your contributions. I'll try to post here the solution I got from reading all your answers.
When do you start commenting?
Comment the code as you write it because...
- you wont come back later to comment
- it will never be clearer in your mind
Document the API. Create a design document separated from the original code and/or comment the header of your interfaces so:
- It gets everyone in the same page
- It helps everyone stay in the same page (no unwanted morphing)
- It can evolve in the future into a more elaborated document
I selected @Octávio answer as the right one because it hit an important fact: comment before it is too late.
Thank you all again for your insightful answers!

