alexhelder
03/21/2025, 12:09 AMclass Facade(
private val delegate:Delegate
) {
fun aaa(a,b,c,d) by delegate::bbb
}
class Delegate {
fun bbb(a,b,c,d) { ... }
}
If the number of arguments or functions increases, doing it manually like fun aaa(a,b,c,d,e,f) = delegate.bbb(a,b,c,d,e,f)
becomes tedious. This seems useful if a class needs to delegate to another class, only a subset of some interface, or does not want to implement the whole interface via class delegation.CLOVIS
03/21/2025, 8:25 AMinterface System {
fun x()
fun y(): String
}
class MockedSystem(
private val mockLogic: MockLogic,
) {
override fun x() by mockLogic::mock
override fun y() by mockLogic::mock
}
where MockLogic
could implement centrally the logic for stubbing etc.phldavies
03/21/2025, 9:10 AMCLOVIS
03/21/2025, 9:28 AMMockLogic.mock
needs to have overloads for all possible signatures, but that's fine)