I'm going to paraphrase here, but this is my distillation. OO and FP are basically inverse to one another:
- OO takes a problem and breaks it down by actors. You end up portioning functionality into all the various methods of the classes. If a group of objects all need to implement the same function, you put that in an interface.
- FP takes a problem and breaks it down by actions. Then you model your actors (the class hierarchy from OO) with a single data type (as in a tree). You pattern match over the data, and functions do different things based on the match - the type of actor.
No comments:
Post a Comment