Java interface and implementation naming (or “I” or “Impl”)

How do I name my interfaces and the classes that implement my interfaces? Through much research on the internet and my own gut feelings, this is what I reckon:

I never prefix my interfaces with “I”. The value of coding to interfaces is that you can swap out the implementation with minimal hassle. It means that instead of using implementation specific class names in your code, you use interface names instead – right? So, if I’m going to be using interface names everywhere, I don’t want to have to prefix everything with “I”. Coding to interfaces is a best practice, so I don’t need to explicitly state that I am doing it…It should just happen – which makes the “I” prefix redundant.

Furthermore, the “Impl” suffix is also redundant. Yes, indeed, your dilemma isn’t as simple as picking between the two. Firstly, “Impl” doesn’t translate. “Impl” in other languages has no meaning, and yes I’m talking about Polish and Scala. In Polish (according to Google translate), “implementation” is “realizacja” and in Scala, there are no interfaces. The closest thing Scala has to interfaces is traits, which can contain implementation specific code. So really, everything is Scala is an implementation, so why you use “Impl” suffix?

Secondly “Impl” is restrictive. What happens when you want to add another implementation of Foo? You gonna call it “FooImplImpl”? “AnotherFooImpl”? “FooImpl2″? I didn’t think so. Perhaps you were going to just call it “FooImpl” and put it in a different package…

Thirdly “Impl” doesn’t convey any meaning about what the implementation is. You wouldn’t create an “AnimalImpl” would you? You’d create a “Lion” or an “Elephant”. There is almost always something that distinguishes your implementation that you can use in the class name. Even if it is a long name, it doesn’t matter – you’re coding to interfaces (remember?), so you’re rarely going to see that class name.

Lastly, and probably most importantly – you still can’t think of a name? You don’t need an interface. If you really can’t think of a name, your class must be generic enough to not need an interface and you’re probably not going to have any other implementations. Your class methods become the interface contract, and that is that.

3,246 thoughts on “Java interface and implementation naming (or “I” or “Impl”)

  1. ruby fortune casinoenergy casino opinie wpЕ‚ata paysafecard kasyno blackjack online friends

  2. total casino na czym gracobstawiane przez graczy w ruletkД™ kasyno online szybkie wypЕ‚aty gry z bonusem bez depozytu

  3. 50 free spins vulkan vegaslegalne gry hazardowe online kasyno online szybkie wypЕ‚aty bonusy bez depozytu

  4. hot spot 777gra diamenty za darmo kasyno online blik ukЕ‚ad kart poker

  5. mr bet kasynototal kasyno bonus za rejestrację aktualne bonusy bez depozytu jak wpłacić pieniądze do bankomatu

  6. total casino bonus powitalnylol nie dziaЕ‚a kasyno online blik blackjack online 2 player

  7. Почему многие ищут ••Глаз Бога поиск по фото••? Потому что этот запрос стал одним из самых обсуждаемых. Перед использованием любых подобных инструментов важно убедиться что вы открыли ••Глаз Бога официальный бот••. глаз бога официальный телеграм

  8. gra za pieniД…dzefortuna kod bonusowy kasyno online szybkie wypЕ‚aty gry online za darmo kasyno

  9. sizzling hot deluxe demoblackjack online play free kasyno online szybkie wypЕ‚aty paysera bonus za rejestracje

  10. 10 zl za rejestracjepieniД…dze do zabawy najlepsze kasyno na telefon lucky dreams casino

  11. poker przez internetcrazy time history kasyno online szybkie wypЕ‚aty nowe kasyno online bonus bez depozytu

  12. ice casino no deposit bonus codeszmiana nicku riot najlepsze kasyno na telefon fc barcelona villarreal transmisja

  13. Here, instant cash prizes are collected by the fisherman wild with four needing to be collected to progress to the next round, retriggering the spins and awarding an incrementally increasing multiplier. Celebrate the winter season in style with Bigger Bass Blizzard Christmas Catch. The familiar splash of a hooked bass, but this time it’s wearing a Santa hat. The water isn’t murky lake green; it’s a frozen, crystalline blue, with snow dusting the edges of the reels. Pragmatic Play, in partnership with Reel Kingdom, didn’t reinvent the wheel here. Instead, they took one of their most successful engines—the Money Collect feature from the acclaimed Big Bass Bonanza series—and gave it a full-blown holiday makeover. Well reveal those casinos that have more generous limits than most, who knows what apps Zynga will produce for the iPhone and iPad-their ever popular Facebook games could all go mobile. Even though you are provided with a bonus, but you do not have to make a deposit before trying your hand. With a current Cashmo Casino 50 free spins offer, a secure site for its users.
    https://qna.habr.com/user/danielmarthy
    VN Video Editor provides users with two separate platforms to choose from, since it operates on macOS (download the app on the Mac App Store) as well as Windows (only with BlueStacks or another Android emulator). A desktop version of VN Video Editor provides extra editing tools and extra precision, however it retains the familiar mobile interface from the mobile app. The application performs efficiently between mobile devices and desktop computers, which lets users begin projects on their preferred device, then switch to another to finish them. SCALE VIDEO ACROSS TEAMS You might have already used VN Video Editor on your smartphone, but can you use it on your computer. Is VN Video Editor available for Windows? Is VN Video Editor for Mac? First impressions hit like a sucker punch, and with video editing apps, it’s all about the interface. You’re either clicking play in ten seconds or fumbling through menus like a rookie. InShot and VN throw down different vibes—one’s your chill buddy, the other’s a pro barking orders. Let’s see who’s got the edge.

  14. kasyno podobne do total casinobeep beep casino no deposit bonus kasyno online opinie beep beep casino 100zl

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>