Transcript from the "Feature Complexity" Lesson
>> What I'm going to ask everybody to do is to just adopt a beginner's mindset. And I want you for a moment to stop and imagine that you don't understand how to program at all. This is where we are going to approach feature complexity and how we start to think about code in general.
[00:00:33] And so in that, I want to introduce the four elements of programming. And this I would have to say if I had to stop and think about what is the most important thing that I've realized after 20 years of programming, this is it. This is my master thesis on programming and so carrying on with the Karate Kid theme, as I stopped and I looked back, and I've been programming for 20 years and I've written a lot, a lot, a lot of code.
[00:01:13] And quite frankly for probably the first 10 years I was not very good at all and, it's not that I wasn't good at all, as in bad. But I hadn't reached a level of proficiency, that I would kind of expect from a senior architect. And I started looking at this arc, of myself programming and how I learned things.
[00:01:41] And I realized that when I'm programming, I'm essentially doing the same four things over and over. There are four things somebody said when you program tell me what you do and I would say it's four things, that's it. I'm describing things, nouns, and performing actions, verbs, I'm making decisions, conditions and then repeating the iteration, that's it.
[00:02:23] When I program it's four things, nouns, verbs, conditions, and iterators. You can take the most complex code that I'm writing right now and by accomplishing, I would say the most sophisticated large scale code and everything that I'm doing can be distilled into these four elements. Nouns, verbs, or data structures, functions, conditionals and iterators and what's interesting about this, I arrived at this conclusion as I was kind of going on this rant with some of my apprentices and I was wanting them, to simplify their thinking and they were just making it way too complex.
[00:03:23] In a bit of frustration I kind of stamped my foot and I said, everything that I'm asking you to do, in fact, everything I know about programming. I can write on a single piece of paper and they're, really, challenge accepted, go and in the process of articulating it, this is where, I arrived at.
[00:03:41] These are, the four things, that, I'm doing, now what's interesting is, I quickly went down, I wrote this, articulated it, that at the same time, this lovely individual. I forget her name, off top my head but she wrote a book salt, fat, heat and acid or might be salt, fat, acid, heat but it's a great book on cooking.
[00:04:06] I think there seems to seem nosrat or I'll think of in a second but if anybody knows that they can paste the link in but she was talking about when she is cooking. That there are four fundamental things that you need to understand that if you understand salt, fat, acid, heat that you can essentially be effective in any kitchen in any context.
[00:04:37] And there's a really good like series on Netflix, she's amazing and highly check it out but to me was kind of this vindication of is it possible that this is true? And then salt, fat, acid he came out and I'm, well, if it's for cooking then certainly it can be for programming.
[00:04:59] Now, this is what's interesting about this, again, we're going back to the beginners mindset because I really want to start at nothing and I want to build up a foundation of how we think about programming. So I realized that I've been doing these things since I was a very, very small child.
[00:05:23] That as engineers, the things that we use to write software in these techniques we intuitively know as small children from the moment we can talk, and carry on a conversation and communicate. The problem is that we haven't trained ourselves to think in the level of precision required to communicate that in code.
[00:05:54] But the things that we're doing and we're doing every day without thinking about it, we've been doing for years. Let me prove this with a thought exercise. Let's pretend that lunch is served, and it's a healthy delicious lunch of donuts, which is probably my favorite lunch. And we have three trays of donuts, we have a blue tray, a green tray, and a yellow tray, okay, everybody, we can agree this what we're looking at.
[00:06:26] Now, if I said to you, or any small child, so imagine a five year old, do you see those trays of donuts, okay, do you see the green tray? On that tray, find all the donuts that have sprinkles on them, then bring them back to me. Is that confusing at all, probably not, pretty straightforward.
[00:06:58] If you see the tray of donut trace, don't go to the green tray find all the ones with sprinkles and bring them back to me. Now, what's interesting what I said in just human possible language, you can also articulate that in code. Trace.find, iterate over the tray, If it's green, return it and so now what you're seeing is an iterator and a condition.
[00:07:30] So I'm looking for the green tray then I'm taking the selected tray with the donuts and I'm filtering through. So I'm iterating and I'm saying if this doughnut has sprinkles put it in this new tray and return it. And then child.fetch sprinkled doughnuts, which by the way, both my children have this method and they're very good at it, 100% code coverage but we look at this.
[00:08:01] And the statement here, it makes a lot of sense, when we reframe it around nouns, verbs, conditions and iterators, we realize we can express something that is very easy for us to understand as human beings in code. And so this is why I'm pulling us back to this very foundation of, let's start ground zero.
[00:08:25] And let's build up on these concepts and let's make something.