https://kotlinlang.org logo
Title
m

Mike

07/25/2019, 11:31 AM
Java never had it, either, other than a convention by some misguided people, and that some people still cling to. There shouldn't be a conflict between the name of the interface and the implementation, so the
I
prefix, or
Impl
suffix shouldn't be necessary. The interface should describe attributes/features in a general sense, and the implementation should be concrete. The only time they truly overlap is if there's only one implementation of the interface. Commonly seen when a project also uses IOC/DI.
👍 1
i

igor.wojda

07/25/2019, 12:37 PM
In practice it’s not all about contract (interface) and implementation (class) where you can easily came up with different names for both of them.
dependency inversion
is usually the case where
Impl
is the easiest way to go as interface serves a bit different purpose
m

Mike

07/25/2019, 1:02 PM
Minor correction. Dependency Injection. Strictly speaking, interfaces aren't required to use DI/IOC containers. They work fine with classes too. And most mocking frameworks can mock classes. Personally, I define the impl class and any public function is implicitly the contract. Now if it's used outside the module, I'll ensure I have interfaces, but not in one module. IMO it just increases work required to change something.
Inversion of Control is the other term/concept you wanted.