4 ms·
See my other comment: https://news.ycombinator.com/item?id=18676680 https://news.ycombinator.com/item?id=18676680 Not breaking an API is one of the few cases w
by catpolice 8y ago
See my other comment: https://news.ycombinator.com/item?id=18676680 https://news.ycombinator.com/item?id=18676680
Not breaking an API is one of the few cases where they make sense, but it's sort of a hack that you have to settle for because of back-compatibility. But even then, you've already broken the API in a lot of cases. In your example, 'area' was a field you could read and potentially set. But by changing it to a derived value, code that sets it no longer makes any sense - what do you do with width and height if somebody sets the area? The underlying model changed in a way that broke the old API either way. So yeah, just change 'area' to 'getArea()'.