- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
"Did you get heads or tails?" "Yes"
Admin
Admin
I don't think you understood what I'm talking about. I'm talking about the scenario where you do not know what the original bug was. The scenario where all you have is a piece of code and a repository. Personally, I don't know any code repositories that are sophisticated enough to pinpoint when individual lines of code were added. I use SVN and it certainly doesn't do that. To track down changes I can go through the revision history for the file; but when the revision history is several years in length that can take a while. On the other hand, if the block of code is conveniently labelled with the bug that it was supposed to fix, it takes mere seconds to look up the bug.
Admin
Or was there something different you had in mind?
Admin
Oh, you can fix both of them, if you take your "disciplinary procedures" seriously (and severely) enough... :)
Admin
Sigh ... it's amazing how many idiots love to stat that code should have comments, and defend the values of comments. What these morons don't seem to realize is that you comment something because it's too fucking complicated. Good, readable code doesn't need comments, you can glance at it an know what it does.
Another point, people update code, the don't comments.
Admin
On comments:
If you are writing the code, add comments so YOU can understand it. In 6 months (more or less) you will have forgotten all the minutia of the problem, and you will probably start from scratch figuring it all out again and again. This is a very good rule to follow.
You write a small 'hack' to get some details and massage some data. This program will grow into the most critical money making piece of software your company will produce, so you had better comment it for others to understand.
Avoid comments like "// ..." (a well known author of a programming language does this) as if they were the plague. They don't help anyone and are work sinks.
That completes todays programming lesson for today. Class dismissed.
p.s. The metric ought to be "words (English) of comments" not "lines of code". If you can't explain it, nobody will understand.
Admin
A good comment doesn't need updating every time you do a little change to the code, and it tells you something not immediately obvious from the code. Sometimes the right algorithm or the right datastructure needs some careful explanation of why things have to be this way. If you've never done anything genuinely tricky (for example, what's special about the number 3215031751?) I could understand you not appreciating this fact.
Admin
So what you're saying is that, after typing "Ojbect o" and getting an error, I can expect a different result if I retype "Ojbect" much faster than I did the first time?
Admin
Working with artists, I see a disturbing amount of changelists that have a description such as:
Or a variation of that.
Admin
Again still think your point is mute, name your methods/functions accordingly ... such a sudoPrime, does this need a comment no, naming variables/methods accordingly reduces the need for comments. I never said code doesn't need comments I said they are overused ... why does some crappy algorithm need comments because some fucktard doesn't know how to abstract or name it accordingly ... the Engrish (yes pun intended) is incredibly expressive ... it's amazing how useful it can be.
I have yet to come across a lot of code that ever needs comment. The only time I use comments is when something is truly tricky such as a decent non-blocking concurrency algorithm. But again most decent programmers should be able to know what it does beforehand ... guess we will have to agree to disagree
Admin
Admin
At least I didn't flip it again, expecting a different result. Better to be a loser than insane.
Admin
You seriously need a comment for a magic number???
Admin
gotta catch them all!
Admin
Uh, no. That's a fine aspiration but we're not there yet & probably never will be. Complex systems can result in complex interactions which are not obvious from the individual steps being performed. In these cases, comments can be very useful in adding understanding of how the individual steps combine to accomplish the overall end-goal.
But certainly comments should only be added where they increase the readability of code. If you're writing:
then you've just decreased the readability, as you've written twice as many lines for no additional information. On the other hand, the following is a good & necessary comment:
Admin
Another one: in old VB it was used to "un-nulify" a String. To prevent the Error 91: Object variable or With block variable not set (NullPointerException in VB World), one could append the string with an Empty; this way the null became "", and other values remained unchanged.
Right or wront, this is how null safe strings were made back then...
Admin
Alex, Rodrigo's comment should be blued.
Admin
I don't have a problem with putting the bug tracking number in there. On my project, I have to deliver source to a customer that doesn't have access to our source control or bug tracking system.
Admin
Right? My favorite part was this: and despite having no Java experience, he loves to "help out" the team by diving into the Java projects.
When you have no experience, you should keep it that way and never "help out"?
Admin
TRWTF is anon's communication skills. What was he expecting?
Admin
SVN annotate is your friend !
Admin
Not true at all. Code readability isn't the issue. It's WHY that particular piece of code even exists. I leave comments to my future self (and other team members) so that they understand why that piece of "brilliant" code needs to stay there without having to hunt through all sorts of different systems to hopefully locate it.
For example, imagine starting a new job and finding something like the following in the billing system:
if (today=="tuesday") { price = price * 1.0345; }
That's a simple bit, totally readable, not complicated at all and certainly should make whoever sees that ask Why TF it's there. However, consider seeing the following right above that if statement:
// 2004-12-24 mike: Per CEO Jim all prices are bumped by 3.45% on Tuesday's no exceptions.
No WTF here and certainly a clear, concise and helpful comment for clear and concise code. You don't need to go through the ticketing system or blame or whatever the hell else you have. You just move on.
Granted that comment could be reduced to remove the date and name (as blame etc has that) however that's just being nice. Never mind the fact that I've seen many places lose historical check-in history because the new dev manager likes this system better than that system. When that happens you never figure out what's going on and just have to hope that your refactoring isn't leaving vital stuff on the floor.
-the idiot.
Admin
Best news of the day of mine! Stupidity is unbounded.
Admin
+1.. put the issue number in the commit message. Configure Bamboo + JIRA right and your code change will automagically appear in the relevant issue along with any associated code reviews and build versions (assuming you're using smart tags for those as well...)
Admin
Really, he should have said that the definition of insanity is doing the same thing continuously with no variation in input parameters, and expecting different results, is insane.
Coin coin = new Coin("heads", "tails"); while(true){ coin.flip(); if(coin.sideUp.equals("a fucking potato")){ //It is insane to think this will ever be reached break; } } //enjoy your insanity
Admin
Bad post formatting before, sorry.
Really, he should have said that the definition of insanity is doing the same thing continuously with no variation in input parameters, and expecting different results, is insane.Admin
Why do we even talk about this? The universe is the hidden input parameter to this particular experiment, and this particular parameter is always different, even if classic mechanics (Isaac Newton sans Butterflies) applied to it.