Re: Why switch/case in Packet::name??

Hi Atul,

You are right that name() should be a pure virtual. It was just a fast hack some long time ago when I needed to dump some debug info. name() should either be changed or removed if not needed anymore.

I chose fromRawData() in analogy to QByteArray::fromRawData but I am open to choosing a better name. Actuall today I even thought about creating a class PacketFactory for example, which will get its own header and source files. I felt the need for something like that earlier today when I wanted to include Packet.cpp for my quick and dirty CppUnit test project. I couldn’t just do so, because in Packet.cpp objects of all packet types are created, which means they also had to be compiled and liked even though I didn’t needed them at all.

Peter

atul wrote:Dear all

I think it would be easier to make name() a pure virtual …

So the compiler makes sure we provide a name ;-)

Switch/case is really against OO… I think Packet::fromRawData is fin as it is a factory ( we should think for a better name though for this method … )

What do you all think?

— cheers atul


Would you like to post a relpy?


This post is a reply to:
Why switch/case in Packet::name??
Dear all I think it would be easier to make name() a pure virtual ... So the compiler makes sure we provide a name ;-) Switch/case is really against OO... I think Packet::fromRawData (more...)

No follow-ups yet.