There are four basic kinds of variation:
1) A variation that preserves both melody (though perhaps with new ornamentation) and harmony of the theme
2) One that preserves the essential harmony of the theme
3) One in which the harmonies deviate but the over-all structure, such as the number of measures, the structure of sections and phrases, and cadential endings, is preserved
4) The entirely free variations of modern composers in which even the structural outlines of the theme are no longer recognizable.
Historically, category 1 prevails throughout the 16th and 17th centuries; category 2 throughout the Classical period; category 3 is common among Romantic composers; and 4 is characteristic of the most recent style.
There is still a fifth kind of variation, in which the melody is retained but the harmonies are altered. In the Classical period, this type was used as a kind of "trick."
In the 19th century, the variation form was sometimes used as a movement of a sonata or symphony, but it was also important as an independent form for both orchestra and piano solo. Variations were created on preexisting themes or on specially composed melodies. Occasionally, variations were made to suggest particular moods or ideas suggested by the theme.
(see also Passacaglia and Chaconne)