At work, we're creating a propritary JMS-like protocol. Today we talked about whether we should put messages and addressing info in the same object, or have a message object, and a seperate "envelope" object which holds the headers/addresses, and contains a message object,
I argued that by using envelopes and messages, we can use the composite
pattern, which would allow for embedding messages inside other messages. Someone else argued that you could get away with the same with just a single message class, that can contain other messages classes, along with their header/addressing info. Certainly this is true. But all implementations I've seen of the composite pattern use two classes, a composite object and a leaf, and not one class. What are the advantages and disadvantages of each implementation?
--Mark