views:

1260

answers:

6

Hello, When releasing source code for someone else to see, when coding style is not well defined (no pun intended) do you remove the #ifdef DEBUG parts?

(that is the parts that are compiled only when DEBUG is defined)

If I remove it, it makes the code looks better (or me look better - do I really want someone to know I've debugged, and how I've done it? ), but then I'll lose my debug parts, or have to keep two (or more) versions of the code.

What is to be done?

thanks.

+5  A: 

I think if your debug code is clean and has "professional" language in any logging statements, it's okay to leave it in. If the debug code is sloppy or has debug messages like "I'm here...," "Now I'm here..." you should take it out.

If your debug statements reflect the fact that there are issues that you can't figure out, it might be best to take them out, if you're trying to "sell" your software to someone. (Hopefully you can fix them later...)

Andy White
If you're going to go through and delete all the unprofessional debug code, you may as well professionalize and leave them in.
Daniel Dickison
+1 to Daniel, if you could mod comments :)
Otis
+3  A: 

You should leave the code as is, unless you make use of non-recomadable language in your commentary. If someone is to use your code, chances are they'll need those, or it will help them understand your code. (this is also true for commentaries)

Edit: I worked on drop of other studio code often in the past. I have seen debug code, dead path and many other stuff, still the only thing I hated, was people that strip their code of debug and commentary, this makes their code real hard to maintain

MissT
+2  A: 

If you do decide to remove them, just filter them out with a script when exporting the code, no need to maintain two versions.

Jaka Jančar
That's a good idea! thanks.
Liran Orevi
+2  A: 

I also vote to leave it in. If/when you start work on your first patch, you'll likely need those DEBUG-blocked pieces. Also, QA won't love it that you removed the code, even if it is blocked in a directive.

Slidell4life
+2  A: 

Maintain your base version with everything in your source code management system.

Then if you want to distribute source code filtered in one or more ways, make a script that will make a release version of your source code.

Do not maintain these secondary filtered repositories, make them always generated.

But is it worth the time? Probably not, and you should probably just distribute everything including the #ifdef DEBUG parts.

Brian R. Bondy
A: 

Maintaining multiple versions of ANYTHING is undesireable.

Only do so if you must.

Blank Xavier