Whether you are new to development or if you’ve been here since the “good old days”, everyone has run into problems they can’t figure out. Sometimes it’s as simple as missing your closing tag, a semicolon, or you could be struggling with a complex integration that you’re unfamiliar with. Whatever the problem may be, here are some of the best ways I’ve found to help find a solution.

How to ask for help

The best place to turn to first is the Internet. There are many resources that could address your exact problem. There is almost always a developer who has gone before you and struggled with your exact problem. If you can’t find a solution, you can ask for some! Post your questions on forums, like StackOverflow, with lots of details. The details are very important, as you want to make sure that whoever is helping you can accurately understand your problem. Developers are very collaborative, and it is a common goal to discover problems and provide solutions.

If you work with a team of developers, be sure to ask a team member to look over your code with you. Oftentimes, just explaining your code and your problem to another person will give you an idea on how to fix it. But if that’s not the case, your team member will be able to help point you in the right direction. This is often referred to as “pair programming,” and can be the most effective way to discover a solution quickly. Using pair programming you can bounce ideas off each other and try new things. The best practice for this type of programming is to “try, fail fast, and iterate”. There are no dumb ways to finding a solution. If you make your problem worse, you can always go back, so give your thoughts a try! If it fails, don’t be discouraged, and keep trying. Know that with each failure you are getting closer to finding your solution.

How to debug your code  

Debugging is a way to review your code line by line. There may be multiple reasons as to why your code is not working, and the only way to properly tell where the issues may lie is to comb the code line by line. There are many debugging plugins and software that can help with this process but the simplest way to debug is the print test. Print something to the console before the new feature, while using the new feature, and after the new feature and then run the code. An example would look like this:
console.log(“testing before feature”);

Function(){
console.log(“testing in feature”);

}

console.log(“testing after feature”);

 

If you don’t see one of the test results, you now know where the problem is. You can keep using this method to go line by line within your problem area.

5 Best practices to prevent mistakes  

Documentation  

To read and write code, documentation will prove to be a massive help to your learning and growth as a developer. There are many books and documentation on the languages that you will use. Also writing documentation on processes that are specific to your position or to your company will prove very helpful for the next time you have to do the same thing. This will help you avoid making similar mistakes.

Branch workflow

If you use repositories for your code base, be sure to use branches. This will help when you do testings, as you won’t hurt the master branch or cause your application/website to go down. Branches also allow other developers and team members to review code easily, as it is a separate branch. They can check out the branch you are working on and run it on their local machine to make sure that everything looks good, or be able to help debug your code remotely.

Run your code often  

When implementing small features, be sure to run your code often as you make changes. This will ensure that through each step of the process, if there is an error, you’ll know exactly where it is. The more code you write and implement in between tests, the more code you will need to debug when an error is found.

Slow down  

Sometimes there can be a lot of pressure to create that new feature before the deadline or fix an error before anyone notices. We obviously don’t want to be lazy or work slowly, but you can miss vital details if you move too quickly. If there’s an error on a project you haven’t worked on in awhile, refamiliarize yourself with the project and make sure you know where the issue is. Research to see if others may have had a similar issue, then continue in your process to fix the solution. It’s ok to take your time to fix the problem.

Take a walk  

There can be times where I haven’t stopped looking at my code for hours at a time and my brain just isn’t working like it used to. When this happens, I like to take a 15-minute walk around my neighborhood just to get me moving and to take my eyes off of a screen. If you don’t have the ability to take a walk, just take a break; make a snack, cuddle your dog, read a book, or lay down, just don’t fall asleep. Whatever your break is, be ready to come back after 15 minutes. In my experience I have felt refreshed and found my productivity improved.

Conclusion  

Hopefully just by going through some of these processes or using some of these practices, you can begin to think about your problems in a new light. If you are new to programming, just know you are not alone and there is an entire network of developers that are working alongside you and struggling with the exact same thing you are.