3 ms·
It's also interesting that this Rectangle/Square conundrum disappears when you remove mutatable state from the picture. I think it's usually best to model math
by sixbrx 15y ago
It's also interesting that this Rectangle/Square conundrum disappears when you remove mutatable state from the picture. I think it's usually best to model mathematical objects like these as simple value objects anyway, it's less surprising and more similar to how they are treated within mathematics itself.
- extension 15y agoThe conundrum is that you can't define a canonical inheritance relationship between square and rectangle or mammal and cat because the relationship depends entirely on how you are using these concepts in your program. Making them immutable may affect the relationship but does not make it canonical.