How to name you're interface

reibo_bo profile image Bo Vandersteene ・1 min read

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**/}

example 2

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

class Person implements IPerson { /**define you're method**/}

example 3

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

class PersonImpl implements IPerson { /**define you're method**/}

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


Editor guide
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.