I think that there are two types of interfaces declared in general:
- a service description. This might be something like
CalculationService
. I don't think that methods getX
should be in this sort of interface, and certainly not setX
. They quite clearly imply implementation detail, which is not the job of this type of interface.
- a data model - exists solely to abstract out the implementation of data objects in the system. These might be used to aid in testing or just because some people as old as me remember the days when (for example) using a persistence framework tied you down to having a particular superclasss (i.e. you would choose to implement an interface in case you switched your persistence layer). I think that having JavaBean methods in this type of interface is entirely reasonable.
Note: the collections classes probably fit in to type #2
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…