|
|
|
|
|
by mikerichards
3640 days ago
|
|
In the mid-late 90s, when I started writing C++, I had a gut instinct that methods and data shouldn't be encapsulated together. I couldn't explain why though. Rich Hickey started clarifying it for me a little though. I can't dig up the interview he did, but he talked about classes being mini-DSLs and hindering reuse. That makes sense to me. I much prefer generic functions and multi-dispatch in Common Lisp's CLOS and the new language Stanza - it just seems more flexible. But generally, I want to think about data transformations and not little "machines" (objects) doing things things to their state internally. |
|
At the end of the day most programs can be thought of as state machines in some way. But it's often hard to split them into smaller state machines. The thing is, state is hard to compose if it's encapsulated :-)