I have come to realise that there are four different ways to compose.
The first is having the composition fully realized in your head before you set anything down on paper or in the studio. For me this renders the best musical composition and is usually the result of a happy, focussed and inspired mind. This is the most traditional method and is encouraged by classical music institutions.
The second method is more labour intensive and involves a partial idea that has to be nutted out at a piano or at the computer (usually thanks to a pressing deadline). For me this method can go either way…if I am quick enough it can sound inspired…alternatively, tired ears can produce a incomprehensible monster!
The third method is the most modern and most common. That is, having no real preconceived musical idea, and composing by jamming, riffing, experimenting, exploring happy accidents or simply letting the software dictate the musical ideas. Today, with the proliferation of experimental synth software, loops, sound generators, samplers, effects and a limitless number of tracks to record on, it is sometimes necessary for the musician to simply let the sounds themselves guide the creative process.
Obviously no method is exclusive and so the fourth method is simply a combination of all of the above.