|
Wolfgang_Baron wrote: Alright, so you think I am suggesting, that giving more answer options is always better?
No, I was making an inside joke that no matter what answers I put in a poll there will always be someone, somewhere, who comaplains that I've missed an option.
So OK: What choices would you like to see to have a fully rounded poll that encourages debate without reducing the need for interesting discussion?
cheers,
Chris Maunder
The Code Project | Co-founder
Microsoft C++ MVP
|
|
|
|
|
You have the option to not vote and add your comment on the topic in a more detailed way.
Please abstract from the actual poll result - this does not really matter - it's more about triggereing a discussion on the topic.
Cheers
Andi
|
|
|
|
|
If you know the logic just add a line why the code has been removed with version if you want to maintain it too.
It's really far better dumping out the unnecessary code and keep your code neat and clean.
Sometimes it may happen that you need the removed code, if this is the possibility why you kept it commented; then you should also agree with the possibility that you could come up with far better logic next time for the same thing. But only because you've commented it you will never even think of that.
|
|
|
|
|
While working I comment out but come commit, the old code is deleted. Dead as French Attack.
Reality is an illusion caused by a lack of alcohol
|
|
|
|
|
Nagy Vilmos wrote: Dead as French Attack
Like the battle of the Chesapeake?
|
|
|
|
|
For me, it depends on the situation, I have created utility libraries for debugging live code. And I will comment out the one or two lines of code that access the utilities. However the lines are commented as to their function and how they are used.
When we develop a new product we generally use one of a set of communication protocols but as new parameters are introduced it is useful to see how the data stream is being parsed. It can be a real time saver.
Code that serves no purpose because of code reduction or improved processes, need to go away.
It was broke, so I fixed it.
|
|
|
|
|
I comment the code out - just in case I need to undo the damage, as a reminder, and stuff like that. Eventually, when suitably aged, it is removed.
Just a habit of caution - like carrying a second car-key: even if you only need to use it once in five years to get into your car because you lost or locked you key inside to make it worth it. So it is with seeing what you've done that you've, for any number of reasons, decided to undo.
I need to point out that the above cautions aren't quite as effective with marriage or parenthood.
"The difference between genius and stupidity is that genius has its limits." - Albert Einstein | "As far as we know, our computer has never had an undetected error." - Weisert | "If you are searching for perfection in others, then you seek disappointment. If you are seek perfection in yourself, then you will find failure." - Balboos HaGadol Mar 2010 |
|
|
|
|
|
It had a policy of never deleting code, only commenting. We also used vi to edit these files, so we were often looking for /* or */ in 100s lines of visually undifferentiated code
Some bright sparkhad the idea of banning /* */ in favour of // which made things easier. But not as easy as the best dev in the department letting me into the secret that we were, in fact, allowed to use EMACs (with glorious syntax highlighting). He said vi was only prevalent because of "macho bulls**t posturing" by the other staff .
“Education is not the piling on of learning, information, data, facts, skills, or abilities - that's training or instruction - but is rather making visible what is hidden as a seed” “One of the greatest problems of our time is that many are schooled but few are educated”
Sir Thomas More (1478 – 1535)
|
|
|
|
|
Mostly I remove (source control) but occasionally I comment out it (for removing it some future iteration)
|
|
|
|
|
Worse than commenting it is not commenting it at all...
Code within IF blocks can easily never be executed, and I've seen this being use on purpose...
Am I the first to find an
if (false) { code block?
Use the source control of your choice... please!!
Cheers!
|
|
|
|
|
Yes, I had a co-worker whose favourite "thing to avoid having to clean up functions" was exactly that, and saying nothing, writing no comment at all. He usually had really good ideas, but he was a fvcking lazy bastard and a pain in the ass if you had to complete something started by him.
The most positive side for me was... I really had to learn very fast to be able to understand that code and, I had the best teacher in how NOT to do several things.
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
Rating helpful answers is nice, but saying thanks can be even nicer.
|
|
|
|
|
If used *sparingly* I don't see an issue with this. If you're likely to re-enable the block soon its a viable option - with the benefit that the code is more readable with syntax highlighting versus a commented block.
"For fifty bucks I'd put my face in their soup and blow." - George Costanza
CP article: SmartPager - a Flickr-style pager control with go-to-page popup layer.
|
|
|
|
|
For me you could do whatever you want as long as you don't push it to the repository like that!
|
|
|
|
|
That's amazing. Just add comments.
if (false) {
}
"Bastards encourage idiots to use Oracle Forms, Web Forms, Access and a number of other dinky web publishing tolls.", Mycroft Holmes[ ^]
|
|
|
|
|
Flavors of the following are usually frequent in this "best practice":
if(1 == 2) {
|
|
|
|
|
Right?
I hate seeing laziness of other programmers.
If you need it don't comment it out. If not delete it.
No more Mister Nice Guy... >: |
|
|
|
|
|
Usually I comment out unused code, then after a reasonable amount of time and no screaming from users I remove unused comments and cleanup the code.
Its the man, not the machine - Chuck Yeager
If at first you don't succeed... get a better publicist
If the final destination is death, then we should enjoy every second of the journey.
|
|
|
|
|
I have some co-workers who do.
It bugs me a great deal seeing commented out code and it makes me think "is this obsolete or is this intended to be used at a later time?".
It obfuscates code that does matter, especially other comments.
There's a reason it's commented out and that reason is probably that the code didn't work or that the specs have changed and you don't need it anymore. There is no reason to keep it around.
Old code will always be available through source control.
Please just delete old and unused code. If you really think you'll need it someday again just keep it in a personal text file or something.
It's an OO world.
public class Naerling : Lazy<Person>{
public void DoWork(){ throw new NotImplementedException(); }
}
|
|
|
|
|
If you have everything checked into version control, then there is not much need to keep old code. However, most of my code goes into libraries and the job at hand is supposed to be only a thin layer on top of those libraries.
That kind of code does not become obsolete. It is constantly adapted and improved. Some of my code has reached a biblical age this way and is far from obsolete. I can't think of a more productive way to work, at least as long as Mickeysoft does not decide to pull away the rug under my feet by throwing everything overboard for their next great idea.
Sent from my BatComputer via HAL 9000 and M5
|
|
|
|
|
This is the only right answer...
|
|
|
|
|
Except that it can be very hard to find... where did I put that discarded function? It's in one of a possible dozen possible files checked in betweeen 2011 and 2013
|
|
|
|
|
Yes, and the many many branches and the comments you did not enter when checking in also don't help. And let's not talk about the nonexistant documentation or change management. Version control can be hell.
Sent from my BatComputer via HAL 9000 and M5
|
|
|
|
|
...so I can travel back in time and recover that clever thing that I shouldn't have deleted.
|
|
|
|
|
I just got a question in my mind "How many times we follow commented code ?"
I have commented a part of code last year and this year i did same development on some other forms, i really forget that i have same piece of code somewhere in my project. Really interesting
I think in some pressure condition we really forgot about the code that was commetned some months/days ago, and do the same coding.
Do you ?
Rating always..... WELCOME
The only reason people get lost in thought is because it's unfamiliar territory.
|
|
|
|
|
No, I don't. Redundancy is one of my oldest enemies and I go out of my way to get rid of it. And even in the days of hex keypads and hand written machine code I already organized my code into libraries to keep the problems I hade previously solved and bugs I had previously fixed at hand for future use.
Nothing, not even the gratest framework in the world, beats a self made library of proven code, right in whatever domain you happen to work in.
Sent from my BatComputer via HAL 9000 and M5
|
|
|
|