I wrote a Kotlin based library to help reduce the Boilerplate code for ViewBinding in Android to bare necessity, making it easy to use and wrote my first article explaining the same. Give it a read, if the topic interests you. Any feedback is welcome and appreciated. Thanks.
Here is the link to the library.
n
Nikolay Puliaev
02/25/2021, 5:16 PM
Hi. Does it handles problem of view binding memory leaks?
c
Chetan Tuteja
02/25/2021, 5:26 PM
Yes @Nikolay Puliaev. The binding object is cleared after a view life cycle is destroyed. So I guess it does.
f
flosch
02/25/2021, 6:13 PM
But why create a baseclass for something that could be done via a delegate?
➕ 4
c
Chetan Tuteja
02/26/2021, 4:09 AM
@flosch
I completely understand that. You make a valid point. It is just that where I work we have a lot of abstract implementations for various scenarios with various base methods. For example, we a MediaFragment which can be used if we need to pick an image or video and compress it and return its file. So that is where my mind went. Thanks for the feedback though.
f
flosch
02/26/2021, 8:23 AM
Then I suggest you and your people at work should look into „composition over inheritance“. It will make your codebase much cleaner
c
Chetan Tuteja
02/26/2021, 8:25 AM
Yes, I will definitely take a look @flosch. From my POV the whole codebase needs revamp, but due to limited time we are working with what we have for now.