Melody is possibly the most stigmatized concept in music theory. For something to be melodic, many people believe that it needs to be slow and pretty; it's a word that carries a heavy connotation. Melody (at least the current version of the word) is beautiful, and anything that deviates from that is simply not melodic. Strictly speaking, however, melody has nothing to do with beauty or abrasiveness. Melody is just a series of notes or pitches played in succession, notes that can be heard as a whole. Simply sitting down at a piano and banging out a couple of notes does not a melody make. A melody needs to be heard as a single entity in order to be considered a melody. And even the most dissonant of musical phrases is still a melody if it fits that requirement.
The modern idea of melody differs from that of early western classical. Melody is heavily used in rock and pop music, and those genres usually base a song on one or two melodies only: the verse and the chorus. Of course, there are some subtle deviations along the way, but a catchy, radio-friendly pop song will repeat the same melody over and over to make it memorable for the listeners. Early western classical music didn't have the same concern with airplay and demographics, so a strictly repeated melody wasn't the norm. This type of music used melody to introduce a theme, moving on to vary that theme in several different ways. The basic melody was still there, but it had the potential to became nearly unrecognizable as it shifted and changed. The sonata form is a stunning example of this concept of theme and melody restatement. Melody is also extremely important to jazz musicians, especially those that specialize in improvisation. Though there are several types of improvisation, melody is frequently used as the song's base. Improvisers will set a pre-determined melody and allow the lead instrument to jump forward from that melody. It creates a wonderfully rich piece of music that shows how quickly (and interestingly) a melody can evolve.