I'm trying to break up a large class by using clas...
# announcements
k
I'm trying to break up a large class by using class delegates (to avoid suppressing Detekt's TooLargeClass error), but finding it's not possible to access variables in the container class. How do folks handle something like this? class ContainerClass : X by ClassDelegate() { val something } class ClassDelegate { fun blah { // want to use something here... } }
worked around it...create another class that holds the val something and send it through all the delegates by injecting it into ContainerClass. Something like: class ContainerClass(somethingHolder: SomethingHolder) : by ClassDelegate(somethingHolder) {}
g
out of curiosity, whats the use case for such a large class? Is this generated code?
k
Ancient Java code converted to kotlin. In this case, it was a massive repo class that the developers never bothered to group methods together with 😛