Hacker News new | ask | show | jobs
by jameskilton 5804 days ago
The article may be a bit on the drastic side, but I do agree with the conclusion that libraries should not treat everyone like idiots. Keep the users from shooting themselves in the foot, yes, but If someone is extending a class in a library, then they have the burden of doing it right. No developer can predict everything people will want to do with his/her library.
2 comments

But that doesn't directly address compatibility. Most people will expect some level of compatibility if the library was revised and having the guts of your interface hanging out isn't going to help.
It's precisely because you can't predict everything that people will do with your library that you limit its extensibility to only those situations you've designed for. That way, when you come out with the next version, you have a much higher expectation that you won't be breaking users' code, and those users will be far less upset at you.

It's not about treating everyone like idiots. It's about responsibly designing for and managing change over time.

And thus you should almost always make fields private, make methods non-virtual, make classes final / sealed, etc., except in those situations where you've carefully considered the ramifications and designed for them.