You must play a character who has an accent, but you must never play an accent.- How not to do an American accent, BBC News
This struck me as being as relevant to writing as it is to speaking in another accent.
Many of us, when we got started as writers, found the idea of writing someone of a different ethnicity or gender or from a different country or background fairly intimidating, and when we tried it, we got it wrong.
The key, of course, is not to say "I'm writing a 14-year-old girl" or "I'm writing a black man", because you're not. If you try to write like that, you'll write a cliche. It'll come off offensive or stereotyped or unconvincing.
What you're trying to do is write a person, an individual. That that individual has as one of their characteristics that they are black or a girl or 14 is only one very small piece of information about them. It may be significant, but it's certainly not the only significant or even in most circumstances the most significant piece of information about them.
The fact that this character is any of those things shouldn't make writing them any more difficult than writing any other character, because each character needs to be an individual, a person. Someone not you.
It's not uncommon to see people go wrong in this when they're writing high fantasy, where every elf is serene and graceful and supremely fantastic with a bow, for example. Oh yeah? Look at the variety in humanity in temperament or athleticism.
The problem comes because the writer decided to write an elf, not a character who happens to be an elf.
As the dialect coach might say, 'You must write a character who is an elf, but you must never write an elf.'
If I had to choose a list of revelations that helped me as a writer, that one would be near the top.