Overcoming problems while Coding

Break problems down and they become easier to tackle

It's more than likely that as you code you'll run into problems, some of them may be so common that a simple Google Search would resolve the issue, some may require you to check out programming communities like Stackoverflow and in the rarest of cases, you may not find answers anywhere but in the communities that work on the same thing you're working on.

As a developer, asides from solving problems with code, it is required of you to find solutions to niche problems not many people have encountered. The more specialized what you want to do is, the fewer people may be available who have answers or solutions.

In this article, I'll go through various ways developers like myself find solutions to problems, how to think about problems and ways to increase learning by finding problems.

First of all, in our everyday lives.. we tend to avoid stress or unnecessary use of effort to do things, but that is not always the case in the tech space.

The tenets we use in development are to KISS(Keep It Simple Stupid), DRY(Do Not Repeat Yourself) and generally to manage the complexity of your programs(you don't want to write code that nobody including yourself will understand down the line).

Try as you might in keeping it simple though, complexity comes with coding, how it is managed is down to each developer. The problems code can give and how to find answers have similarities but could be unique to what you're doing.

A problem I met when working on my Product Preview Card was that my CSS (SASS-scss) did not respond to media queries.

I used every valid media query syntax, but I could not get a responsive screen solution. In cases like this, developers usually have 3 choices:

  1. Google your problem.

  2. Check Stackoverflow.

  3. Check the community.

Googling your problems -

Believe it or not all software developers google problems they have when coding, you might've missed a semi-colon when working with javascript, using the wrong selector syntax when working with CSS or just to figure out the generally accepted way of doing something you open up google to see why your code isn't working.

Usually, you get a solution. If you don't though, it leads to scrolling through the documentation of what you're working on.

There are other ways of "googling for answers" these days as even language models like chatGPT can assist in coding problems, though you should always refer to the documentation or a source to back up the code or references it makes.

Asking on Stackoverflow -

My problem led me to Stackoverflow, and this is always a dice roll. You either get flamed for your "unoptimized code" or get led in the right direction.

Unfortunately, I got flamed for my code and no answer was given.

In truth, nobody owes you straight-up solutions to solving your code, but communities like that exist to do just that but sadly have fallen to trolls and unhelpful posts sometimes. which leads to the next best thing.

Asking the community -

After spending 2 days wondering why my media queries were not working, I decided to check out the Frontend Mentor Slack channel, and got an answer in no less than 5 minutes.

Surprise surprise, sass nesting increases css specificity so media queries will not be hit as the nested selectors and their properties take the highest precedence.

After getting my answer, I removed nesting, rewrote my code and voila, you get a responsive preview card component that adjusts to any resolution.

Screenshot

You won't know everything -

You can't know everything, in my five months of learning, I completed the freeCodeCamps Responsive Web Design Certification, JavaScript Data Structures and Algorithms Course and other minor certifications but that does not mean I know everything, far from it as there are multiple ways software is developed and you keep on learning, which is why your code from yesterday will not impress you today.

You'll always learn something that changes how you would have solved a previous issue. And that's the joy in tech, things don't get stale if you continue pushing the boundaries of what you know.

Thinking about problems -

No matter the problems you encounter while learning to code or even in the workplace, you'll need a certain mindset to approach problems.

Here are a few things to consider:

  1. What are you trying to do?

  2. What type of error is this?

  3. What steps led to the error?

  4. What is the debugger saying?

  5. Are there known solutions to solving your problem?

  6. Who or where can you go to that may have faced the same things?

Let's go through each of these:

What are you trying to do?

In software development, it's important to understand what you are trying to achieve before you start coding. This helps you to stay focused and prevents you from getting sidetracked by irrelevant issues. Clearly stating what you're trying to do will help you understand the requirements and constraints of the task at hand, and will ensure that your efforts are directed toward the desired outcome.

What type of error is this?

Errors in software development are inevitable, and it's important to be able to identify and categorize them. There are several types of errors in JavaScript, including syntax errors, runtime errors, and logical errors. Syntax errors occur when the code does not follow the correct grammar and structure of the language. Runtime errors occur when the code runs into an issue while executing, such as a reference error or a type error. Logical errors occur when the code runs without generating an error, but the output is not what was expected

What steps led to the error?

To fix an error, it's important to understand how it was caused. This often involves tracing back the steps that led to the error and identifying the point at which the problem arose. By understanding the steps that led to the error, you can better understand the root cause of the issue and how to resolve it.

What is the debugger saying?

A debugger is a tool that helps you find and fix errors in your code. It can be used to step through the code line by line, inspect variables, and evaluate expressions. The debugger provides information about the error, such as the line number and error message. This information is invaluable in determining the root cause of the issue and finding a solution.

Are there known solutions to solving your problem?

Before attempting to fix an error, it's a good idea to check if there are any known solutions to the problem. This can be done by conducting a web search or checking forums and communities that specialize in the technology you are using. This can save you time and effort, as someone else may have already faced and solved the same issue.

Who or where can you go to that may have faced the same things?

There are many resources available to help you resolve errors in software development. These include forums, communities, and support channels such as Stack Overflow, Reddit, and GitHub. You can also reach out to colleagues or other developers who may have faced the same issue, as they can provide valuable insights and guidance. By working with others, you can learn from their experiences and get the support you need to solve the problem.

Finally, remember to ride the waves, difficulties will come and being good at finding solutions will make you stand out from everyone else.