What is Programming?
Programming is writing a set of instructions to perform single or multiple tasks. In non-technical terms, it’s writing the solution to a problem.
Let's take a scenario. It’s 2 am as I write this course, and I am tired (the problem) and I am going to fix this by making a cup of coffee (solution). Here’s how I make my coffee.
- Go to the kitchen
- Get my cup out
- Get some coffee
- Measure the coffee
- Pour it in my French Press
- Boil some water
- Add the water
- Wait for 4 minutes
- Pour coffee in the cup
1 Problem. Infinite Solutions.
You could make your coffee in an espresso machine, or you could not make coffee at all! The same problem of feeling tired has multiple solutions. Coffee, Tea, Energy Shots, Power Naps. The options are near endless.
As a programmer you solve problems, and you do that in your way. It is about how you think the problem should be solved and if you see a logical error in your code, that’s not just a bug, it’s an error in the way you think.
Programming Coffee Making
Contrary to popular belief, writing code is the last part of programming. A good way to solve problems is by using the three-step approach:
- Identify the problem
- The Solution as a Flow Chart
- Write your code
Identify the problem
Problem: The human is tired and needs the energy to stay awake.
Solution: Get the human some coffee.
Solution as a Flow Chart
The next step involves how-to for the solution. What steps to follow? What do you require? How long and often should it run?
From top to bottom, the flowchart is extremely detailed about steps to follow to make a cup of coffee. If you’ve used Flow Builder before, this may seem familiar.
Writing the code
Now we have our detailed solution to the problem. Let’s write some code in plain English.
Just like flowcharts, programming is a step-by-step process.
First, let's gather our materials.
get cup = 1 unit; get coffee = 100 grams; get water = 500 ml; get pot; get timer; get frenchPress;
Now, let's place them on a table and boil the water:
put cup, frenchPress, pot on table; pour water(500 ml) in pot; start pot; set timer = 60 seconds;
After the timer is done, let's brew the coffee:
put coffee(100 grams) in frenchPress; pour 1/5 water from pot in frenchPress; set timer = 30 seconds; pour water from pot in frenchPress; set timer = 5 minutes;
Now that our coffee is ready, let's pour it in our cup and drink!
pour everything from frenchPress to cup; drink;
Now, our coffee is ready! The final code looks something like this:
get cup = 1 unit; get coffee = 100 grams; get water = 500 ml; get pot; get timer; get frenchPress; put cup, frenchPress, pot on table; pour water(500 ml) in pot; start pot; set timer = 60 seconds; put coffee(100 grams) in frenchPress; pour 1/5 water from pot in frenchPress; set timer = 30 seconds; pour water from pot in frenchPress; set timer = 5 minutes; pour everything from frenchPress to cup; drink;
Congratulations! You're now a programmer!
- Programming is writing your solutions to a problem.
- Following the three step process simplifies programming and problem solving.
- Learning to code is a marathon and not a sprint. It's okay to take your time.
The author has a terrible sleeping schedule