There are times when you can't just wrap the code with some decorator to fix internal behavior.
So you have to go and copy the whole library into your project and make the tiny bits of changes that 'd be easily done if they were at least package-visible or protected, or the class weren't final.
Flow was the most annoying at this, I had to copy both Flow 0.12 back in the day, and also Flow 1.0-alpha into my project initially to fix its bugs, because most of its stuff just can't be fixed from the outside. Well, technically copying it and then putting it in a forked Github repository was the easiest solution, so there's that.
If the thing is fixing internal bugs, then that's how you should be doing it. Then send the fix to the maintainer. Don't subclass to fix behavior, as someone new to the project won't have any idea that you're using MyBaseClass instead of the one the library provides.
12
u/nhaarman Nov 26 '16
Instead, prefer composition over inheritance.