DEV Community

Bo Vandersteene
Bo Vandersteene

Posted on

How to name you're interface

What's you're naming convention on implementing interfaces

You can do it on different ways:

example 1

interface Person { /**define you're method**/}

class PersonImpl implements Person { /**define you're method**/}
Enter fullscreen mode Exit fullscreen mode

example 2

interface IPerson { /**define you're method**/}

class Person implements IPerson { /**define you're method**/}
Enter fullscreen mode Exit fullscreen mode

example 3

interface IPerson { /**define you're method**/}

class PersonImpl implements IPerson { /**define you're method**/}
Enter fullscreen mode Exit fullscreen mode

this list of examples can be extended, feel free to share you're opinion

Top comments (1)

Collapse
 
tschaka1904 profile image
Maximilian Koch

When looking into books that teach OOO, I remember that the I for interface before the name was always taught as a (good) practice. In reality, I haven't come across any application where this naming pattern is actually used.

Usually the interface has a very generic name, Report.

interface Report { /**define you're method**/}

class AReport implements Report { /**define you're method**/}
class BReport implements Report { /**define you're method**/}

To my mind this seems sufficient and perfectly fine. That said, as long as you stay consistent with your naming strategy almost all patterns are fine.