Practice problems for learning how to code

I learned to program in the exact same fashion that the Coding Bootcamp Prep Course is set up. First, I read about a topic and tried to understand it. Then, I worked on a variety of practice problems that focused on the topics I had just read about. The practice problems had test cases that told me if my functions were correct, and I tried to make each function pass all the test cases that were given for a problem. Sometimes, the practice problems were easy and wanted me to do simple things like remove all the spaces from a string. Sometimes the problems were extremely hard to conceptualize and made me want to bang by head against the wall. But as I sat there, trying to remember syntax and get all of my test cases to pass, I kept wondering one thing:

"What did writing functions have to do with becoming a developer?"

I thought of web applications as complex systems that did things like let you order food, show you restaurant ratings, or allow you to book a hotel room. The benefit of being able to create individual functions or simple programs that passed some tests cases was completely lost on me.

Web Applications are Made up of Functions

Now that I've been a developer/engineer for almost 2 years, I can definitely see the benefit in being able to solve abstract problems by writing functions that can pass test cases. Web applications are complex systems, and they can do a lot of amazing things. But when you break a web application down into its many individual parts, a web application is made up of a bunch of functions each performing a specific task. For example, when a user tries to create an account on a website, you may have a function to make sure that the user's password is at least 6 characters long and contains at least one number. You may also have another function to make sure that the email is not already being used by another user. These are just two examples of many tasks that web applications need to perform. When you create a web application, you want the functions in your application to be simple and easy to read. That way, when you look at the code 6 months later, you know exactly what the functions are doing. Therefore, being able to create easy to read functions that can accomplish a task is essential to creating web applications.

When you write code for a web application, you often have test cases that the code will need to pass before you can deploy the code to production. The test cases are used to make sure your code does what you expect it to, just like the test cases your functions have to pass when you are first learning to program. Being able to make your functions pass test cases is important because it ensures your code does what it's expected to do, and when you're working with a large code base, you want to have some verification that your functions do what you think they do, even after you make changes.

Understanding Not Memorization

Learning to solve problems by writing functions is also a great way to hone your problem solving skills. Problem solving skills are essential to being a developer. Many new programmers approach the practice problems in prep courses and on sites like HackerRank as some thing to be memorized. They try to memorize the solutions to many algorithms and think that is how you learn to program.

In truth, memorizing the solutions to practice problems is a terrible way to learn to program. It doesn't teach you anything but how to solve that specific problem. Being a developer is about understanding how the code and computers work. It's also about solving many different problems. Consequently, when you do practice problems, you should try to understand how the code works, why a particular approach works for a specific problem, and if your solution didn't work, what went wrong with it.

Additionally, in programming, there are many ways to approach a problem. A problem may have 2 or more ways to write the code and pass all the test cases. Each way of writing the code can be just as 'correct' as the other ways. As you grow as a developer, your job will be to solve problems through code and explain why you chose a particular approach. When you approach your practice problems, if you focus on the code and improving your understanding of it, rather than memorizing solutions, not only will you be able to solve more problems in the future, but you will have the ability to solve the problem in multiple ways and explain why you chose one way over the other.

This article was written as part of the Coding Bootcamp Prep course. The course is dedicated to providing people of all skill levels the knowledge they need to get admitted to the country's top coding bootcamps.