Unhelpful comments in your code?

All off topic discussions go here. Everything from the funny thing your cat did to your favorite tv shows. Non-programming computer questions are ok too.
User avatar
bluemoon
Member
Member
Posts: 1761
Joined: Wed Dec 01, 2010 3:41 am
Location: Hong Kong

Re: Unhelpful comments in your code?

Post by bluemoon »

While the code flow is simple and require few or none comment, the intention of the function is not.
what kschedule() actually do? does it pick a task, or it also perform the context switch?
do it modify anything in *cpu? can we call with null? what potential issue may arise (machine lock up if all task are blocked)?
do it require spinlock protection surrounding the call? etc.

These all may well be written as comment above the function.
Kevin
Member
Member
Posts: 1071
Joined: Sun Feb 01, 2009 6:11 am
Location: Germany
Contact:

Re: Unhelpful comments in your code?

Post by Kevin »

tiger717 wrote:Please have a look at this piece of code (originates from my multitasking scheduler) and tell me if you really need comments for understanding it.
No, because this is a trivial and short function, despite taking up all the space on the screen. The only thing this code needs is a regex removing some newlines. (Well, some might argue that it could need a more sophisticated algorithm, but that's not the point here... ;))

Nick's code was already somewhat more interesting, but I've seen much more complex things. What you're doing here is almost like comparing Hello World to a real application.
Developer of tyndur - community OS of Lowlevel (German)
Post Reply