Staying focused

I find when im writing code I often get distracted by games and youtube, and id like to know what strategies/tactics you guys use to stay focused on a project.

Keeping in mind I never finished any of the projects I have started, I kinda want to know the solution as well…

1 Like

I usually find that working til I accomplish something or meeting a goal often works best. Not taking a break until that goal is accomplished. The skill lies in choosing goals that can be accomplished in a reasonable amount of time while not being too easy.

2 Likes

I know there is a program out there that’ll restrict distracting things like youtube, games, etc. cant remember the name of it.

Also Coffee + L-Theanine helps

i find that segmenting my PC into gaming/slacking, and actual work helps.
At home i have 2 stationary pc’s.
One running window$ for gaming with hardware for that need, and the other running older hardware, running linux, just for work.
Before i bought my gaming PC i used a VM to segment my work “PC”, so that when ever my VM was running, basically that was
bussiness.
And if i shut it down and returned to my window$ desktop all the gaming, and facebook tom’foolery was ok.
Basically if your PC isn’t setup to constantly spam you with noise…well there is no noise, and you can get some work done.
dont install steam on your work PC, i guess listening to youtube music is ok(We all need to be in the zone), ignore FB(just dont use facebook really),.
have some self discipline, but help it along with not working on your “gaming/desktop/daily” pc.
Most the problems you are explaining are by webpages etc. which are specifically designed to keep you trapped, and as a developer,
that’s not really where you wanna be.
You design your own environment, and therefor also which distractions are in it.
By now i got it down to that when at work i just check linkedin, and a news paper when ever i have run out of ideas and need to abstract abit from a problem.
Else i go grab a smoke, and usually a 5 min smoke break can solve a problem which usually takes hours of blindly flailing, so distractions can be good
at times.

3 Likes

I like @trexd answer, blocking websites just fights the symptoms but the reason often lies somewhere else.

I can stare at a wall for one hour straight, if I don’t like my current programming task. So you have to change it in your mind, make it smaller maybe. I’m still bad at this.

3 Likes

It helps to write down what you want to accomplish before starting and set a definite end time. For me I finish class at 2:50 pm and work until 5:00 pm at the library. During this time period I try to accomplish a small task that will aid me later on. Today I plan on making a small for-loop to scan through two ArrayLists (for the intention of multiplying later on).

I end up leaving school feeling proud and excited to tackle the next task when I get home. It takes me about 15 minutes to walk home, in which I think about how I’m going to implement that small thing I made into the bigger picture. When I get home I make sure to grab a quick bite to eat (no more than 10 minutes and without looking at my phone) and then I begin to code. I work for another couple of hours until dinner (and if I’m making good headway, I’ll continue working through dinner) after which I’ll work on my program until midnight while still trying to reach a goal or have my program accomplish something. After midnight hits I can be satisfied that I accomplished at least something without feeling guilty of being distracted. If you give into temptation, you’ll just end up hating yourself, with the vicious cycle of never feeling a sense of pride or accomplishment. Make small goals and work hard to reach them.

Acknowledge that even if you got absolutely nothing done that day, you worked hard without giving into temptation. I live for this satisfaction but it can be difficult to get into this mindset but know that it can be done with persistence.

3 Likes

Coffee, music - and a drawing / post-it scripted plan on what teh h*ck I am supposed to do.

But yes. Usually I end up doing the same…

As of others have said set small goals to accomplish everyday or whatever time schedule works for you. Our minds are actually better at completing a larger project in small tasks rather than trying to knock the entire scope in a long sitting.

2 Likes

I use the separate machines method and also kanbanflow to manage what I need to work on. It also has a useful timer (well, it is when you discipline yourself to use it).

https://kanbanflow.com/

The biggest problem I sometimes have is that many people seem to work in ‘manager time’ not ‘engineer time’. Manager time is when you day is broken down into 30 minute or 1 hour slots and engineer time is when it is broken down into half day or day slots. Manager time is for people who go from one meeting to the next and then have to just write up a few notes or update a project plan. Engineer time is for people who need to really settle into their work so they can get on and design or build something. Managers, working in ‘manager’ time don’t get this and will constantly interrupt engineers asking them to join yet another meeting or call, and then ask why progress is slow :stuck_out_tongue:

Back in my Chrome days I quickly threw together an extension to block websites, because I noticed I was clicking on twitter and YT when I didn’t even wanted to, it was a habit.

Since then I moved to firefox, and deleted twitter, 80% of my YT subs and 90% of my reddit subs, that kinda helped.


As for when you’re actually coding, what really helps is a list of things to do. I add // TODOs and // FIXMEs in my code and grep and awk them atm to see what I need to be working on. As well as have a simple TODO list on my desktop for more higher level stuff.

The trick seems to me to be just starting working, after that you don’t even want to stop, unless distracted by something (notifications, people, etc) or when you finish a feature and you distract/reward yourself with some web surfing. BTW this is why I don’t allow notifications from most web sites.

OFC, it’s easier said than done. Especially when you’re working on something you don’t wanna be working on.


To add to the // TODOs and shit. The reason I keep it in the code base rather than in some Trello board or whatever is to keep it close to the code. Code changes, and so does all the TODOs, FIXMEs and NOTEs, it’s easier to manage them like that, when they are near each other. You don’t need to sync your board/list with the code base. But higher level stuff can easily go into those, obviously.

Another good thing from that, IMO, is that VCS tracks that too, so if you roll back to previous version, or different feature branch, the TODOs and FIXMEs represent that local state.

Example of my little python script that groups output from grep:

1 Like

Thanks for the help guys :slight_smile:

Music works like a charm for me.
Its feel has to compatible with my mood, and (in most cases) crucially:
It must not have lyrics!

Most “focus” or “study” playlists on Spotify are decent all-round playlists. SoundCloud have some suitable playlists to, but I’d skim over the tracks to avoid anything that might adversely affect ones state of mind.


While in extreme moods, I might skimp on the “no lyrics” rule and prioritize qualities that either emotionally harmonize with, or influences my current emotions. Former to avoid cognitive dissonance. And latter to attain some desired mental state. This may include basically everything.


Here’s a bit of what I normally use to focus:

  • Random “Focus” or “Study” playlists
  • Random instrumental playlists

And some stuff I can remember having listened to when moody:

  • Any pre-“St. Anger” Metallica
  • My Little Pony (sometimes OST, other times mixes/influenced originals)
  • Anything Disney
  • Random collection of either heavy or death metal
  • '90s pop
  • etc.

No music is too stupid or bad if it works for you!
Though you might want to consider headphones to minimize judgmental stares :wink:

The best way to focus SQUIRREL!!!

Well, I’m not the guy to ask probably but I second the idea of music.
Specifically film scores are often perfect because they are almost purpose built.
Limitless and K-PAX have something that just works for me.

Close all browsers. Close Steam (actually quit the program), so your notifications about your friends don’t come up. Enter full screen or focus mode if your editor or IDE has that. Put on some quiet music, usually without lyrics.

That works for me. I generally go for a walk or something to clear my head of racing thoughts. It helps to visualize your objective or goal for the day too. You might get distracted at first, but if you practice you’ll get better at it. A lot of people refer to this as mindful mediation.

2 Likes

The irony of me reading this thread while at work…

I can’t help myself.

5 Likes

after you get experience its not that hard to keep from getting distracted, however you have to be working on a project you like. the right music helps ALOT to be truly “plugged in”. If you are working on something you enjoy, you wont even want to game at that moment

OP it is just basically called having discipline. Prioritize work over other things but keeping a healthy balance.

Sleep well, eat right, hydrate, and limit the caffeine to reasonable levels…

I second what others have said above. It is hard for anyone to focus on something they don’t want to do. I like to listen to music while I work to drown out distractions.

My biggest weakness. When I actually sleep normal amount of hours (it goes for both under- and oversleeping) and it the proper timeframe it indeed helps a lot!

1 Like