Lecture 21
FP vs. OOP for the Expression Problem
+
Victory Lap
Programming Languages
UW CSE 341 - Winter 2021
Updates 2021-03-12
The Expression Problem
Breaking Things Down
Summary
“The Expression Problem”
FP Approach = “By Column”
See code!
OOP Approach = “By Row”
See code!
Punchline
Extensibility
???
???
FP Extensibility : Ops Easy, Variants Annoying
See code!
???
😃
???
😭
😭
😭
OOP Extensibility : Ops Annoying, Variants Easy
See code!
???
???
😭
😃
😭
😭
Extensibility is Difficult
Binary Operations and OOP’s “Double Dispatch”
Add
Example: add a String and a Rational
Add
Binary Operations Easy in FP
Add
See code!
Binary Operations Tricky in OOP
See code!
Double Dispatch
See code!
Takeaways
Victory Lap
First: THANK YOU!
341 Course Themes
What’s Next?
PL Courses @ UW
Other Resources
The End