polendina
11/15/2023, 1:04 PMKlitos Kyriacou
11/15/2023, 2:46 PMpackage a.b.c
interface MyInterface {
fun methodA()
fun methodB()
}
Class1.kt
package a.b.c
import a.b.c.internal.Class1MethodAImpl
import a.b.c.internal.Class1MethodBImpl
class Class1 : MyInterface {
fun methodA() = Class1MethodAImpl(...)
fun methodB() = Class1MethodBImpl(...)
}
Class1MethodAImpl.kt
package a.b.c.internal
fun Class1MethodAImpl(...) { TODO() }
Class1MethodBImpl.kt
package a.b.c.internal
fun Class1MethodBImpl(...) { TODO() }
I don't think you can totally avoid what you call "API pollution", but you can possibly minimize the risk using package naming.polendina
11/15/2023, 2:55 PMyou can possibly minimize the risk using package namingI indeed had to encapsulate the code using packages instead of class, with top-level properties/methods everywhere now. I naively tried to use extension functions with object singletons, then call them when overriding the interface method, but It sure resulted in a StackOverFlow
Daniel Pitts
11/15/2023, 3:55 PMDaniel Pitts
11/15/2023, 3:57 PMpolendina
12/01/2023, 10:44 PMIt could be that the abstraction you've chosen doesn't quite work cleanly with OOPIs there a way for me to tell whether that's the case?
Daniel Pitts
12/01/2023, 11:51 PMpolendina
12/02/2023, 4:16 AMDaniel Pitts
12/02/2023, 4:16 AM