Andrew Gazelka
01/27/2019, 8:37 PMI
?nfrankel
01/27/2019, 8:40 PMAndrew Gazelka
01/27/2019, 8:41 PMnfrankel
01/27/2019, 8:44 PMAndrew Gazelka
01/27/2019, 8:45 PMI
then. Thanks.Davide Giuseppe Farella
01/27/2019, 9:15 PMTvChannel
and a MovieChannel
and they had to share an interface and well... We already have a Channel
class with CoroutinesI-
and -impl
i think the second one si better, since I would want to expose the interface, instead of the implementationnfrankel
01/27/2019, 9:32 PMI-
and -impl
means you cannot name your types properlyDominaezzz
01/27/2019, 10:08 PMVideoChannel
?nfrankel
01/27/2019, 10:16 PMChannel
?
We already have apackages are there to avoid name collisions avoiding duplicate types name is a good idea unless the alternative is worse -class with CoroutinesChannel
IChannel
louiscad
01/27/2019, 10:16 PMImpl
suffix, I strongly disagree, there's plenty of cases where a default implementation is provided, but only the interface of abstract class is exposed, and it's better that way, and there's no better name than specifying it's the implementation with that suffix. For example, there's the internal abstract ContinuationImpl
class in Kotlin/JVM stdlib.ghedeon
01/27/2019, 10:19 PMChannel
in one class, with ugly long import to differentiate between them, I'd vote in favor of VideoChannel
.nfrankel
01/27/2019, 10:20 PMghedeon
01/27/2019, 10:25 PMI/Impl
noise. I'm just not sure that "did you see that in Kotlin?" tells me anything. People are doing a lot of things that you won't see in SDK, and they are not necessarily wrong. Like, many teams prefer TheFoo
instead of FooTest
because it's easier to navigate in your code like this (search results are better separated).Davide Giuseppe Farella
01/27/2019, 10:33 PMRepositoryImpl
? Maybe that will appear only in 2 places in the code, the declaration and the instantiation, why should I make more confusion just because "if I use impl that means I can't find a better name"?louiscad
01/27/2019, 10:36 PMContinuationImpl
class, or is this name, with the Impl
suffix good enough?Davide Giuseppe Farella
01/27/2019, 10:38 PMimport as
? For which one? Which name should I chose for which of them? Should I remember that import name and use the same everywhere? Should I risk to import something with different name? Why can't I simply add an I-
?louiscad
01/27/2019, 10:49 PMI
prefix for interfaces is that interfaces are almost always part of a public API, where name matters much more than for Impl
suffix where it is usually in a private or internal class, where renaming doesn't break anything and is just an IDE action away. Because of that, you need to think at least twice about the reach of the API you are making and its use cases before settling with a name.hudsonb
01/27/2019, 11:09 PMghedeon
01/27/2019, 11:20 PMDefaultThing
is that it suggests that it might coexist with a few other NonDefault
implementations. But it's not true in cases where the only purpose of the interface was Dependency Inversion. The Repository example by @Davide Giuseppe Farella is pretty good. You don't have a hierarchy of repositories. In the ideal world, all you want is FooRepository
. but because of DI you name it FooRepositoryImpl
since the desired name is taken by the interface.Davide Giuseppe Farella
01/28/2019, 5:03 AMChannel
ursus
02/06/2019, 5:44 AM