Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Yes and no. I think the poster does make an interesting point.

If the parent class is instantiable - which is a code smell already but also very common and even encouraged by some OO evangelizing[1], as is the case for the "colored point" example - then he's right, the derived class which adds fields does admit more values than the parent class does (excluding child values).

[1] encouraged by the commonly heard advice: "if you don't like exactly what the class does, then derive from it and supply your own customizations". Ie. this is the use of inheritance for ad-hoc customization, as opposed to a design-first approach which would have the parent be abstract (which has its own problems of course such as requiring great foresight).



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: