[AGENT++] SNMP classes design (SNMP++, SNMP4J, SNMP++.NET)

Frank Fock fock at agentpp.com
Fri Aug 13 00:34:46 CEST 2004


Hi Marek,

Marek Malowidzki wrote:

>Indeed, this is a question of taste. However, there are some differences
>between some PDU types, e.g., v1 trap or get-bulk.
>
>  
>
In SNMP4J there is a PDU class (which covers v2 PDUs), the PDUv1 class
which covers the v1 trap PDU, and the ScopedPDU class that covers
SNMPv3 scoped PDUs based on v2 PDUs.

>>If you want to add functionality for a special PDU type, you can write
>>an adapter class.
>>
>>What kind of functionality do you want to include in a PDU class?
>>    
>>
>
>No, I just mean some differences in the interface. The wire PDU format is
>indeed the same but the meaning of some fields is different (e.g.,
>get-bulk). The situation when you can call methods on some type that may be
>unrelevant (and it depends on the current PDU object's content) is not too
>elegant and generally violates the OO concept of a type interface (which
>should be constant). For the current Pdu class, the pdu-type works as a
>"union switch" that dynamically decides which part of the type's interface
>is relevant and which is not.
>
>  
>
In SNMP++, there is indeed only one PDU class. I agree that the SNMP4J
design is cleaner because it clearly separates the interfaces, except 
for GETBULK
which is in my opinion not worth to be separated in its own class. The 
opposite is
true, it would be too much overhead.

>Frank, I am not going to fight fiercely for the "pure OO design," I just
>asked for the reasons. What I understand from your explanations, you have
>  
>
That's why I tried to explain my reasons ;-)

>decided that defining separate PDU classes was not worth doing - mainly, due
>to small differences in the interface (and probably the differences in the
>v1 trap did not justify it). Thus, instead of defining a number of PDU
>classes, you decided to keep everything in a single class with addtional
>"pdu-type" discriminator (property). Is this right?
>  
>
In SNMP++ we have chosen the single PDU class design because
of the lack of dynamic type information in C++ (OK, theoretically one
could use RTTI but it seems not to be very portable and it increases
the code size).

Best regards,
Frank




More information about the AGENTPP mailing list