Joe Soltzberg

44%
Flag icon
A minor disadvantage of the use of interfaces to emulate extensible enums is that implementations cannot be inherited from one enum type to another. If the implementation code does not rely on any state, it can be placed in the interface, using default implementations (Item 20). In the case of our Operation example, the logic to store and retrieve the symbol associated with an operation must be duplicated in BasicOperation and ExtendedOperation. In this case it doesn’t matter because very little code is duplicated. If there were a larger amount of shared functionality, you could encapsulate it ...more
Joe Soltzberg
That's why I wish it was easier to share base/abstract functionality between enums in situations like this
Effective Java
Rate this book
Clear rating
Open Preview