A fugue is a piece that is based on a single melodic idea (often accompanied by a contrasting idea). These are called the 'subject' and 'countersubject'. Well, ok, sometimes fugues have two or three or even four ideas and are then called 'double fugues'. What is cool is the way the subject can be layered with itself and transformed in various ways: expanded, contracted, inverted and even played backwards. This genre developed over a few hundred years and reached its pinnacle with J. S. Bach. I took a seminar in fugue once and the professor announced quite casually that the ONLY composer we would be studying would be Bach. But just a couple of decades after Bach died, Joseph Haydn started writing fugues in the finales of his quartets op. 20 and then Mozart started writing fugues. The finale to the Jupiter Symphony is an example. Then Beethoven got into it and started writing fugues in his piano sonatas and string quartets. Soon after that, the theorists wrote a lot of textbooks on fugue writing, so of course it died out for most of the 19th century except in the classroom. But Bartok flirted with fugue in a couple of pieces in the 20th century. In 1950 Shostakovich was sent to judge a piano competition as part of the festivities connected with the 200th anniversary of the death of Bach and heard a LOT of preludes and fugues. When he got back home he started writing and in a few months had written a sequel to the Well-Tempered Clavier: 24 preludes and fugues in all the keys.
Traditionally--I mean with Bach and Beethoven--a fugue subject was pretty simple. That Bach fugue in E major I posted yesterday is an example. But Shostakovich wrote one fugue with the wildest, longest fugue subject you could imagine. Here is the fugue in B flat minor, no 16 from his Preludes and Fugues op 87:
The performer is Tatiana Nikolayeva who was in the Bach competition Shostakovich was judging. She won the gold medal.