Before diving deep into learning how to code, it’s important to understand what computational thinking is. First, remember that humans and computers don’t think or act in the same way. Keeping that in mind, you will have to learn how a computer works. In this video, you’ll get an overview of computational thinking with some real-world examples of how it works so that you can start to understand how a computer thinks.
Before we dive straight into programming, let’s learn some of the fundamentals that will make your life easier from here on out. One of the first things to discuss is the difference between how computers and people solve problems because we each have our own strengths and weaknesses. Computers are fast, precise, and never get bored doing the same thing over and over again. Humans don’t think as fast as a computer does, but they’re smart, they’re innovative, and they’re constantly learning and able to improve from mistakes that they’ve made.
Humans vs Computers
A computer is fast but dumb. A human is slow but smart. To illustrate a difference, let’s look at an example. Let’s say a person wants to find a pack of spaghetti at the store. They’re going to be able to narrow it down quickly and find the aisle that contains pasta. Then they find the spaghetti and pick out a pack of spaghetti. This method of finding spaghetti comes from the experience of the person. They’ve been to grocery stores, they know what pasta is, they’ve shopped. They’re able to put that all together and quickly narrow down and find what they’re looking for at the store.
It doesn’t work this simply for computers. If a computer wanted to find a pack of spaghetti, it would first have to be trained on what spaghetti is. A simple way to do that would be to train it to look for a barcode for a specific brand of spaghetti. Then the computer could use that barcode to look for that specific pack of spaghetti. It would have to do so by looking at every item in the store, but that’s okay because the computer is fast. The speed and the power behind a computer will enable it to find that item in seconds, probably faster than we could walk and find the spaghetti ourselves.
It’s different, but it’s effective. What we learn from this example is that humans are constantly learning and improving from their experiences. We’re able to subconsciously create shortcuts that make our lives faster, learning from the environment around us. As programmers though, we have to set a lot of those shortcuts aside and learn to give the computer instructions in a way that it can process.
Computation Thinking in a Messenger App
That is what computational thinking is. It’s learning to solve problems the same way that a computer would solve problems. Computational thinking breaks down into three steps, decomposition, pattern recognition, and creating an algorithm. Let’s use these steps to design a simple messenger application. Decomposition is breaking a problem down into the smallest possible steps. We want to analyze what we want the computer to do and then come up with the smallest list possible to give to the computer.
To build our messenger app, we want to code something so the two computers can communicate over the internet. If we start to break this down, we come up with three basic steps for our application.
The user is going to type in a message and hit send.
That message is going to travel across the internet to the receiver’s computer.
The message is going to be rendered in our chat application and we’re going to read it, but we can break this down even further.
The computer is going to need a lot more information for step one. For step one, not only does it have to receive the message that’s typed in, it needs to know where to send that message and it has to know how to access the internet. That’s decomposition. When we break a problem down into its smallest steps, coding solutions don’t seem as daunting because we can tackle each step one at a time.
Pattern recognition comes next. We want to look for patterns in our code. By finding patterns, we can speed up our code by leveraging the speed that computers have at their disposal. A computer can do things 10,000 times a second, so every pattern allows us to group things together and ask the computer to do it over and over again efficiently. It may not seem like our messenger app has a lot of repetition, but it’s going to do the exact same thing every time any given user presses the send button.
A user may send thousands of messages and there may be tens of thousands or millions of users using that chat application. Hopefully we can see why recognizing the pattern and reusing it with the different texts that the user wants to send should be a part of our code.
For the third step, we want to put together an algorithm. An algorithm is a set of steps that’s going to produce the same output every time. To make our algorithm work, we’re going to break it down into smaller pieces.
First, we received some text input. Then we’re going to encode that text to be able to transfer it over the internet. And then lastly, we’re going to receive that text and display it on the other user’s machine, and we’re going to do that every time the user presses
enter. When it comes to creating algorithms, precision is key. Remember that an algorithm needs to produce the right results in every scenario.
Saying, “Don’t swim 30 minutes after eating,” may be good advice, but it’s not a good algorithm. If that was all you included in a computer algorithm, a computer would think it was fine to go swim 15 minutes after eating. It would be willing to run a marathon two minutes after eating. Why? Because those scenarios don’t match our exact algorithm. This is why being really specific is important when designing an algorithm.
A Recap of Computational Thinking
Decomposition, pattern recognition, and algorithms are how you think computationally. I’m going to give you a piece of advice that builds on this. This piece of advice is going to help you as you start your journey to become a programmer:
Learn to master the small steps. All large complex solutions are made up of many small steps. It could be eight, it could be 108, but it is the small steps combined together that help us solve larger, more complex problems.
This is the power of code. Combining many small things into all sorts of different chains can give us very different results. Take the smallest step seriously. Take these simple lessons seriously. Master them. It is the first step to being able to solve bigger and more complex things.
[cta id=”589″ vid=”0″]