|Buy the entire series and save $12 (streaming) + $24 (download)!|
By Robert C. Martin, 1h 13m
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. "58 is like the luckiest number ever." according to Patrick on the Sponge Bob show.
And...Episode 58 is where we talk about the SOLID principles in Functional Programs.
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 Starwars. 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 Starwars 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 Starwars.
Anyway, Starwars 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?
By Robert C. Martin, 1h 7m
So, now it's time to get into the real guts of the Spacewar game. The game logic. There are quite a few fun and interesting topics we're going to cover.
These are a few of the questions I want to address:
1- There are 8,000 lines of code and 777 unit tests. What kind of coverage
does that represent? What was the testing strategy for GUI vs. Game Logic?
2- How does Clojure/spec help us keep our data types under control in a dynamically typed language? Are dynamically typed functional languages inherently weaker than statically typed functional languages? Or are there advantages to dynamic typing?
3- How do you manage to update complex state when you aren't allowed to change the state of any variables? Does this represent extra work?
4- Lazy evaluation is a powerful technique, but what kind of trouble can it get you into?
5- Where does this program go from here?
Prepare yourself for a really interesting deep technical dive as we walk through Spacewar -- Game Logic.
By Robert C. Martin, 1h 19m
OK, so now things are going to get really tech-y and geeky. We're going to talk about how all the GUI widgets work, how they are arranged in a hierarchy, and how they communicate events and respond to commands—all without mutating any state.
The data structures we'll use for this are going to quickly get very complicated. In order to avoid losing control of them, in a dynamically-typed language like Clojure, we're going to investigate the use of Clojure's type specification library
Oh boy, this functional programming stuff is fun! And so is playing Spacewar! Have you played it yet? You can play the Clojurescript version here.
By Robert C. Martin, 1h 27m
Spacewar! How cool is this? Did you ever think that you would be combing through the innards of a real-time, interactive video game written in Clojure? Well, you are now!
This game is thousands of lines of Clojure code. It has Klingons, Romulans, Starbases, and The Enterprise. You must save the Federation.
This episode and the two that follow will lead you through the design and implementation of a functional and interactive GUI program. It is 100% functional: no cheating, no mutated variables, and not even any Transactional Memory; just plain old functional programming.
You should probably follow along and grab the code. If you want to play the game, you can find the ClojureScript version in your web browser here.
By Robert C. Martin, 1h 7m
Do you remember Master Mind, that clever board game from the '80s, with the colored pegs? We implemented a version of it back in Episode 9. Well, in this episode we're implementing it again, but in Clojure.
In this episode we're going to walk through the code for this program, one commit at a time. You'll see how I used TDD to develop it. You'll see the functional design. You'll be amazed that there are no assignment statements. You'll be astounded at the data-flow style. And, in the end, you'll know the best strategy for winning Master Mind and will be able to amaze your friends.
So hop on board and let's get this train moving, because we're about to immerse ourselves in functional programming, Clojure, and Master Mind.
The code in this video can be found here. Make sure you walk through all the commits in sequence. There is much to learn by watching the progress of development.
By Robert C. Martin, 1h 10m
Welcome to our series on Functional Programming! Are you ready for some fun?
So, yeah, I'm sure you've heard all the fuss about functional programming recently. People are talking and arguing about combinators and monads and monoids and all kinds of other words that sound like they came out of some mathematical laboratory. Don't worry, that's not the direction we're going.
Oh, we might peek into the math lab from time to time, but this series is about doing, not about pontificating. (Well, usually, anyway.)
In this episode we're going to introduce the basics of FP. We'll talk about what it is, where it came from, how it relates to regular programming, and we'll even show you some code.
The code will be in Clojure. That's the language we'll be using for the most part, though we'll likely look at some F# from time to time.
So, get ready for a some loops and whirls, because this episode is likely to turn your brain a little sideways.