But the thing that was least discussed in my study of fugues that I feel warrants mention beyond the absence of countersubjects entirely in many fugues is that there is far more liberty to the countersubject than a strictly academic explanation would lead you to believe. In one of Bach's B minor fugues in the 48 (I think ... ) he presents the countersubject in prime form in the first answer and when the subject returns he presents the INVERSION of the countersubject. It is also commonplace to transpose countersubjects when they would not work in their initial form over the subject.
I have also noticed that while strict adherance to the interchangability of the subject and countersubjects makes for a more impressive fugue there is plenty of room for free material both in middle entries as well as episodes. I prefer to stick to George Oldroyd's hoary axiom that it is crucial to have all the material in your exposition be the best stuff you can come up with because THAT is the stuff you'll have to live with for the rest of the fugue. I don't recall that he said that resorting to free material "may" mean that you're unhappy with some of your exposition but it could be inferred. Then again, Oldroyd never really indicated what Bach seems to have noticed, that in a three and four strand contrapuntal composition some of those puppies grow up to be dogs that just don't hunt, so you don't take them with you for most of the hunting exposition.
All of this becomes even more potently practical when composing contrapuntal works for solo guitar. It seems too bad that so many of the few who have composed fugues for the guitar never took the time to compose countersubjects. To be fair, I suppose, any guitarist, let alone a non-guitarist, who composes a fugue for the guitar should be proud of pulling off a multi-line work for solo guitar! Yet I aspire to something more demanding and perhaps that just makes me a pedantic snob, but the whole beauty of counterpoint to me lays in its capacity for inversion and rotation. Simply because other composers for the guitar have not generally bothered to write invertible counterpoint for the instrument doesn't mean no one should try it.
Then again, most guitarists and those who write for the guitar have never sung in choirs and may thus be unfamiliar with how contrapuntal art can be developed within the severely limiting yet practical confines of ensemble singing. Perhaps I am a guitarist/composer who had the supremely unfair advantage of singing a William Byrd motet in high school and later on sang any number of contrapuntal choral works by Fux and Sweelinck and Durufle in college. So many guitarists have gulped down the notion that the guitar is a miniature orchestra and too few seem to have benefited from the more practical observation that the guitar is much like a choir (without the wonderful ability a choir has to sustain, which means it's more like a harpsichord with some room for vibrato)!
Learning what is possible within the confines of a choir makes the guitar, by comparison, easier to navigate. After all, for both the guitar and the choir it is dangerous to have voices cross each other because the clarity of the melodic line can be lost. For both the guitar and the choir the range of the "instrument" is similarly restricted to the lowest notes baritones can handle to the highest notes the sopranos can squeak out on a good day with some solid rehearsal.
There is in the end no substitute for slogging through the work it takes to compose fugues and to discover through trial and error what the material you are building with, as it were, suggests to you. The house you build with wood is not the same kind of house you would build with bricks and the house you build with bricks is not the same sort of house as the one you would build with sheet metal. Of course in the real world no one builds a house only with one of these materials or the other but I trust you get my point.
By way of extending this metaphor each additional melodic element or strand in the fugue may be thought of as the plumbing, the wiring, the insulation, and the heating of a house but the foundation is ultimately the subject. If you build your house on a solid foundation that can withstand the weight of all the other elements then your house will stand and people will actually decide to live in it. If you don't then odds are pretty high in a musical idiom as unforgiving as the fugue that no one will live in it. What is more if you are not willing to live in the house you built for yourself no one else will want to live in it.
In a way this is all a roundabout way of saying to study the old masters, see how they built the houses that they lived in, see how they built the houses that people have been living in since. You don't learn merely by building your own houses, you apprentice yourself by way of study to the builders and houses of the past. This is not always because all those houses built in the past are better, you may find that the houses you build are in some cases sturdier homes but if you study the masters of the past you will understand how at the level of true mastery one builder can be strong in one area and another builder may be strong in another.
At the risk of reciting a hoary cliche you're safest bet is to study J. S. Bach and to see how he assembled his fugues. Then you can turn to the likes of Haydn and Beethoven (Haydn tends to be under-appreciated as a composer of fugues). You can turn to Mendelssohn, you can turn to Bartok, Hindemith, Brahms, and others. You can go further back to Byrd and Purcell and also to Handel. You will find in different periods certain things change and others remain the same. The unalterable foundation of any fugue is its subject and though this should go without saying it constantly bears repeating.
The most important observation I can make now that I've been working through composing some dozen fugues is that your subject must be a tune that submits to developmental processes and which, perhaps most importantly, beyond this initial observation, is something you will not soon quickly tired of either hearing or playing. Writing a decent fugue is like writing a decent pop song except that you must start right away with your hook and the hook must withstand immediate transposition and repetition for the entire length of your pop song. Really these musical arts are not so disparate as many people on either side of that pop/classical divide would have you believe but I've already written at some length about that elsewhere here.
So beyond studying the old masters of fugue-writing there is another task that you should consider. I will aproach this by way of a necessary digression--the comic book author and artist Andi Watson once put it, the lines in the sand are social. Someone interested in comics can benefit as much from a study of Peanuts and Garfield (yes, I admit I said that) as Calvin & Hobbes or Krazy Kat or any other comics story. If you study fugues don't forget that you will learn as much by studying other non-fugal compositional procedures as you will be studying them. Both negative and positive space are parts of composition in musical as well as visual art.
Don't rule anything out, not even the things you dislike, as something you can learn from. You can learn a lot from the things you like but you can learn as much from the things you hate. When I was young I was assigned Bruckner and I hated Bruckner (I still hate Bruckner)An essential part maturing as an artist is to recognize that it is wiser to learn from everything than to set some things off limits.
You may want to compose fugues but you will benefit from listening to popular music. Why? Because you will hear the kinds of tunes that people keep singing over and over again and just as the hook is the foundation of a popular song the subject is the foundation of the fugue and you will find, particularly in the works of Bach, that popular hymns can become the foundations of amazing fugues.
To pick just one easy example the giant fugue for solo violin in C major is derived from a subject that relies on the German hymn that can be roughly rendered as "Come Holy Spirit". You can even detect, with some careful study and historical cross-referencing, how the fugue subject and the hymn from the German tradition connects to the old venerable tract Veni Creator Spiritus with that stepwise oscillation around the dominant scale degree. At a more ostensibly mundane level you can see connections between the bass line in Weezer's "Island in the Sun" and the opening first violin line in Haydn's "Fifths" quartet. The more widely you cast the net the more fish you will discover have more in common than you could have guessed.
So now we have, it seems, come full circle. Paul wrote in one of his epistles "study to show yourself approved." It applies to the study of the scriptures and pastoral care but it applies everywhere else, too. You won't get anywhere if you "learn by doing" alone just as you won't get anywhere if you learn merely by "book learning". Fail to combine the two, fail to integrate all these (often by themselves) unhappy disciplines and you will fail to see the happy integration of many beautiful disciplines.
There may be many people who might tell you that you will benefit more from the study of Bach than enjoying Stevie Wonder; that there will be more benefit in listening to Mozart than listening to the Who but if you love the art of music and love it broadly this will be of more benefit to you then loving only the specialized things that you focus on.
The narrow furrows of detailed study are for when you are cultivating your particular specialty crop in your own garden. If you do not love gardening altogether then you don't have the opportunity and inclination to specialize. You will be more likely to write a decent fugue if you love a beautiful tune or even incline to study tunes you hate than if you just tell yourself, "I'm going to get good at writing fugues." The disposition of the mind and heart to explore are most important ... because it will be this that allows you to find the fun in the endless trial and error and dissatisfaction of slogging through subject after subject that don't work and the even more endless array of countersubjects and contrapunal lines that just don't work.