Functional Programming and SOLID
Clean Code: Functional Programming, Episode 58
Robert "Uncle Bob" Martin
1 hour 13 minutes • 1.10GB • Mar 2019
Fifty-eight. 58 is 2*29 and is the sum of the first seven prime numbers: 2+3+5+7+11+13+17. 58 is the year that Sputnik was launched. "Fifty-eight is like, the luckiest number ever," according to Patrick on SpongeBob SquarePants.
And...Episode 58 is where we talk about the SOLID principles in Functional Programs.
YAY!
In the last episode—Episode 57 (which is 3*19 and the atomic number of Lanthanum (not to be confused with gold-pressed Latinum))—I told you we were done with Space Wars. I lied. Well, no, I didn't exactly lie. I was wrong, but I didn't know it at the time.
You see, at the time I knew I wanted to do an episode on the SOLID principles in functional programming. I just didn't know I was going to be using Space Wars as the example. But then, as I started writing the episode, it became clear to me that there were loads and loads of SOLID principle conformance and violation in Space Wars.
Anyway, Space Wars it is. One more time. And this time we're going to look at it from the point of view of:
SRP - The Single Responsibility Principle,
OCP - The Open-Closed Principle,
LSP - The Liskov Substitution Principle,
ISP - The Interface Segregation Principle, and
DIP - The Dependency Inversion Principle.
As an aside, did you know that twenty years ago there was a guy on USENET who accused me of being a racist for using the word "segregation" in the ISP_?_