Everybody is a critic. Every developer has both been on the receiving and the giving end of criticism. It is a vital part of our job, be it as code review, comments on social networks like this one or during a retrospective. So let us have a look at both sides of criticism:
First, we should distinguish actual criticism from fallacious arguments (reasonings that are logically invalid) like ad hominems (personal attacks instead of making a point about the code/article/argument: "You don't have the experience to understand this") or false dichotomy (presenting a choice of two options when there are actually more: "You can either use Vue or React.") and point them out:
"Please no ad hominems, let us concentrate on the argument/code instead."
"That is a false dichotomy, one could also use a multitude of other frameworks and libraries!"
Next, acknowledge valid criticism, regardless if constructive or not. Even unconstructive criticism can be helpful to sharpen your arguments or provide a new point of view to think about your code. If you feel unjustly criticized, please keep it to yourself - complaining about it merely makes you look insecure; try to keep your ego out of the discussion.
"Thank you for your comment."
There's no shame in admitting being wrong, as long as you don't remain wrong. Telling your critics:
"Thank you for correcting my previously wrong position."
is one of the strongest moves you can make in any discussion.
Lastly, try to find an action to derive from the criticism: how can you use the criticism to improve your code, article or argument? If that doesn't work, directly ask the critic if they could offer actionable advice:
"Do you have any suggestion how I can improve this?".
That will usually either shut them up or may otherwise result in chances for actual improvement. Either way, you win.
That's it. You've handled the criticism in a measured and professional manner. Well done!
What is there to gain from giving criticism? Is this just satiating your urge to be right? Or the wish to convince others to stand for your cause? Do you expect an insightful and civilized discussion to sharpen your arguments? Do you even want recognition as an expert in the field?
Whatever your goal is, avoid a discussion if it is obvious that you will fail to achieve it. Don't fall for the sunk cost fallacy (throwing away your time because you already started doing so) and continue a discussion after it becomes clear that you will not achieve it. If in doubt, getting out of a discussion is simpler than you think: just say your good-bye and refrain from commenting further. You might feel pressed to answer to comments or even slurs that follow - don't. It is not worth your time and slurs reflect more on those giving them than those targeted.
Otherwise, make it worth the use of your time and the one on the receiving end: constructive criticism is always preferable, but occassionally, destructive criticism may be warranted if starting from scratch is the only way forward. Good criticism fulfils three requirements: it is logically sound, is free from ego and is actionable for the recipient:
As we already learned when looking at taking criticism, arguments should be logically sound, so refrain from fallacies.
👎 "Everyone is using React and so should you!"
👍 "React has a large ecosystem that will help you finish your project faster."
Arguments should be objective, not only in content, but also in form:
👎 "I would use recursion for that if I were you."
👍 "This task lends itself to a recursive approach."
The best criticism is one the recipient can act on:
👎 "This is so bad, it can't even be improved!"
👍 "Instead, you can use the builder pattern if you happen to rewrite this."
External sources to support your point should be included both for strenghtening your point as well as a chance to learn more about the topic.
Have you already made your criticism? Great. Now it may become the subject of other people's criticism itself and you could be on the receiving side again. And that's a good thing.
🙏 "Thank you for the time you took reading this."
You probably knew all that already and are only here to criticise this post. Go for it, it can only become better from your criticism. Or maybe this helps as a small reminder for you to improve? Wonderful. Either way, have a nice day!