in reply to Documenting Methods/Subs
Initially my answer was going to be "It depends on the size and complexity of the code" but then I stopped and thought for a moment.
If a program contains subroutines, then it is a fairly safe bet that it is big or complex enough to require comments. After all, very few people use a subroutine in a 3 line program. ;)
If it doesn't all fit on my screen without scrolling, then adding comments provides visible breaks in the code making it easier to find a specific section.
So basically I add at least one comment to each subroutine (stating what it does on a single line) to make it easier to spot if and when the program gets larger.
If I used some really hairy code - or something just plain weird - I'll add more detail, though not to extremes.
I find it makes life easier that way - especially if I have to edit the code several months later or decide to reuse that subroutine elsewhere.
|
---|