Some of these depend on the person / situation but here goes.
- Music or some other way to drown out ambient noise, invest in headphones, you'll be wearing them a lot and maybe for extended periods and they need to be comfy
- Make sure you know your tools (IDE, Debuggers, etc) and are comfortable with them. It helps a bunch when you at least know what you're doing there.
- Techniques that let you manage your own time (Pomodoro for example) are great in making sure you don't burn out on an issue or solutions you're trying to tackle.
- Always keep in mind that people smarter then yourself have gotten stuck on easier things then you're currently on. ;)
- When in doubt, ask other people, discuss, talk.
- Make sure you have a good chair / desk, I prefer to have the option to switch between standing / sitting for example.
- Get away from your desk, walk, stretch, get sunshine.
- Make sure you have a good keyboard.
- Try to let go of your mouse as much as possible it might be personal preference or your IDE that lets you use it a bunch but trust me, after 10+ years of working as a Full time Developer you WILL feel pains in your wrists eventually.
- Exercise outside of work.. when you're sitting for extended periods of time or even alternating between sitting you're still doing something we humans are not meant to do.
- Make sure you are hydrated.
Here are some simple tips for developers who wants to be productive:
- Don't think always about code, issue or problem. Only think when you're actually coding.
- While you're coding and face some problems or issues, don't deep dive at that time. Take a little break and come back to seat. Let's see how effectively you'll solve the problem.
- Make a schedule for extra activities like watching youtube, or any social media. If you keep doing such activity at an interval of time, then you'll loss your productivity. For eg. 1 hour at first hour of coding and half an hour of second half of coding.
- When you start coding, don't think or open any social media. Go deeply with your coding.
- Read code specific blog only if you're stuck with something that is relevant. Take 15 minutes of your time to know about such new thing that introduced while you were coding. And then take a 5 minutes break after reading. Just look around here and there.
- Do not hurry about your breakfast while you're working with some specific problem that might be finished after 5-15 minutes. Relax and finish your problem.
- At the off time (eg. when you at home), watch youtube channel that you're interested in.
- Take at least 8 hours of sleep. This will keep you fresh and will not ruin your work.
Know when to stop. Our brains, like any other muscles and body parts are subject to overuse and exhaustion. I found myself too many times being unproductive because I had gone for long periods of non-stop coding (and/or designing)...and honestly this is where bugs occur, where you make stupid mistakes, syntax typos and even worst. After a couple of hours stop, take a walk, go to the gym (this is what I do), do something else but reading or working on code.
Also, use the right tools, autocompletion saves hours of coding (and also stupid typos), git/versioning saves you from madness and going back in time when needed...and personally my tool of choice is VSCode which is constantly growing with dozens of tools that WILL make you more efficient with your time and code.
There are already a lot of great answers (all the points from Marius van Zundert are straight to the point), but there's one thing I'm surprised I haven't read: distractions. When you want/need to be productive, you need to be able to focus. Ambient noise is part of the problem (especially in open-space offices -_- ), but over the last years, I noticed many developers don't help themselves. Your phone is one of our worst enemies when it comes to being able to focus. Try some of these (depending on your own discipline and habits):
- block (almost all?) notifications when the phone is locked. My phone only vibrates (it's always in silent mode) for emergency-like calls. All the noisy notifications are only displayed when I manually unlock the phone (emails, twitters, slacks, ...) If you are on-call, Pagerduty is an obvious exception, but you get my point
- try to put your phone far from you (not in your pocket, not on your desk) and in silent mode. That'S another way to avoid the notification to break your focus
Try one of these simple rules and you should see a dramatic boost on your productivity, if you were guilty - like so many of us - of being distracted by notifications.
(on a similar note, I turn desktop notifications for emails or Slack only for important channels. Then I check the unread stuff from time to time, multiple times a day, so that I am not interrupted, but people don't have to wait for too long to get an answer)
- Understand the conditions that get you into the zone; and maximise the opportunity for those conditions to occur. eg. most devs I know need to organise their week to ensure they have big chunks of meeting-free time. Most need quiet and/or the right music. etc
- Understand the law of diminishing returns: very long hours don't work. There's a point where you are just writing absolute junk that you'll just have to refactor tomorrow.
- Time box debugging. If you've been staring at the same problem for two hours, go for a walk outside for a few minutes. If you've been staring at the same problem for a whole day, talk it through with a team mate.
- Make sure you understand why you're building something, not just the blunt what. Know what the company's strategy is, know what your team goals are, then you'll understand where your contribution fits in.
- Invest in ergonomics. Get a great chair, ergonomic keyboard, etc... whatever works for you.
- Have at least one non-coding hobby.
- Do some kind of exercise.
- When you take holidays, take holidays. No work email or chat, take a break from coding, let yourself decompress. Otherwise you're just spending your leave days for no reason and won't be fresh and ready when you officially go back.