How to decide when to look at other's code?

Hello, I am a beginner in writing code. During vacations, I really try my best to solve problems at my own pace but the problem is sometimes it takes me so much time to figure out how to solve a problem. Usually, when I am solving a problem I will try to write down what part I understood sometimes I also draw the problem to give myself a visual representation. After that, I will try to code what I understood. I will do this continuously until a eureka moment comes. I want to make the most out of every problem as much as possible by this I mean I want to be able to solve it quickly (so that I can move on to other problems) but not lose the challenging essence of it as well. Do you have any advice, like a set of criteria that I can consult, on when should I start getting ideas from other’s codes? Also, how do I deal with the frustration effectively if I continuously have to code and take shorter breaks? I really enjoy coding and I want to take care of this enthusiasm but I also want to make sure that mentally I am not too taxed. I am learning to code in C by the way. Thanks so much in advance.

Honestly, taking a long time with a problem is often a good idea. By working through it in phases, as you describe, and sometimes coming back to the same challenge over multiple sessions you are really exercising those problem solving skills. Learning how to work through a difficult problem is the hardest and most important parts of learning to program.

In terms of your original question of when to look at someone else’s solution, I suggest coming to a resource like this first. We don’t have many C experts here, but we have some. Community members like @JeremyLT will be happy to give you as much information as they think that you need to make it to the next step on your own. We are also a good resource just to bounce your thoughts off of when you wan to make sure you’re on the right track. There may be other supportive communities out there with a higher C population, but if not you are always welcome here.

1 Like

Howdy!

Honestly, stopping to think about how best to solve a problem before you touch the keyboard is a great habit to form. If I don’t take this time upfront, I often need to refactor my code in the future.

Like @ArielLeslie said, I recommend trying to create a solution yourself rather than looking at solutions. You learn very little from looking at code; it’s just how human brains work. As a developer, you’ll want to decide when to reuse code and when to write new code from scratch, but as a learner you want to write as much code as possible yourself.

2 Likes

Normal coding lifecycle would look like:

STEP 1: CODE
STEP 2: TEST
STEP 3: REFACTOR
STEP 4: GOTO STEP 2

Step 3 generally is a good time to see other solutions. From this point of view https://www.codewars.com is the best resource for this kind of flow

1 Like

Thanks a lot! Forums like this are really helping me adjust emotionally to the college program I chose. I do not have many acquaintances who are involved in the tech industry aside from the people I know at university and sometimes it can be hard to ask questions like this because everyone seems to be doing just fine :sob::sob: Recently, I’ve been having a lot of doubts in my learning process but this forum is starting to restore my confidence in it. Thanks :slight_smile:

I remember those days. If it’s any comfort, most of your peers are often just as confused or overwhelmed as you are (and you probably look like you’ve got it together to them).

1 Like

It’s a comfort to know that you (and others) also went through this and became successful in your craft. I really like what I am doing and it’s very challenging. Getting all these responses is helping me to appreciate the challenge instead of running away from it by procrastinating.

1 Like

I just signed up. Thank youuu so much!

It’s a solid bet that anyone you talk to here will have experienced teary eyed, screaming frustration and soul crushing self-doubt.

1 Like

I’m setting this as my wallpaper. I cannot thank you enough :slight_smile:

I like to give myself a certain amount of time for it … but that time goes down if I find myhself looping around the same circles.
Sunday coming home I had an issue w/ my bike chain; oh, my holiday flag was caught up in it. I wrestled the stuff out… and oh, now, the front part of the chain wasn’t on.
I thought it through, tried stuff, thought, tried… then walked to the bagel place and did the same and then finally figured out where I had to jam the chain past so it would loop around the links.
I realized that I was totally ready for the solution a good 15 minutes before I found it; if somebody’d come along and said “this needs to get past that,” Eureka! would have happened because it was the One Thing Missing.
I also made a point of re-working through the problem and re-visualizing it for the rest of the ride home. If I have to go somewhere for the answer, I do that even more.
I try to apply that principle to programming. If I’m just going to the answer and rolling right by … then it’s time to go for a bike ride anyway … (and half the time things do come up…)
but it is 60+ F outside in ILLINOIS so … it’s time to go for a bike ride even though I’m not even stuck right now…

1 Like

Took me a long time to figure out lots of my friends were just faking “just fine” (as I was) :wink:

1 Like