The story starred Lieutenant Mary Sue ("the youngest Lieutenant in the fleet — only fifteen and a half years old")Also according to the same article, it has been speculated that Wesley Crusher on "Star Trek: The Next Generation" was a "self-insertion" by Gene Roddenberry and thus a Marty Stu. (I held this opinion long before I learned the term "Mary Sue" and in fact, since about half-way through the first season of ST:TNG.)
But here's the problem. Who does the writer know best? Himself or herself. So where can the writer best draw character distinctions? From himself or herself. For instance, my main character in Hammer of Thor, Francis Kader, has a couple of flaws I have myself. Michael Vaughan of Agent of Artifice is pretty much based on how I would probably act if I were an adept (the people with magical powers in my Adept Series novels). And Peter Branton of Book of Death and the forthcoming Gods of Strife has more than a few of my personality quirks. But does this make them Marty Stus? I don't think so because they have flaws (mostly mine) and are not perfect. Is there a little self-insertion going on? Yeah, but I don't think that makes them bad characters.
(Speaking of self-insertion, I have read two fiction novels which mention the author: Brothers No More by William F. Buckley mentions Buckley's run for mayor of New York City and in Number of the Beast by Robert A. Heinlein a character says of Heinlein's Stranger in a Strange Land something like, "what some writers won't do for money." But that's a different kind of self-insertion and in both cases the authors used it as self-denigrating jokes.)
In my novel Rock Killer, I gave the main character, Alexander Chun, horrible space sickness (and he works in space). I did this because I suspect I would have horrible space sickness (I get motion sick very easily) and it was an easy flaw to give him (yes, he has other flaws). So again, I drew upon myself.
Of course, for writers there are countless places to draw characters from. And you should never base a character on a specific person but use an amalgamation of people and their characteristics. But don't be afraid to give a character a characteristic you have in fear of having a Mary Sue, especially if it's a flaw. And, whatever you do, don't have an idealized character who is flawless in every way. Even Superman had Kryptonite and Lois Lane.