Problem-Solving - For learning programmers
Tags: beginners, learning, programming, webdev
Published: 2023-08-11 06:48:22

Embarking on the path of coding can feel like stepping into an intricate labyrinth of languages, each with its rules and quirks. The journey to becoming a proficient programmer can be fraught with moments of overwhelming frustration and self-doubt. In these instances, it's crucial to pause, inhale deeply, and remind yourself that you're making progress, even when it seems elusive.

A transformative shift occurs when you recalibrate your perspective on programming. Amidst the intricate syntax and the array of languages, lies a fundamental truth: programming is, at its core, problem-solving. This can sometimes fade into the background as you delve into textbooks or wrestle with syntax intricacies. Yet, it remains the cornerstone upon which your entire programming career is constructed.

Beyond just being a skill, problem-solving assumes the form of a mindset, empowering programmers to conquer obstacles, spark innovation, and sculpt solutions. As you embark on your coding expedition, remember that every challenge you encounter isn't a roadblock; it's an opportunity to exercise the art of problem-solving and shape your coding journey.

Understanding how to solve a coding problem can, in many respects, be more important than fully understanding all the features of a programming language. It provides valuable insight into your thought processes and increases your ability to turn an idea into reality which many companies prefer to see in potential candidates as opposed to an encyclopedic knowledge of programming syntax.

Learning to problem solve is a perpetual adventure, an odyssey that spans years and continuously evolves. There exist dedicated courses that focus on problem-solving techniques and structures, which offer immense value and are worthwhile investments not only as a programmer but as a human making your way through life. I have, however, distilled a simplified approach that has proven useful in my own programming journey as both a reminder that I am doing ok and as a tool to increase the retention of pivotal programming information.

## Read The Problem

 That's right, my first and probably most valuable step is the simplest. Before I transferred to learning code, I found myself in fast-paced business operations roles. It was here I developed the habit of skim-reading, which was a necessity in that environment, to quickly take in the general idea, theme, outcome or results of information and apply it to the given situation.

The habit of rapid skimming, at least in the early stages of my own learning became a barrier to effective problem-solving. Of course, I had to find a different approach and embrace deliberate reading, a practice characterised by care, consideration, and patience.

The significance of this shift cannot be overstated at least in the early stages of learning. When faced with a coding challenge, the imperative is to do away with the hurried pace of skimming and instead immerse oneself in the problem's nuances. This investment of time and focus guarantees the absorption of the information at hand, setting the stage for a comprehensive understanding.

## Identify the problem and its parts


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9pbe1gqdx0xghfn2rwfu.png)

This step involves gaining a thorough comprehension of the problem's nature. There are many ways to do this depending on the problem with which you are presented. There is merit to multiple different approaches as long as you are finding meaning in the problem. I find a combination of the following to be best:

**Root Cause Analysis** - Root cause analysis is a useful tool for dissecting the origins of the problem and identifying fundamental triggers. But any systematic methodology that identifies the core reasons behind a problem is very useful in directing subsequent problem-solving strategies.

**Problem Statements** - A succinct problem statement is an essential product, it serves as a concise articulation of the challenge, ensuring clarity and a common understanding of the problem. This statement acts as a navigational beacon, guiding efforts and fostering coherent communication within a collaborative context. When working with Agile, you might see this in the form of Epics or User Stories.

**Giving Meaning to the Problem** - The rationale behind a problem's resolution, or evaluating why a problem should be addressed at all underscores the broader implications of its solution. This analysis bridges the gap between technical endeavour and real-world impact. In the early stages of learning this might be a much simpler task of validation to learn.

**Make one big problem several smaller problems** - the tactic of breaking down a complex problem into smaller components enhances systematic problem-solving. This modular deconstruction simplifies intricate issues, rendering them more manageable and facilitating step-by-step resolution.

## Research and Refine

The notion of leveraging established code, a practice particularly familiar to programmers, does extend itself to the learning process. During the journey of acquiring programming skills, there exists an understanding that existing solutions, proven effective, often outweigh the construction of novel ones. A valued approach to solving a problem involves delving into research, examining potential solutions to the given problem, and scrutinising how other practitioners have tackled similar challenges.

Engaging with the work of others prompts essential questions:

- What methodologies yielded success in their context?
- What were the pitfalls they encountered?
- What intrinsic factors contributed to the effectiveness of their approach?
- How did the culmination of their insights lead to the ultimate resolution?

The seeking of guidance is not a failing; rather, it's an acknowledgment of collective knowledge. In fact, the collaborative exchange of knowledge is a cornerstone that propels growth. However, in tandem with this, lies the responsibility whilst learning to not just take code and transplant it into your problem but to genuinely comprehend it.

## Pseudo code the Solution

As learners we often feel that we need to jump headfirst into the code, tapping away at the problem hoping to chance upon a revelation. This, more often than not, is actually holding a viable solution to the problem at arm's length. 
 
 Many companies during the interview process get their candidates to whiteboard the solution, actually, stand up, walk away from the laptop and brainstorm how they will solve the problem. This is a great exercise and one that learners should embrace wholeheartedly.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/orlmq0etpow1858daxl0.jpg)

As a learner, don't worry too much about the syntax, focus instead on the logic needed to tackle the problem. Visualising, or even vocalising the problem will start to inform the subsequent coding syntax. If you know your problem will need to look at a sentence to find all the vowels then you can start to form the basis for your program knowing you will need to identify what the vowels are, then how many letters are in the string, and then a way to determine if that letter is a vowel or not.

Focussing on Logic, in my opinion, is more valuable than syntax as you can apply logic to every problem in any language, finding the right syntax is a process of research.

## Implement and Reflect

Now that you've spent the majority of your time thinking about the problem, it's time to put it to work. As you get more advanced, a helpful practice is to first write test cases and then write your code to pass those tests but when you're just starting to learn, focus on understanding the problem and your solution to it. 
 
 Once you've run the code, it works and you've finished doing your victory dance it's time to reflect. Reflecting on your code solutions is a valuable practice that will serve you for the entirety of your career. How did I go and how can I do it better next time are the questions that might keep you up at night but they are also the ones that will drive improvement in your capabilities.

## Pratice, Practice… Practice!

You will hear this over and over ad nauseam but truly the only way to get better as a programmer is to program more. Remember that little side project you did at the start of your learning journey? Why don't you try it again later and see how you might do it differently, faster and with more confidence.

Practice the ABCs (Always Be Coding) and the steps above, this might help your learning and understanding of the problems you will face in your future as a programming legend.

Everyone learns differently, there is no right or wrong way to go about it but there is one consistency in that it takes time. The real question is how best to use that time. I for one fully believe that whilst learning, time is best spent understanding the why and how of the problem based on logic. Syntax is important but it's not helpful when it comes to implementing the solution.

Good luck and keep going.