Take the humble MouseEvent (alias java.awt.event.MouseEvent). The integer constants on MouseEvent include:
- BUTTON1
- BUTTON1_MASK
- BUTTON1_DOWN_MASK
BUTTON1_MASK is for use with getModifiers(). According to the JavaDocs, it's now recommended to use BUTTON1_DOWN_MASK which goes with getModifiersEx().
And, before you can say "Type-safe Enumeration", stop to ponder how many constants are needed to represent mouse buttons. How about none? Wouldn't a plain integer do just fine? How about a boolean function: event.buttonDown(int button)? OK, maybe it's useful to expose the bitmasking of the modifiers to the user, but the resulting mess argues that it would have been more useful not to.
Three different constants for a concept with all the complexity of mouse buttons? I sincerely hope someone was taken out and given an over-the-head turbo-wedgie for that one.
No comments:
Post a Comment