Note that some well-written characters can, technically, fall under the category of a Mary Sue (or Gary Stu, which is the male equivalent). It’s only when the writing is severely bad / lazy / a combination of both that a Mary Sue tag really gets attached.
It can be a wish fulfillment, of course, but usually the Mary Sue is kind and loving and thoughtful and loving and wonderful and kind to animals and loving – and who dies tragically because the world can’t handle her/his goodness.
Another indicator is (in fanfiction, where the term originated) if a totally new character that’s never been seen in the official franchise begins a romantic relationship with ANY of the established characters. That “new student” in a Harry Potter fanfic whom Harry immediately falls head-over-heels in love with, for example.
Wikipedia has a infomative [url=http://en.wikipedia.org/wiki/Mary_Sue]articel on Mary Sues. From the article:
What jayjay mentions is how I most often see Mary Sues. If I write a Harry Potter fanfic and add a new beautiful, more brillliant than Hermione, transfer student from America with gorgeous copper hair and intriguing slate blue eyes whom Harry, Ron, and Draco immediately fight over, that would be a classic Mary Sue…
More one than two. Mary Sues are not necessarily perfect in every way, but their flaws are often not really flaws, or very forgiveable flaws, or plot necessary flaws (the flaws tend to be “outspoken” or “opinionated” or “brilliant beyond her years”)
Which, of course, was eventually trumped by the notorious Stephen Ratliff when he took a very minor character from the TNG episode “Disaster”, Marissa Flores, and turned her into the infamous Marissa Amber Flores Picard in the much-MiSTed Marissa Stories…
Dunno about Melanie, but Dominique from the Fountainhead always struck me as Ayn Rand’s neurotic fantasty image of herself - statuesuqe, glamorous, beautiful, the object of every man’s lustful desires, and the one woman worthy of the ‘real’ man in the book. What makes this scenario even creepier is that the book contains a secondary character called “Cathy” (IIRC, she’s the villainous Ellsworthy Toohey’s niece) who is described as short, squat, drab…basically what Rand actually looked like. Cathy however is a fairly pathetic, easily manipulated character. Thus, IMO, she wrote herself into the story twice - once as the ideal woman she obviously wished she were, and again as a frumpish hausfrau worthy of contempt. (Paging Dr. Freud!)