What To Do When You Don't Know What To Do
ᴋᴇᴠɪɴ ᴘᴏsᴛᴏɴ Sep 21
Getting into a nice flow is one of the greatest feelings as a developer. You put your headphones on and get lost in the code. Hours tick by as though they are minutes and you just enjoy the thrill of making the computer work for you. Features and bug-fixes are being crossed off left and right and at the end of the day, you marvel at your ability to make something happen out of nothing. You are awesome.
And then there are days when you can't get something to work, and you wonder how you even got hired.
It happens, and it happens to everyone. Everyone comes up against situations where they exhaust all their brain power and google-fu only to become more frustrated that they cannot figure it out. You are not alone.
So what do you do? You figure it out, that's what. You are a developer, solving problems is what you do!
Here are a few things I try to keep in mind:
1) Code Only Does What It Is Told To Do
When your code is doing something that it should not be doing, remember that you (or some other library or package you are using) told it to do that. Being able to debug your code is such a vital skill that a lot of developers take for granted. When I'm working on a complicated problem, I'll log everything I can so that I can make sure I know the state of my code at all times. Somewhere, someone has told the code to do the thing you think it shouldn't. You just have to find that somewhere.
2) Don't Assume Anything
I love it when someone asks me over to their desk to help look at a problem with them, and while explaining the problem they find the solution. This is a well known phenomenon in software engineering called rubber ducking. This works so often due to the fact that it forces you to prove your assumptions. Always go back through the scenario and make sure that everything you think to be a fact, is actually a fact. Don't trust that the name of the method or function is enough to give you the insight you need. Go see exactly what that function or method is actually doing.
3) Understand Your Integrations
Some of the more complicated issues I've encountered were a result of trying to integrate my code with another package or library. I know, you expect that thing to work like it says it should, but guess what? Mistake-prone humans much like you and me wrote that code, and no software is completely bug-free. Don't be afraid to go look at their code to see exactly what is happening. Sometimes you'll find that the issue wasn't in your code, it was in theirs! Next thing you know you are submitting a PR and contributing to the community. Which not only fixes your problem, but think of all the other developers that will never have to feel this pain because of your help.
4) Get a Fresh Perspective
Sometimes you need to step away for a while and let your brilliant subconscious figure out the problem for you. This happens all the time. Other times a fresh perspective means that you bring in someone else. Don't feel defeated when asking others for help. Software is complicated. Even the most simple bugs sometimes can slip through the cracks because well, let's face it, we are not robots. We are not perfect. So don't be ashamed to bring someone else over. It doesn't mean that you aren't capable of figuring this out. You have the maturity to realize that there is something that you are missing, and maybe someone else can find that something.
If none of these help, then I'd find a different profession. Totally kidding! These are just a few things that help me, and I hope they help you as well!