• Why use enum instead of class?

    By Jonathan Cornaz 10 years ago

    Hello,

    I'm very confused because you have somme wierd declarations types:

    • org.opennft.domino.Database.Utils
    • org.openntf.domino.utils.Factory
    • org.openntf.domino.utils.DominoUtils
      And probably some more utility types.

    Theses types are enum types but aren't used as enum at all! They doesn't contains any enum value but only methods.

    Then why have you declared theses types as enum ?

    • By Jesse Gallagher 10 years ago

      It's a combination of a functional and a stylistic convention for a “bag of static methods” class. There's not too much difference between using a value-less enum and using a final class with a private constructor for general use. Once you get used to it, though, the enum pattern is cleaner and more explicit.

      • By Jonathan Cornaz 10 years ago

        Hello, thank for your response.

        Of course there's not too much difference between using a value-less enum and using a final class with a private constructor… Except, classes are what is provided for this purpose and enums are not…

        But thank you, I know what I was looking for. It's only a convention for declarations of utiliy classes.