Sonata Allegro form was a development of the classical era. It represents a more open form than many of the earlier Baroque forms such as fugues, rondeau form, etc. While there is a formula that can be applied, there was not a rigid, formal concept for the form. Rather it evolved over the classical era and beyond. Haydn was one of the early exponents of this form. It was named 'Sonata Allegro,' because the final Allegro movement of a Sonata was most often created in this form.
It is by no means restricted to this general rule, however. In fact there are no hard and fast rules in writing a Sonata Allegro form. However many trends can be attributed to the form, generally, Sonata Allegro form can simplistically be described as an 'ABA'' form. The first A section is called the 'Exposition.' (This section is repeated verbatim in classical performance, actually making the overall form 'AABA''). The B section, or 'Development' follows the Exposition. It usually uses some material from the Exposition, but in a more or less radically altered way.
In the A's ection or 'Recapitulation,' the A material returns relatively intact. Each of these sections has a relatively complex internal pattern as follows: The Exposition states the main thematic elements and has its own internal form as follows: 1) A Primary key section which contains: a. the Principal or Primary Theme which is a phrase or more in length and establishes home key, b. a Transition between the Primary Theme and the Related key section.
The transition can modulate to the new key, develop ideas of first theme, change mood in preparation for related key section through mood metamorphosis, introduce new material, possibly contrasting with both primary and related key sections, anticipate of ideas in second theme, be omitted, produce a deceptive modulation, or be non-modulatory if in major. 2) A Related key section which contains the Secondary or Subordinate Theme which is most often in the dominant or relative key, and can be similar or contrast in content to the Primary Theme, the Closing section, which confirms the new key, and may be derived from other themes. Next comes The Development. This is an open and free-form section of the Sonata Allegro movement, usually based on thematic materials from the Exposition. The Development can be varied in length, sometimes short and little more than a re-transition to principal theme, sometimes a large dramatic section containing a theatrical climax, storm und drang. It can also be modulatory, derivative, and pay special attention to shaping factors in pace, texture, tessitura, plan of key relationships, order of melodic material, etc.
Last comes The Recapitulation. This is where it returns to the material in the Exposition. However the Recapitulation is almost always different from the Exposition in that it remains in the home key (i. e. , second theme stays in the home key rather than changing).
The recapitulation can also sometimes be varied from the Exposition by being condensed (some parts shortened) or abbreviated (some parts omitted), a variation of the exposition, and rearranging the order of its parts, being expanded.