To have a sharp mind, take care of your body
It's easy to think that you only need your brain to think clearly and be productive.
(Un)fortunately, we're not droids, and your ability to concentrate your attention and solve cognitive problems at work depends on your physiology.
Paying attention to your body and taking the time to keep it in good shape benefits your mind enormously. Thus, it will help you become not only an effective but also a healthy and happy developer, too.
Let's see how.
Get enough sleep
Sleeping has been considered for wimps and boring people. While you're sleeping, others are churning out code and working on their business, so you're getting left behind.
There are certainly situations where working more hours outside the 9-5 hours makes sense for the business's success; however, this should be the exception, not the norm.
Research shows not getting enough sleep has all kinds of health risks and reduces the length of your life, so the "I'll sleep when I'm dead" philosophy is a hazardous view.
On top of that, there is a sharp drop-off in productivity when your mind starts to tire.
Many moons ago, I worked at a startup where we had to pull a few all-nighters before customer demos. It seemed like torture – I couldn't wrap my head around the simplest conditionals, but at the same time, I would've had to debug thorny bugs.
It's absurd to pound on an exhausted brain, just as trying to cram theories into it the night before a university exam makes no sense.
Step away, get in your eight hours of sleep, and return refreshed and motivated the next day.
Sleep on it
A good night's sleep gives you a working mind to tackle complex problems, but that's not all.
While sleeping, your brain connects concepts gathered during the day, so you'll often find that the following morning, you have the solution to the problem you've been grappling with (or at least the seeds of it).
Take a walk
If it's still your working day and you don't have the luxury of sleeping several hours for your subconscious to solve a problem, stand up from your computer and take a walk.
It will get your creative juices flowing and get you out of a rabbit hole you might have been going down but which leads nowhere. Furthermore, you're moving your body, which you otherwise might not do during an intense workday.
Healthy body, healthy mind
The fact that a healthy body helps to have a healthy mind has been known since Ancient Rome.
If you take care of yourself by exercising regularly and eating well, your mind will be sharper, and your problem-solving will improve.
Besides, you feel much better after running, cycling, lifting weights, or doing any other form of physical exercise, so even if it didn't have any creativity benefits for your mind, it'd still be worth doing.
Admittedly, it's hard to get into the "exercise habit," so to increase your chances of going for that run or traveling to the gym, make it easy for you to do so. Prepare everything the night before so that when you wake up, you can be out the door in a few minutes without pausing to think whether you want to do this.
And on the days you don't feel like it, do it anyways.