I'm working on a network application that implements a custom protocol. I want to easily extend the application suportsupport over the protocol as it changes. Also, as the application extends, I might need to implement other protocols. So I need a design that allows flexible packet creation, based on protocol and variety of packets that it supports.
- The up-castringcasting from the base class to the derrivedderived class in
order to accesaccess member functions.
- With each new packet derrivedderived from
MBXGenericPacket, I'm forced to
encode and decode the MBX_Header in the
serialization/deserialization, thus causing code repetition.
- To get the required packet class from the factory, I need to first
extract the indentifieridentifier from the header and then pass it to the
CreatePacket() method. I think it will be nice if you could just
pass the PacketData to the factory, rather then decoding
information by yourself.
- The factory's purpose is to abstract the creation process of classes.
In my opinion, the packet identifiers should be encapsulated by the
factory, but that causes a lot of noise in the code, as you have
to type:
MBXPacketFactory::MBXPacket:: ...