Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

putting a capital 'I' in front of JAVA interfaces [closed]

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.

like image 565
jax Avatar asked Feb 23 '10 03:02

jax


People also ask

Should interface name start with I in Java?

There are two main naming conventions for interfaces in Java: no prefix or suffix for interfaces, ~Impl suffix for implementations, ~I prefix for interfaces.

Should interfaces be capitalized?

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.

How do I name my interface?

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 .


2 Answers

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.

like image 192
Pascal Thivent Avatar answered Sep 20 '22 11:09

Pascal Thivent


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.

like image 30
akf Avatar answered Sep 22 '22 11:09

akf