News for hackers. Stuff that matters.
Re:Ask HN: What's the most simple thing you struggle to unde... by ferdterguson on Thursday June 08, 2017 @11:23PM (#14518962)
The one sentence answer from a FP perspective, imo, is that 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.

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.

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?