2 ms·
> integrate with it smoothly "Smoothly". For my 8 years with Java the only base classes that haven't been retroactively modified and thus breaking my inherited
by pdimitar 8y ago
> integrate with it smoothly
"Smoothly". For my 8 years with Java the only base classes that haven't been retroactively modified and thus breaking my inherited classes... were the ones in the stdlib. Everything else could and has been pulled under my feet, many times.
Everyone and their moms and dogs was like "hey, I think I can do better because I feel great this week!" and then 10 of us had to repair an object hierarchy of 200+ classes. I mean, everybody knows the CTO can't make a mistake, right?
And don't give me the "not in a disciplined team!" argument. Even disciplined teams make mistakes because often the author has no idea how many other colleagues use their base class.
I know the idea sounds too good to ever believe that it can't be true -- but yeah, it's not true.
> nothing pisses me off more than a "sealed" class that you can't inherit from
The "sealed" classes are meant to be semantic boundaries. Get an instance of it in your object and be done with it. What's so triggering about that?
- wvenable 8y agoBut you don't have an alternative. You subclassed things and someone broke the base class. It happens. But there is no other magic bullet (whether it be all functional programming or something else) that solves that problem. Most just make extension impossible, which isn't really better. > The "sealed" classes are meant to be semantic boundaries. The author of the "sealed" class definitely imagined all possible use cases and their code has absolutely no bugs, right?
- pdimitar 8y ago> The author of the "sealed" class definitely imagined all possible use cases and their code has absolutely no bugs, right? ...What? You can compose an instance of the sealed class in yours. You lose all brittleness from inheritance in the process. I've been coding OOP most of my life and I am working with FP for 2 years now -- composition never introduced a bug. Sure it's anecdotal but after a trend repeats itself 5+ times, you start observing patterns and making conclusions. Additionally, a number of FP languages offer Java-like and Go-like interfaces for an extra peace of mind.
- wvenable 8y ago> You can compose an instance of the sealed class in yours. But I can't subclass a sealed class to fix a bug or add a feature and pass it back into the framework to use. And yes, I have needed to do this otherwise I would never notice it was sealed in the first place.