Many years ago when I was at uni they said to put a capital i (I) in front of interfaces. Is this still a convention because I see many interfaces that do not follow this.
There are two main naming conventions for interfaces in Java: no prefix or suffix for interfaces, ~Impl suffix for implementations, ~I prefix for interfaces.
Interface names should be capitalized like class names. Methods should be verbs, in mixed case with the first letter lowercase, with the first letter of each internal word capitalized.
Naming InterfacesInterfaces should be in the title case with the first letter of each separate word capitalized. In some cases, interfaces can be nouns as well when they present a family of classes e.g. List and Map .
Using an "I" prefix on interfaces is something COM founded (.NET just inherited this convention) and is not a standard in Java. Look at any of the JDK or other code developed by Sun and you won't see an I prefix. And it's not only Sun, most Java projects don't use the I prefix. Far from being a Java standard, the I prefix is an aberration adopted in some corners of the Java world though.
No, this is not convention. At least it isnt within the JDK. That said, if your shop has this as a convention, even though it might not be practice on the outside, I would suggest that you follow suit. Keeping consistency within a team is more important with regard to conventions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With