GithubHelp home page GithubHelp logo

pfwtfp-strategies-for-getting-unstuck's Introduction

Strategies for Getting Unstuck

Learning Goals

  • Identify strategies for getting unstuck

Introduction

It happens to all developers at some point: you're on a coding roll, and then you hit a rough patch. You start trying different solutions, but none of them work and you keep getting farther and farther off track. That's why it's useful to have a set of strategies for working through complicated issues and getting yourself unstuck.

Identify Strategies for Getting Unstuck

As we've talked about before, programming is, at its fundamental level, a process of solving problems. So, when our programming gets difficult or confusing, it usually helps us to think about generalized problem solving and how we can apply those techniques to our particular issue at hand. The behavior we should most seek to avoid is "trying stuff randomly." You wouldn't want a surgeon to take that approah when it comes to fixing one of your ailments, treat your code with a similar level of respect.

We have a few approaches to try when we get stuck. Let's take a look at each and how they apply when we're coding.

  1. Simplify the problem. Check your goal. Is it too complex? Does it try to solve multiple issues at the same time? You might be able to dismiss one or two or a few issues and solve a more straightforward version of the problem. One of the reasons adding subroutines is so powerful is because it forces the code to become simpler. This will make finding your way out a lot easier.

  2. Research similar problems and solutions. The internet is your friend. Search for examples of solutions trying to achieve the same goal as yours. While you obviously don't want to cut and paste code into your own solution (not only is this not going to increase your understanding, it probably won't fit your specific needs), looking at similar problems might suggest something new to try.

  3. Look at the problem from a different angle. This is an easy trap to fall into if you're working on a problem like others you've done before. You might instantly apply the same solution. But if anything is different or more complex, that same solution isn't going to work. Remember to take a step back and reconsider your assumptions about the way forward.

  4. Break the problem down into smaller parts. This is similar to our first approach, simplify the problem, but it's less about the problem itself than how we're working through it. Instead of trying to fix an entire app, can you focus on a block of code? A line of code? If fighting your way through too much code at once is what's getting stuck, you can adjust your context and take each piece one step at a time. Some developers escape this trap by starting with a clean slate and writing a simple program to do the simplest version of the task. They then "grow" their simple example's complexity until it get closer to the real problem and usually have their "A-ha!" moment in that process. This approach naturally joins to meet our following strategy as well.

  5. Start with a solution and solve the problem backwards. This is the approach to take if you know exactly what your result should be but aren't sure how to get there. Start at the end and determine what it would take to get there.

  6. Run Uphill: Do the "Hard Thing" You Don't Want to Do. When looking at code, we sometimes get the intuition or insight that the way the code is isn't the way it should be. Maybe the current code uses an Array and you're repeatedly doing a find() instead of a lookup (something Hashes are ideal for). In your heart of hearts, you know you should be using a Hash instead. Y0ou know you and every programming that will come after you would wish for a Hash...but going through and changing the code to be a Hash feels like too much work and it's not really the cause of my bug so, #yolo, leave the old code in. This strategy says "do the opposite." By making the code have less friction, it will free up your mind to be able to attack the bug.

Conclusion

If you find yourself stuck in a coding problem, following a methodology of problem solving will help suggest different approaches to try and help you get yourself unstuck.

Resources

pfwtfp-strategies-for-getting-unstuck's People

Contributors

sgharms avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.