[SNMP4J] SMIConstants: interface or class?

Beton, Richard richard.beton at roke.co.uk
Wed May 12 12:06:54 CEST 2004


Frank Fock wrote:

> I think the essential from our discussion about type-safe enumerations
> is that one should not suggest changes without pointing out what benefit
> that change would add to the software.


That's partly my fault for assuming people are familiar with Joshua
Bloch's book.  He makes his case for typesafe enumerations well IMO
(Item 21, pp104-114).  Although I accept there are several arguments
against them too, I don't accept the performance argument: typesafe
enumerations are just references to constant objects and as references
have similar runtime issues as primitive ints.  The benefits come from
having the compiler confirm that method parameters and return values
have a well-defined meaning; it is not possible to confuse values with
the full range of integers, as is the case when using ints for
enumerations.  Such an API is therefore much less ambiguous.

My 2p worth.  :-)

We can look forward to built-in typesafe enumerations in JDK1.5.

Rick :-)







-- 

Visit our website at www.roke.co.uk

Registered Office: Roke Manor Research Ltd, Siemens House, Oldbury, Bracknell,
Berkshire. RG12 8FZ

The information contained in this e-mail and any attachments is confidential to
Roke Manor Research Ltd and must not be passed to any third party without
permission. This communication is for information only and shall not create or
change any contractual relationship.




More information about the SNMP4J mailing list