When you create an interface, create it based on behavior, follow the -able standard, for example.
interface Comparable interface Enumerable interface Listable interface Talkable interface Thinkable
Or based on an object like
interface Comparator interface Enumerator interface List interface Human
And why?
UPDATE
This question is not about the naming convention (-strong suffix or I-prefix). It is about the intention of the interface design and its impact on: -
- flexibility
- complexity / simplicity
- maintainability
For example, if I need to implement various functions by executing a method, I can declare my class as
public class Man implements Talkable, Thinkable, Laughable public class Woman implements Talkable, Thinkable, Laughable
On the other hand, if we create an interface based on an object, we can use it as
public class Man implements Human public class Woman implements Human
And we can also use it for polymorphism purposes.
Human man = new Man();
source share