mbonnin
06/15/2023, 7:59 AMinterface SomeInterface {
fun function1(param1: Param1)
fun function2(param2: Param2)
}
Can I somewhat evolve it without having to introduce a new interface name?
// Can I evolve it into somthing like this?
interface SomeInterface {
fun function3(param3: Param3)
fun function4(param4: Param4)
}
Maybe using default methods? Or do I need to deprecate and find a new name?andylamax
06/15/2023, 8:46 AMlouiscad
06/15/2023, 10:07 AMmbonnin
06/15/2023, 12:27 PMI would deprecate the old ones and add new onesHow would that work? If I do this:
interface SomeInterface {
@Deprecated("implement function3 instead")
fun function1(param1: Param1)
@Deprecated("implement function4 instead")
fun function2(param2: Param2)
fun function3(param3: Param3)
fun function4(param4: Param4)
}
Then all the implementers now need to implement all 4 functions which isn't greatmbonnin
06/15/2023, 12:29 PMinterface SomeInterface {
@Deprecated("implement function3 instead", DeprecationLevel.Error)
fun function1(param1: Param1) = error("implement function3 instead")
@Deprecated("implement function4 instead")
fun function2(param2: Param2) = error("implement function4 instead")
fun function3(param3: Param3)
fun function4(param4: Param4)
}
But I'm not 100% sure this workslouiscad
06/15/2023, 12:29 PMmbonnin
06/15/2023, 12:30 PMmbonnin
06/15/2023, 12:30 PMmbonnin
06/15/2023, 12:30 PMlouiscad
06/15/2023, 12:30 PMlouiscad
06/15/2023, 12:31 PMmbonnin
06/15/2023, 12:32 PMIs binary compatibility a big concern, or is only source compatibility an issue?At this point, I'm not 100% sure, I was mainly asking here in case there's a general admitted way to solve this issue. I'll dig
louiscad
06/15/2023, 12:34 PMmbonnin
06/15/2023, 12:35 PMmbonnin
06/15/2023, 12:35 PM@Throws(IOException::class)
fun fromJson(reader: JsonReader, customScalarAdapters: CustomScalarAdapters): T
where customScalarAdapters
is actually not needed as a parameterlouiscad
06/15/2023, 12:36 PMlouiscad
06/15/2023, 12:36 PMmbonnin
06/15/2023, 12:36 PMcustomScalarAdapters
without making it too painful to upgradembonnin
06/15/2023, 12:36 PMmbonnin
06/15/2023, 12:37 PMmbonnin
06/15/2023, 12:38 PMfun fromJson(reader: JsonReader, customScalarAdapters: CustomScalarAdapters): T
telling them to remove the last parameterlouiscad
06/15/2023, 12:38 PMlouiscad
06/15/2023, 12:38 PMlouiscad
06/15/2023, 12:39 PMlouiscad
06/15/2023, 12:39 PMmbonnin
06/15/2023, 12:40 PMmbonnin
06/15/2023, 12:41 PMinterface SomeInterface {
@Deprecated("use function3 ", level = DeprecationLevel.ERROR)
fun function1(param1: Int): Int = error("implement function3 instead")
}
class A: SomeInterface {
override fun function1(param1: Int): Int {
return 9
}
}
louiscad
06/15/2023, 12:42 PMlouiscad
06/15/2023, 12:42 PMlouiscad
06/15/2023, 12:42 PM