Well done for completing today's course and challenges.
Now, one of the questions I often see students ask in the Q&A is, "Okay, so I've written this code,
this is my solution, but what's the right solution?"
And this is something that I want to talk about today.
And the really important thing for you to understand is that there is no right solution.
It is your solution.
It's about your thinking process and how you got there.
And when you're looking at the solution, when you're looking at your code, the most important thing
is not how fast does it run, or how few lines of code you use,
how efficient is the code.
To quote the godfather of computer programming, Donald Knuth, the guy who wrote The Art of Computer
Science and many other books that are super influential, super hard to understand, but what he says is
premature
optimization is not a great thing.
Don't try to make your code the most efficient as possible.
Instead, what you should aim for is readability.
So if another programmer comes along, if another student takes a look at your code, can they understand
what you did immediately without a lot of effort?
Well, if that's true, then you've succeeded.
That is the goal.
That is the bar that you should measure your code by. Now,
when I was in university and I had to write a lot of essays, especially during the year when I was
doing neuroscience as a degree, and when I first started writing essays, I thought, "You know what?
Good essays are ones with big words.
They're the ones with like, you know, the ones in the dictionary that like nobody ever uses."
And they had to be really complex.
It made me sound super smart.
But then I had a professor who was somebody who really was very influential in my life.
And he took one look at my essay and says,
"This is not how you write. You write so that other people understand what you're trying to say."
And it's actually the same thing with code. It's not about writing big words, it's not about shortening
your code to the shortest number of lines. It's about making your code expressive, readable and as easily
understood by as many people as possible.
Once you've gotten there, eventually, you know, once you become a senior developer, you'll have
your own ideas about style and syntax. But at this stage, optimize for readability.