Protocol implementation advice
Hello,
I am currently writing an application that is using an already existing protocol to send/receive data. The protocol is text based, there are like 20 different commands that can have multiple arguments.
Now I was wondering what is the best way to implement this in C#. Currently I have it all working with a single Message class, where I set the arguments using a ListDictionary and then build a string to send. However, I've seen some protocol implementations, that use a different class for every different message in the protocol. It seems attractive, but doesn't it add some overhead to the application? The messages won't be sent more often than every 2 seconds.
I'd like to ask what's you opinion on this matter? What are the advantages and disadvantages between these two designs?
Thanks in advance. :)
Re: Protocol implementation advice
Quote:
I've seen some protocol implementations, that use a different class for every different message in the protocol
That's the route I'd go down.
The advantages of writing every message in a protocol far outweight lumping all the protocol handling into one (huge) class.
Advantages like :
(1) Separation of code into easily understandable units, rather than one huge class.
(2) Easier to maintain than one huge class.
(3) Less likely to suffer from 'spagetti code' syndrome.
(4) It supports unit testing of each message.
...i.e. all the advantages of having an application made up of small, well designed objects rather than a few very large objects.
Darwen.
Re: Protocol implementation advice
As far as the extra overhead.
If the extra overhead doesn't measurably impact performance, then go for the design that is easier to maintain (i.e, separate classes).
Re: Protocol implementation advice
Thank you for your responses :)