Interfaces should generally be similar in convention to classnames, since often classes become clear interface candidates over time. Interfaces that are planned from the beginning can end with ..able, but that is not mandatory.
Some interface names that never caught on
Interface name |
Why |
---|---|
CanApprove |
The interface might have a “canApprove” method in it but there is no reason to name the interface the same way. This was probably written in the days when people created hundreds of interfaces in an application before writing a line of code. Perhaps should be named “Approvable”. |
StorageIface |
Despite being pushed heavily by advocates, the Iface suffix never became common. |
Speedy |
Speedy is a description of ability, not function. |
IacceptCommand |
The early convention of prefixing interfaces with 'I' has been dropped industry-wide. It also confuses camel case capitalization. |
RecordExportingFunctions |
Describes what kind of methods the interface contains, not the ability that the interface represents. Might be better named “Exportable”. |
DocumentFascade |
Incorrect spelling of Facade. If you know you can't spell, get someone to review your names or those who use your interface every day will curse you every time they write it. Or choose a word you can spell. |
Some interface names that everybody loved.
Variable |
Why |
---|---|
Approvable |
Implies in a neat, short word that the implementer supports approval logic. |
Storable |
Clearly the implementing class can be written and reloaded. |
CustomerSearchDao |
It is a Data Access Object interface for providing access to customer searching. This follows a standard naming convention and pattern where there are usually two implementations; a mock interface and a real interface. |
RecordExporter |
Describes the ability that the interface represents. Any class that implements this interface is a “Record Exporter” |
Tip: For new interfaces that are not derived from a concrete class; if the interface content is clear but you are having trouble deciding on an interface name then there is a chance that the project is a victim of over-engineering and you are the engineer. The purpose of an interface is to define the operations needed for a pattern of use, which usually requires enough code to see a clear pattern (or a design pattern to follow). Don't create interfaces simply because you think they make you look smart.