Re:Ask HN: What's the most simple thing you struggle to unde...
by zumu on Friday June 09, 2017 @03:00AM
(#14519623)
> if you are passing the same data (e.g. a record) between functions, doing stuff with it, and returning a new record then that should be a class that hangs on to that data with the methods being the functions that act on it.
But what if I don't want to mutate the source data? I always wind up writing classes that are largely immutable, and it seems wrong from an OOP perspective. Is there a correct way to marry immutable data with OOP?
This is especially true if your functions if you have a bunch of functions that do this and they aren't really useful for anything else.