DEV Community

Cover image for Why is Code & Problem Solving difficult to understand – And How to Make it Easier
Shivam Shukla
Shivam Shukla

Posted on

Why is Code & Problem Solving difficult to understand – And How to Make it Easier

Are you struggling to learn to code and problems solving? If you are, I want to help. So I have collected some tips from my personal experience to guide you so that you won't struggle unnecessarily again.‌‌

Use creativity, imagination, and code!

The most important thing is to understand what you are trying to build, and how to tell if you are taking steps in the right direction.

My advice on this is to use your imagination! Find a way to picture a system in your head. Picturing code as people (call them: “actors”) is a great way to do this. Imagine the people only behave how you tell them to. In code, an actor is usually most easily represented as a class instance. What does that person need to know to perform their duties? This tells you what properties the class would need.

How might they get confused? This tells you what edge cases to consider. If they need to ask for help what information would they need to provide to receive good help? This will be useful when designing error handling.

How might they become overwhelmed? Can they delegate or share their work efficiently?

As an example of how this might work imagine a queue of people. No person will know who everyone in the queue is, but each will know who the person in front of them is, and each person has a separate business to accomplish. Now you know the two properties a queue node needs the next node, and data. This is enough to start writing some code, and you can build from there.

This model might even help make it clear when a Queue would be useful in your code: just imagine the conditions under which people might need to wait or form a line.

Code written by someone who can picture how their code should work should ultimately be better code, even if many mistakes are made along the way.

Conclusion‌‌

Struggling is a good thing when it's productive. It makes you a better person or a better software developer. But don’t get me wrong – I am not telling you to struggle unnecessarily. ‌‌

No software developer is free from struggle when they code. But it is worse to struggle unnecessarily by learning with the wrong resources, or not asking for help from a mentor or someone who can help you whenever you are stuck.

Now, go get things done.

Top comments (0)