JAVA : How to name interface and implementor

Thomas Poignant
1 min readNov 4, 2016

So in my new project, every day I had question about naming things.

Here how I name my interfaces and implementor.

Interfaces :

  • Name your Interface what it is. Truck. Not ITruck because it isn't an ITruck it is a Truck.
  • The prefix hurts readability.
  • Don’t forget your interface is a type, so think about people who use this type, they don’t care to know if it is an Interface or an Object
  • You will never called an ObjectTruckClass because it is a class ?
  • All modern Java IDE’s mark Interfaces and Implementations and what not without this silly notation.
  • Using interfaces in clients is the standard best way to program, so interfaces names should be as short and pleasant as possible. Implementing classes should be uglier to discourage their use.

Implementor :

  • A good way to name implementor is to put the name of the implemention + the name of the Interface. So if we have a red truck our implementation should be RedTruck
  • The Impl suffix is just more noise as well.
  • Look to the Java standard library itself. Do you see IList, ArrayListImpl, LinkedListImpl
  • So when you have a situation where you have an Interface and a single Implementation that is not uniquely specialized from the Interface you probably don't need the Interface.

More on how to write great Java ☕

--

--