Thinking Like A programmer


Programming is not just about writing code, it's about solving problems. To become a successful programmer, you need to learn how to think like one. In this unit, you will learn the fundamental ways of thinking that programmers use to solve problems efficiently and effectively.

What Will You Learn

  • Understand the mindset of a programmer

  • Learn how to break down complex problems into smaller parts

  • Practice abstraction and generalization to make your code more flexible

  • Understand how to use patterns to solve problems

  • Learn how to think critically and logically

The Programmer's Mindset

Programmers approach problems differently than non-programmers. They see problems as a set of logical puzzles to solve, and their solutions are often elegant, efficient, and reusable. To think like a programmer, you need to develop this mindset.

  • Break down problems: Break the problem down into smaller, more manageable parts. This helps you to focus on one part of the problem at a time and make steady progress.

  • Abstraction and Generalization: Abstraction means removing unnecessary details and focusing on the essential parts of a problem. Generalization means creating a solution that can work for many similar problems, not just one specific case. These concepts help make your code more flexible and easier to maintain.

  • Use Patterns: Patterns are solutions to common problems. They help you to avoid reinventing the wheel and provide a tried-and-tested solution. You should learn to recognize patterns in the problems you are trying to solve and apply them where appropriate.

  • Think Critically and Logically: Programming requires logical and critical thinking. You need to analyze problems carefully, identify the root cause of the issue, and come up with a plan to solve it.

Problem-Solving Techniques

Here are some techniques to help you approach problems systematically:

  1. Understand the problem: Read the problem statement carefully, and make sure you understand it completely. If the problem is unclear, ask for clarification.

  2. Break it down: Divide the problem into smaller subproblems, and tackle each one individually. Start with the simplest subproblem, and work your way up.

  3. Visualize the problem: Draw a diagram, flowchart, or any other visual representation of the problem. This helps you to see the problem from different angles and identify potential solutions.

  4. Use Pseudocode: Write out the steps of the solution in plain language, without worrying about the specific programming language syntax. This helps you to flesh out the logic of the solution before you start writing code.

  5. Test your solution: After you've written your code, test it with a variety of inputs. Make sure it works correctly in all cases.

What are some techniques you can use to solve problems?

Programming is not about languages

  • The language you choose typically doesn't typically matter much (although I prefer to use Rust and Typescript)

  • Some will just make you feel stupider at the beginning, for example: Java public static void main (String[] args)

  • Or C++ when dealing with memory allocation, pointers and etc.

  • Some will just make you feel better earlier by abstracting away other things. name = 'Albert'

  • Some languages are better suited for certain types of purposes, but overall the language you choose typically doesn't matter much.

  • The hard part is that languages go in and out of fashion as paradigm shifts and trends happen

  • And the first one you learn will always be the hardest → so we’re here to help accelerate that process.

Computers are stupid...

The hard part about writing a computer program, isn't about trying to be as smart as the computer, it's about learning how to be as mind-numbingly stupid as a computer. - Andy Harris

Programming languages are simpler than human ones

While it may be scary to look at code for the first time, there's really not a lot of syntax to memorize compared to human languages.

Human languages have tens of thousands of words, with inconsistent syntax and stupid rules.

On the other hand, syntax in programming languages, you will learn, is painfully consistent

Most programming isn't about math

Unless you're going into data sciences, or writing 3d shaders, most of programming isn't about math, you'll rarely come across the need to do calculus.

What you'll quickly learn is that the kind of thinking you're doing - is the kind they were trying to teach you in math.

Programming is about solving problems

Programming is about being able to think logically and in abstract about systems and processes, inputs and outputs, and being able to solve problems using them.

Subunits

Problem Solving
Inputs, Outputs & Constraints
Thinking in Terms of Data
Algorithmic Thinking
Abstraction, Modularity, and Integration
Dealing with Failure
How to Get Unstuck
How to Google Problems
Using ChatGPT to Accelerate Learning