Problem-solving - the most important skill you must learn as a junior programmer

Problem-solving is the skill you use when you have to do a task you aren't familiar with, but somehow you have to figure out the solution anyway.

Puzzles with this article's title
Magda Ehlers (Pexels -> Canva photos)

Are you a junior software engineer? Do you feel comfortable coding, or do you worry you don't know how to solve the problem?

In IT, we see many people scared of being an imposter. Do you feel like one sometimes? Do you pretend to know what to do while having no idea what you are doing?

Fear no more!

Problem-solving is the only skill differentiating a programmer from an imposter. You can learn it quickly, at home, and you don't need anyone's permission.

Let's do it!

What is problem-solving?

Problem-solving is the skill you use when you have to do a task you aren't familiar with, but you have to figure out the solution anyway.

Suppose you started working on a new task. You have to send an email to all subscribers using a template prepared by the graphic designer. Every subscriber should get a personalized message. The content depends on the items they have bought from your company.

Now, let's imagine you have no clue how to do it. What will you do?

Will you copy the content of the Jira ticket into Google Search and hope you find code to copy-paste?

I bet you, instinctively, feel this is not the best solution. Good. That makes you better than the programmer I worked with at my first programming job. He was copy-pasting task descriptions into Google Search and then copy-pasting the code he found back into the IDE. He got fired.

Don't worry. Nobody will fire you. He was a real imposter. You aren't.

What should we do when we have no clue how to finish a task?

Two people looking at the screen.
Photo by Sigmund on Unsplash

Focus on logic, not syntax

First, forget about the programming language for a while. Thinking about syntax or the code you have to write won't help you right now.

Eventually, you may find a library to handle the entire task automatically, but don't search for it yet.

First, we have to understand what we are supposed to achieve.

What would you do if you had to do it without code?

How will you know you succeeded?

When is your task finished? How will you know you have completed the work?

In our example, we must send emails. What are the expectations?

  • We send those emails to the right people.
  • The email's content uses the template.
  • The user's personalized content is correct.
  • Emails get delivered. Once.

Thinking about the success criteria helps us define the scope of the work, but we can also discover what automated tests we need to write to check whether the code works correctly.

Of course, we will need more than those four test cases. However, the list we have right now is a good starting point.

Illegible text in rectangles connected by lines
Photo by Hanna Morris on Unsplash

What needs to happen?

What are the steps required to achieve the goal? Now, we will use a fault-proof process of splitting the tasks into smaller elements. It's called the Mikado Method.

The name Mikado Method sounds fancy, but it's straightforward. We need to answer one question repeatedly: "What needs to happen?" We do it until we split the problem into tasks we know how to solve.

Let's look at the "send to the right people" requirement. What needs to happen?

We must know who should receive the email. Is it in the task description, or should we ask someone?

What else? We need to retrieve their data. From where? What data?

If we keep writing those questions and answers down, we'll get a tree of dependencies between the tasks. It may look like this:

Send the email to the right people

  Get the recipient's data

    Download the data from a SQL database

       Which one? What are the credentials?

       Write code to connect to the database

       Write code to retrieve the data

          All at once? Can we do it?

     What data do we need for the template?

       Get the template to check what you need

         Who prepared the template? Where can I find it?

  Decide who should receive the email

     Ask about the recipient selection criteria

       Figure out who can answer this question  

At some point, you will see a technical task on the list. In this case, we have things like "connect to the database" or "retrieve the data."

What can you do now?

Just google it

When you look at subtasks such as "connect to a SQL database," you can be sure you aren't the first person doing it.

You can find a solution online in a few minutes. I have to warn you. Most likely, you will find the wrong solution.

The web is full of code examples with security issues or code written by people who don't follow any good practices.

Don't copy the first code snippet you find.

Instead, find a few more snippets and try to understand what they are doing. If you notice differences, figure out why one author does something, and the others don't. Does their decision look like a good idea? If you don't know, you can ask another programmer on your team or search online.

Whatever you do, I suggest understanding the solution before you put the copy-pasted code into your program.

A broken ceramic plate
Photo by CHUTTERSNAP on Unsplash

What can go wrong?

What may prevent your code from running?

What if the database isn't responding? What if some data is missing? Will you send an email without some information? Will you ignore the problem and send the message with blank spots in the template?

Now, you should try to figure out how your code may break.

For every problem you see, repeat the Mikado Method to decide how you can prevent it.

What needs to happen when the database is unavailable? What needs to happen when the recipient's last name is missing? What will the result look like in this case? Is it acceptable?

Does it look like a lot of work? Programming usually consists of a large number of relatively simple yet time-consuming tasks. You will get used to that ;)