Hacker News new | ask | show | jobs
by snicker7 1933 days ago
> why should each class define and own its own methods?

State mutations. That's it. By ensuring that your data can only be mutated by a your API, it can never get "corrupted".

1 comments

Sure, there is a subset of behaviors for which this style makes sense, but it's just as well supported by simply defining your own functions alongside the struct.