banner
AgedCoffee

AgedCoffee

Practical Guide to Solving Difficult Problems

Title: Practical Guide to Solving Difficult Problems
Date: '2022-05-04'
Tags: ['Hackers and Painters', 'Blog Translation']
Draft: false
Summary: ''

Original Article: Practical Guide to Solving Hard Problems

Sometimes, I find myself needing to write some code, but I don't know how to do it. Have you ever experienced this? Here are the steps I take when facing difficulties. There are no major discoveries here, just hard-earned advice.

  1. Before writing any code, carefully think about the problem for a few weeks.
  2. Define the input and output of the function or class.
  3. Break down the functionality into multiple steps with clear goals. You may not know how to achieve these goals, but you can plan abstract implementation methods.
  4. Write detailed pseudocode steps, even if you don't know the specific implementation.
  5. Try implementing some simple steps and mentally simulate the implementation to build your confidence.
  6. Attempt to implement the difficult steps, breaking down the challenging parts into smaller steps as before. You will be surprised by your progress.
  7. After implementing around 80%, try finding existing solutions to help with the implementation (I personally practice this step as step 0).
  8. For particularly difficult problems where you have no ideas, search for related problems online and compare and learn from others' implementation solutions to improve your own implementation.
  9. If you still can't find any relevant practical help, try taking a break and clearing your mind. Inspiration may strike at unexpected times, like when taking a shower.

I believe these are steps that all programmers take, but it's also nice to say them out loud sometimes.

I particularly value function decomposition. Functions are powerful abstractions, not just for writing less code, but also for problem-solving.

Please don't misunderstand my use of the term "function" as something only favored by functional programmers. I mean any data transformer, from low-level lambdas to monolithic objects with stateful IO processing.

Thank you for reading! Now go solve those difficult problems!

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.