|
_Maxxx_ wrote: tax = taxRate * fine;
... and THAT is -5 vote
Remember: NO comment is NOT AS WORSE as a WRONG comment !
You don't calculate the fine but the tax.
|
|
|
|
|
Yeah, well, in my defence I was making it up as I went along!
|
|
|
|
|
[Description("Calculate the tax based on the rate from the database.")]
double CalculateTax(double fine) {
return fine * GetTaxRate();
}
Now you can find it via Reflection as well.
|
|
|
|
|
Would't you have to do
[(".esabatad eht morf etar eht no desab xat eht etaluclaC")noitpircseD]
|
|
|
|
|
No, because the compiler doesn't care how you view it.
|
|
|
|
|
AspDotNetDev wrote: even for private members So you tatoo your privates?
If your actions inspire others to dream more, learn more, do more and become more, you are a leader.-John Q. Adams You must accept one of two basic premises: Either we are alone in the universe, or we are not alone in the universe. And either way, the implications are staggering.-Wernher von Braun Only two things are infinite, the universe and human stupidity, and I'm not sure about the former.-Albert Einstein
|
|
|
|
|
Can't talk out of experience but that must hurt like there is no tomorrow.
|
|
|
|
|
I already have[^].
I'm no longer willing to even entertain the discussion anymore. Every "good" example I've seen where commenting isn't needed is contrived. The real world is messy. Use comments.
cheers,
Chris Maunder
The Code Project | Co-founder
Microsoft C++ MVP
|
|
|
|
|
I agree, and I like to use comments. I actually often have more comments than code sometimes (mostly XML documentation comments, those can get quite long, and if they get so long (~35 lines) due to a function that does a number of things, I split that function up to make it manageable). I like comments. They help me when I go back to something and think 'WTF was I thinking there'. Sometimes.
Bob Dole The internet is a great way to get on the net.
2.0.82.7292 SP6a
|
|
|
|
|
I'm back on a project I coded in C 20 years ago and I'm sure glad we chose to comment the way we did cause I've had many a WTF momments lately!
|
|
|
|
|
I disagree Minimalist Comments[^]
Further your statement is flame. Let the discussions continue. Let learning continue.
Gus Gustafson
modified 18-Jan-13 10:07am.
|
|
|
|
|
My statement is "flame". You're kidding, right?
You also provide an absolutely perfect example of why comments are important:
average_ship_speed
This name is very descriptive. Everyone in your team probably loves it and understands it. Your offsite developers in other states in the US get it too, and use it. Then you send the code to your cheap Canadian outsourcing company and something goes horribly wrong and you lose a Mars orbiter[^].
cheers,
Chris Maunder
The Code Project | Co-founder
Microsoft C++ MVP
|
|
|
|
|
So was that average_ship_speed_in_feet_per_second?
|
|
|
|
|
It was unitless
Gus Gustafson
|
|
|
|
|
I have a friend who enjoys quoting things like this in furlongs per lunar month.
cheers,
Chris Maunder
The Code Project | Co-founder
Microsoft C++ MVP
|
|
|
|
|
No I'm not kidding. Brazen statements, designed to invoke a response outside the area of the question, are flame. You're tagged.
The old article to which you refer, does not relate to the question at hand. I know that a missing comma also caused a NASA mishap. But that is beside the point.
We are discussing comments. I have publically espoused that comments be minimized. Not eliminated. They are to be replaced by well conceived identifiers drawn from the functional area (other than perhaps i, j, k, etc, when used as indexers). The example, to which you referred, replaced the identifier a with the identifier average_ship_speed. Personally, I find that improved readability immensely. Too often we forget that a failure to provide readable code is a failure to provide maintainable code.
Referencing outsourcing, I write code in English. Not because I am an elitist but rather because I speak English as my first language. All of my outsourcing experiences have been with providers who also speak English, but not as their first language. So I tend to review their code and make global changes where misspellings have occurred. But I hold them to the same standard to which I hold myself.
Gus Gustafson
|
|
|
|
|
Hey Gus,
I think you're missing my point - that there is always scope for confusion in even the simplest, seemingly "safest" code - but I do appreciate the back-and-forth. However, I must take exception when you say my response is outside the area of question. The original post stated "My code doesn't need comments because it is self documenting" which is an argument I've seen again and again. My reply to you, specifically, was that even something as simple as average_ship_speed can cause problems, especially when two different people using two different system (eg Metric and Imperial) consume the same value and have different expectations.
gggustafson wrote: I tend to review their code and make global changes where misspellings have occurred. But I hold them to the same standard to which I hold myself.
That's important, but with spell-checkers readily available I've found that the biggest issue is not spelling, but rather meaning. I'm sure you read my blog post that discusses the issues with that.
Overall I do agree that comments are not a replacement for good coding, and I also feel that good coding cannot be a replacement for good comments. Their is so often scope for ambiguity and even with the best devs I come across problems again and again.
cheers,
Chris Maunder
The Code Project | Co-founder
Microsoft C++ MVP
|
|
|
|
|
|
I initial and date all my code changes in a comment near the change - you have no idea how many times I have been able to point to that in code for a client and say "No, noone has changed this since..." which is particularly handy if something strange goes on...
|
|
|
|
|
So you aren't using source control?
|
|
|
|
|
In some instances source control isn't available, but even where it is used, I still write my comments in the code... Call me old fashioned.
|
|
|
|
|
I use source control and check in with relevent comments - you have
no idea how many times I have been able to point to that in code for a client
and say "No, noone has changed this since..." which is particularly handy if
something strange goes on.
|
|
|
|
|
Bollocks.
I wanna be a eunuchs developer! Pass me a bread knife!
|
|
|
|
|
That's obviously a lie. Self documenting functions are nice, but you can't do anything nontrivial that way.
Then again, maybe his code only does trivial things?
|
|
|
|
|
Round flying thing.
Discus.
|
|
|
|