Coding for long time without losing focus!

I am 27 & interested in tech. I love to code but I feel intimidated when I see complex code or new topic.
While coding or learning / doing tutorials, I am not continue it for more than 10 minutes!
Every now and then, I will open Twitter or watch YouTube videos or read some news! Basically I’m getting distracted very often.
By doing this I am wasting lot of time!
How to overcome this? Any practice?


man its pretty common to lose your focus while coding the best way to overcome this i think you should read some self-help books like the habit, mindset and etc . those helped me lot building coding habits

1 Like

I feel same way when I see a complex code, but one thing I do is continue my lessons (plus search) and return to the same code to check if I can understand it better than before. More than often it is positive response.
For your distraction problem set a short target each time you code and don’t open another tab unless you are searching for relevant lesson.
And most importantly believe in yourself that you can do it.
Good Luck.

1 Like

I’d say that you took your first step in getting better. Concentration was also something tricky for me when I started working.

While coding or learning / doing tutorials, I am not continue it for more than 10 minutes!

Going from a small focus to a long strech of time is like wanting to do bodybuilding when you can’t do a push up.

If you can only focus 10 minutes, work around those 10 minutes. Set goals to increate those times by weeks.

Concentration is not an infinite resource
www youtube com/watch?v=a-KCZ1sghLY
[Thomas Frank](www youtube com/channel/UCG-KntY7aVnIGXYEBQvmBAQ) has a lot of videos regarding studing and get things done

Divide and conquer
Breakdown your tasks into smaller, unique and easy to acomplish tasks

Tackle the easiest first
Focus on acomplish the smallest, most easilly to acomplish task first to get you going. You need those victories to rewire your brain into a doer, not a todo kind of guy ;). Pro tip suggestion: Start with your bed, easiest task, 1+ on your done list

Focus on one task at the time
Don’t Jugle multiple tasks at the same time. Don’t multi tasking. Don’t listen to a podcast / youtube video while learning / thinking (those can be done while doing repetitive tasks that don’t require your maximum focus)
Bonus freecodecamp tip: Listen to the Code Radio www youtube com/watch?v=vAKtNV8KcWg

The genre would be instrumental downtempo music, which is relaxing and non-distracting. My grad school classmates and I had listened to thousands of hours of this type of music while studying and hadn’t gotten bored of it yet. So it seemed like a safe bet for a coding live stream as well.
medium freecodecamp org/introducing-24-7-freecodecamp-radio-chill-tunes-you-can-code-to-dbae61681cf0

More than looking great, it increases energy and focus as well
www forbes com/sites/jennifercohen/2012/05/08/6-ways-exercise-makes-you-smarter/#707a78fe305d

I love to code but I feel intimidated when I see complex code or new topic.

How do you eat an elephant? one bit at the time

Again. Start small. If you see something complex breakdown into small pieces until you can identify it’s individual, simple, pieces.

Treat yourself as an elite athlete. You only get better with practice so keep working towards your goals. It’s normal to feel intimitaded at first. With time and knowledge you will get a quicker grasp of code bases. Keep grinding those skills :slight_smile:


Best bit of advice I ever got on this? “Don’t code in a vacuum.”

When you get to the point where you’re working in a corporate environment, you’re going to be working as a team (usually), or you’ll be accountable to someone (often).

I see this as similar to “I made a new years resolution to hit the gym more, but I really can’t maintain motivation!” Look, I do yoga. But for a few years now, I have been getting very lax in my practice. Why? Because I’m not practicing with others. In the past, I’d been learning for a few years, then rolled into teaching yoga for about six years. I loved it. There were six or seven guys, our regular core, who would be out there five or six days a week. I kept going, because the team was counting on me. When I would feel like sitting back and having a beer, my buddy “YogaHobbit” would throw a flip-flop at me and bully me into doing what I knew I wanted to do.

This is the same. If you only ever code alone, it will be VERY hard to maintain focus, and to keep to milestones. Daily (or hourly) accountability to others, having a core sounding board who understand what you’re getting and where you’re getting hung up, those who will poke you along… we need that.

Are you married or in a relationship? Talk to your partner, explain that this is something you really want to do for yourself, and ask that they help keep you accountable. Set goals for yourself, and share them with your supports – family, or friends, or peers. When it comes to coding, peers are better able to understand your needs, but family support can keep you going forward.

Also, set yourself reasonable goals AND LIMITS. Don’t do an all-nighter because you think you’re “close on these last three challenges”. Set a four-hour block, but take periodic breaks to look up, look out the window. Limit yourself to six, maybe eight hours. If you do, getting time to code will not be burning you out.

If you find that you’re pulling up youtube and following links and getting distracted, step away from code. Your brain might need a break. It’s ok, it happens.

But maybe try forming a “study team” (what they call in prison a “car”). Get a group, three or four, where you’re all at a similar point in your development and can help keep each other motivated. Check in with your car a few times during the day, maybe challenge each other with coding lessons (personally, I love code katas – keep my brain nimble).


A lot of times when I see something new I think, holy cow that looks hard, and my brain just shuts down. The problem, Ive found, is I look at the big overall picture, and get overwhelmed, so what helps me is to break it down into smaller pieces. Really small, sometimes I take a terminology and just research that to figure out what that particular part means to understand what Im looking at better.

Like, my current thing…Big O notation. When I first came across it my brain was like…that looks like math! I was told there would be no math! Im done! (and I love math, go figure!) But…I kept going back to it, and figured out O(n) and O(1)…while doing interview practice, suddenly O(n^2) made sense…and I just decided, if its not one of those, then its probably O(log n), with no understanding of why. Just 2 days ago, several months after first learning about BIg O, I came across a resource where it finally clicked. I still have O(n log n) and O(2^n) to figure out, but…I have come a long…looong way, and it really started with breaking it down, not giving up and continuing to go back to it, reading diff resources, taking diff courses, reading diff books, reaching out and talking to people, and getting that tidbit that helps me understand. And the more I get it, the easier it is to stay focused cause it doesnt seem so impossible anymore.

Sooo yeah, thats just an example cause its the most current thing Im working through, but the key takeaway is, break things down into small pieces. Dont feel pressured to learn all or none…if something frustrates you, dont beat yourself up, just step away from it, move onto something else, and make it a point to keep going back to it until you get it.

Also, polomero …that really works. If Im having a hard time focusing, I’ll commit myself to spend 20m on it, and then reward myself with something fun for 10m, then go back to it another 20m. A lot of times, 5m seems like an eternity, but by the time my 20m are up, Im deep in and not ready to take a break yet…its funny how that happens.


I might sound like Tony Robbins but it helped me a lot, I am 28 and been learning for 2 months now, FCC few udemy course and meetup (usually local free learn to code classes), and the trick is why do you want it ? I would say stop thinking about immediate results but think what are you becoming and find a big big why are you doing It, let that "why " excite you and think about it all the time almost like you already have it and now you are going thru the motions only.

Why can be kids, better life , impact, no commute, bragging rights lol, prove it to yourself etc… Something personal

Keep it up

1 Like