Technology & Leadership

Technology & Leadership

solved Rubik’s cube

3 Tips To Solve Coding Problems Like an Expert

Ask the questions, do root cause analysis, and more

How can I get better at solving problems? I understand?JavaScript?now, but I can’t really solve problems or understand any complicated?JavaScript code,” asked me recently young developer on my contact list.

Problem-solving is a critical element of our careers because writing great code is a creative art, and to be a great developer, you need to be a creative problem solver.

“The biggest mistake I see new programmers make is focusing on learning syntax instead of learning how to solve problems.” - V. Anton Spraul

Sometimes we get afraid or uncomfortable when faced with a difficult challenge and wish it would go away. We may feel that we have to come up with an answer and get frustrated when we’re not sure how to find it.

Being confronted with a problem is an opportunity to improve ourselves, rather than a problem in itself. And although I see that this skill comes with time and practice, I’ve also a firm belief that we don’t need to wait for years to master it. I’ve worked with many junior developers who were better problems solver than their older fellows.

Luckily for us, there are plenty of methods available to solve whatever difficulties come at us. In this article, I’ll break down three techniques that help us untangle any complication like an expert. But before we start, let’s see the differences between how an expert and a novice tackle problems.

Expert Thinking vs. Novice Thinking

“Most people avoid problems or deal with them haphazardly.?Great thinkers and leaders look for problems and have frameworks that help them solve problems better.”?—?Michael Simmons


In his article “Thought,” professor Robert J. Sternberg explained the secret — according to research by the American psychologists Herbert A. Simon, Robert Glaser, and Micheline Chi, among others — that makes experts more effective than novices in problem-solving endeavors.

Experts

  1. They have large and rich schemata, organized representations of things or events that guide someone’s thoughts and actions. These schemata are highly interconnected in a way that lets retrieving one piece of information easily lead to the retrieval of another piece.
  2. They use a?working-forward strategy.
  3. They?monitor their problem-solving?carefully.
  4. They possess far greater knowledge in specific domains.
  5. They allocate more time to determining how to represent a problem —?the preparatory stages of problem-solving?— and spend less time executing solutions.
  6. Their thought reveals more complex and sophisticated representations of problems.
  7. They are more successful in?reaching appropriate?solutions.

Novices

  1. They use a working-backward strategy: They begin by focusing on the goal.
  2. They don’t monitor their problem-solving carefully.
  3. They spend relatively more of their time executing solutions.
  4. They are less successful in reaching appropriate solutions.

“… way of working backward is to start with straight with a hypothesis. If your problem is to increase profitability, you might decide that you’ll want to look at ways to increase revenues. Because increasing revenues can lead to higher profitability. Fine.?But what about decreasing costs? Shouldn’t you understand the various ways that you can achieve your goal before deciding on the way to do so?” — Arnaud Chevallier, “Work forward in solving problems, not backward

Below are some techniques used by experts to have a good problem definition and effectively apply a working-forward strategy to solve?it.

1.?Asking Questions

If you’ve tried this method before, then you may have noticed that sometimes the?problem is not the problem itself but the absence of the right question.

In her book,?The Architecture of All Abundance, author Lenedra J. Carroll introduced a simple technique called “The 12 What Elses” for getting out of a problem:

When?brainstorming solutions,?ask yourself a question and generate 12 answers to that problem.?Then take one answer, turn it into a question, and generate 12 more answers. Repeat until you can see a clear solution.

By following this way, you can generate a questions-answers map, which is helpful to test your hypotheses and structure how to solve complex problems:

Problem-solving: questions-answers map to test your hypotheses

Let’s practice and see examples of striking questions that could put you on the right path toward a solution:

  1. Problem:?My web app has?poor performance.
  2. →?Question 1:?Why? Answer: because of the big size of the bundle.
  3. →?Question 2:?If the bundle’s size is the reason, then why is the performance not terrible directly after I deploy the app and start running it, instead of after a few hours of using it? Answer: It’s more likely that the reason is something else. It could be memory leaks and garbage collection issues.
  4. →?Question 2:?Which part of my app is responsible for these memory leaks? Answer: Let’s find it out by using?Chrome DevTools.
  5. Problem:?I don’t do a daily workout.
  6. →?Question 1:?Why? Answer: It’s because I don’t find the time for it with my full-time, stressful job.
  7. →?Question 2:?If my job is the reason, then why I don’t do it on the weekend and on holidays? Answer: The reason is procrastination and not lack of time.
  8. →?Question 3:?How do I overcome procrastination?
  9. Problem:?I want to have high self-esteem.
  10. →?Questions:?“What will high self-esteem help you achieve? What would you be able to do (or do better) if you suddenly had super high self-esteem? I ask this question because, in the end, the best way to cultivate high self-esteem is by acting as though you already have it.” —?Nick Wignall, 7 Ways to Build High Self-Esteem

2. Root Cause Analysis

Before starting to solve a problem,?we need to understand the root cause first. Often we find out after many trials that the cause differs from what we’ve expected.

By eliminating the false reasons, we’ll have a?better definition?of our problem and become closer to the solution.?The root cause analysis methods help to avoid wasting time and energy in trying to make a fix in the wrong place.

Root Cause Analysis Method
Example of a root cause analysis method

In programming, we use the following practices, among others, as root cause analysis when we have to fix a bug:

  • Determine in which environment the problem is noticed — you may need to ask the end users about it — and try to reproduce it in the same and different environments to have a good understanding of it.
  • Interactive debugging.
  • Log-file analysis.
  • Unit and integration test.
  • Analyze the bundle file?if the problem is related to the web performance.

3. Use Spectrum Thinking Instead of Binary Thinking

Binary thinking?is always putting things in terms of two alternatives?that are usually mutually exclusive. Sometimes this is valid; other times, though, it is a mistaken simplification.

Binary thinking

The antithesis of binary thinking is?spectrum thinking. It considers?multiple options, alternatives, and possibilities. It allows us to switch from operating in just a state of either/or, to a realm where both, between, other, or neither exist.

Spectrum thinking

By cultivating spectrum thinking in yourself, you’ll be much more?creative, and you’ll be amazed by the number of different approaches and solutions you could apply to fix a bug, a conflict, or to come out with an implementation or with a?design?that satisfies the end client.

Here is an example:

  • Binary:?I have to open a dialog or a new page with an arrow back to show the view for updating an order.
  • Spectrum (other):?I can open the view — that allows the user to update an order — in a new tab without a need to close the view displaying the whole list of orders.
  • Spectrum (both & other):?I can implement a dynamic template with 3 layout styles and give the user the possibility to configure it and choose if they want to open the update view in a dialog, a new page with an arrow back, or a new tab. (Here is an implementation of this solution:?How to Build an App With 3 Layout Styles)

Binary and spectrum thinking have their pros and cons and can be paired together. More details about these two patterns and many examples about how to apply them are available in this article: “How Spectrum Thinking Improves Our Communication, Decision-Making, and Problem-Solving Skills.”

Final Thought

Problem-solving is an issue that reaches outside the narrow context of?software development.?This skill highly depends on our mindset and attitude, and to get better at it, the first step to start with is to be more curious than frustrated about the challenge facing us.

“A problem is like a curve in the road. Take it right and you’ll find yourself in good shape for the straightaway that follows. Take it too fast and you may not be in as good shape.” —?Tim Hicks
Sea Cliff Bridge?—?A problem is like a curve in the road. Take it right and you’ll find yourself in good shape for the straightaway that follows. Take it too fast and you may not be in as good shape.

Originally published at Better Programming.

Want more?

???? I write about engineering, technology, and leadership for a community of smart, curious people.?Join my email newsletter for exclusive access?or sign up for Medium?here.

Did you know?

You can get my Udemy video course FOR FREE with the following link (available until October 23, 2022, Coupon: 4443E48C99E79CB072FB): How to Identify, Diagnose, and Fix Memory Leaks in Web Apps

要查看或添加评论,请登录

社区洞察

其他会员也浏览了