Szymon Jeziorski
03/27/2022, 11:55 AMabstract class SampleModifications {
protected fun helper1(...) [...]
protected fun SampleField.helper2(...) [...]
}
helpers usage:
SampleMapper.kt
object SampleMapper : SampleModifications() {
fun Sample.toSomethingElse() = [...] // calling helper1 from SampleModifications inside
[...]
}
extensions usage:
import [...].SampleMapper.toSomethingElse
[...]
sampleRepository.findByIdOrNull(id)?.toSomethingElse()
This works fine and does what I want but declaring abstract classes for such use case seems like overkill for me so wondering if I could achieve the same cleaner or maybe more idiomatic, how would you approach it?ildar.i [Android]
03/27/2022, 7:41 PMalex.krupa
04/02/2022, 8:43 AMinternal
, because then visibility impact isn't that big.
If not, and they're part of a monolithic or just a larger module, I'd merge both files into one, that way you can still have those shared private
helpers.