4 ms·
I try to avoid classes as much as possible these days. I do mac/iOS app development, so I can't avoid it since I need them for defining UI components. However,
by allenu 6y ago
I try to avoid classes as much as possible these days. I do mac/iOS app development, so I can't avoid it since I need them for defining UI components. However, for non-UI code, I tend to use classes to compose separate pieces of state at very high level. The class acts as the "state machine" that updates these separate pieces of data that can only transform in a few explicit ways. Functions define transformations of these pieces state, so they're easy to comprehend and test. I didn't come up with it[1] and it's worked out really well for me.
[1] https://www.destroyallsoftware.com/screencasts/catalog/functional-core-imperative-shell https://www.destroyallsoftware.com/screencasts/catalog/funct...