I am curious to see what other people have to say about this. I recently answered the following question:
The user got upset with me and took my answer as an insult (although I did not intend for that at all). I guess I could have worded my answer differently, but what I said was correct. The code that was written was inefficient (and everyone does this from time to time, nothing wrong with that). I tried to explain why I said it was inefficient and took time writing code to help prove out my point. I then later added an explanation of exactly what I was talking about to make it clear for the user.
In the pseudo code I wrote, I accidentally included a SOQL query inside a for loop. The user pointed it out to me, but instead of being polite about it, displayed hostility towards me because they had taken offense and downvoted my answer. They then made the following comment:
This does cause a SOQL query for every imported object....You do not need the if(found) clause...seems to be a "truly inefficient" way to do this....
At this point I did get a bit annoyed so I retorted back. In retrospect, I should not have done that. I went back and did what I originally should have done and changed my original upvote to a downvote. I wanted to show the user their behavior was unacceptable, so I changed it.
- What should I have done differently?
- How would you have handled this?
- This site is for future users as well as the person who originally asked the question. Even though my answer didn't specifically address the question (although it did answer it, it just didn't point it out), should I still have posted it?
- I have always been of the mindset that if you can help improve code, you should. Do you think it is appropriate to sometimes help users if you think their code is going to do something different than they intend?