2 ms·
> almost exactly like something else, but with a difference Yeah, with all the hate that inheritance is getting these days, it is easy to forget that it models
by mpweiher 3y ago
> almost exactly like something else, but with a difference
Yeah, with all the hate that inheritance is getting these days, it is easy to forget that it models something extremely valuable: programming by difference.
Having something concrete and functioning as a base and then being able to say that your new thing is almost like this existing thing except for these small differences is very powerful.
- kazinator 3y agoI've found that inheritance works best if it is planned ahead, but that's not always how it was "sold" in OOP-promoting materials. Maybe the tacit idea here is that if you start using inheritance right in your design document, where OOP pseudo-code gives detailed requirements, then due to all that forward thinking and planning, good use of inheritance will pop out in the actual product. It's related to how reuse of any kind has to be planned for best results. Code not intended for reuse will not always reuse well, and that includes classes being reused via inheritance.