Inside SWT

Thursday, April 05, 2007

No code nirvana

The other day, I was reviewing our coop's code (a coop is an intern for those of you from the states). We get great coops who are smart and work hard and this guy is no exception. I always ask the person to clean up their code before I get there and make sure it's good.

It is normal for me during the review process, even after cleaning, to delete 10 to 50% of the code, without removing any functionality. Some of it is unused variables, dupicate state, things that are stored instead of computed and all the usual things that cause "too much code". However, a surprising amount of it is simply duplicated or unnecessary work. Why?

SWT committers are rewarded for implementing functionality, not writing code. We take pride in having the minimum amount necessary to do the job and strive to reach "no code nirvana" (an impossible state). Perhaps you reach it when you become a manager?

Steve

4 Comments:

  • > Perhaps you reach it when you become a manager?

    I doubt it. Seems to me managers spend all their time creating useless work without any results. So wouldn't becoming a manager make you write *more* useless code, not less? :-)

    By Blogger Daniel Spiewak, at 3:25 PM  

  • > SWT committers are rewarded for implementing functionality, not writing code.

    So the more functionality they write the more they are rewarded, but spending time cleaning up goes unrewarded?

    By Blogger Channing Walton, at 4:01 PM  

  • No way. Code clean up is an essential part when attempting to reach "no code nirvana". Code clean up for me often involves deleting code, not adding it.

    Steve

    By Blogger Steve, at 5:04 PM  

  • A whole work-term and all there was to show for it was the function.

    No doubt a valuable lesson in code size, especially on these embedded devices I'm fond of these days.

    By Blogger Sebastian, at 12:17 AM  

Post a Comment

<< Home