CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 2006
    Posts
    97

    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.
    Using .NET 2.0

  2. #2
    Join Date
    Jan 2002
    Location
    Scaro, UK
    Posts
    5,940

    Re: Protocol implementation advice

    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.
    www.pinvoker.com - PInvoker - the .NET PInvoke Interface Exporter for C++ Dlls.

  3. #3
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    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).

  4. #4
    Join Date
    Jul 2006
    Posts
    97

    Re: Protocol implementation advice

    Thank you for your responses
    Using .NET 2.0

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured