News for hackers. Stuff that matters.
Re:Public and private class fields by catpolice on Thursday December 13, 2018 @05:36PM (#18676779)
See my other comment: 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()'.

There are no comments on this comment yet.