Distraction happens when you don't live in present. For me, I start observing things (As stated in book of How to Think like Sherlok Holmes). It makes me bind with present, focus, and remember things for long time. It also helps me to awake in boring meetings or discussions
–
articlestackApr 24 '13 at 11:21

Take a few moments to be still. Congratulate yourself for taking this
time for meditation practice. Begin this mindful check-in by feeling
into your body and mind and simply allowing any waves of thought,
emotion, or physical sensation to just be.

Perhaps this is the first break you’ve taken amidst a busy day. As
you begin to enter the world of being rather than doing, you may
notice the trajectory of the feelings that you’ve been carrying
within yourself.

There is no need to judge, analyze, or figure things out. Just allow
yourself to be in the here and now, amidst everything that is present
in this moment. Spend about three minutes simply checking in with
yourself in this way.

As you come to the end of this mindful check-in, again congratulate
yourself for doing this practice and directly contributing to your
health and well-being.

Take a look at Best Health article which shares some helpful tips on how to cope at work while depressed. It says accommodations for employees dealing with depression can be easy to access and are often very low in cost for the employer.

Also useful, a Forbes magazine article presents a checklist with things you need to do when dealing with depression at work.

We would all prefer to stop working. However unless you are independently wealthy, you have to work.

What I have to say is going to sound harsh to you. But you really need to think about it.

As someone who has battled depression for almost 40 years, I say to you, stop using it as an excuse. In over 30 years in the workforce, I have missed a total of a week due to depression. So things are harder than they were before the depression, big deal. Lots of people have challenges to overcome. You just keep on trying no matter what, persistance is the key. You fall, you get back up and try again. Giving up will ensure that your life is harder than it needs to be. Yes your performance will be degraded at first, so what! Accept that and move on and keep trying. Giving up will not help you in any way, shape, or form.

Yes I know it is hard to do things when you are depressed. Accept that during a big depressive episode, you will have to try harder to do things. It is the price of the disease. But you know what, someone with arthritis has to try harder to do things. Someone with with cerebral palsy has to try harder to things. Someone who just lost his spouse has to try harder to do things. Someone who just got his leg blown off in a terrorist attack has to try harder to do things. There are lots of people trying harder.

If you haven't gotten treatment, then do so. It is hard to get out of the cycle without some professional help and often you need medicine. Once the drugs have kicked in it gets easier to get out of bed in the morning, but it never goes away. You have to learn to cope and keep on going. The most helpful treatment I got was from a Behavioral Psychiatrist who taught me how to do things even when I didn't feel like it.

Depression is a disease. Millions of people successfully work with it as others successfully work with other chronic diseases. Dealing with it daily isn't easy, but life isn't easy. There are no quick fixes to chronic diseases, you have to have the intestinal fortitude to keep going even when it is painful or difficult or you don't want to. The single worst thing you can do is stay home being depressed. That will make your depression worse. It will make your life worse.

Now as to work, if you trust your boss, discuss the problem and what you are going to do about it. (Be careful, a bad boss may get worse if you tell him.) He may require you to take the medicine to keep your job or to see a therapist. In the US, he may even make an accommodation by restructuring your schedule to allow you to go to the therapist during the work day. It is also frustrating as a boss to watch someone's performance degrade for no apparent reason. So he may feel it is better to know what the situation is, so he can rearrange deadlines and schedules and help the person get the help they need.

I have found most bosses will be willing to help a good employee through something that will temporarily degrade their work if you discuss the problem openly and talk about how you are going to work around it and what you are doing to ensure the problem won't affect your work forever. After all if you were a manager, would you rather know that someone is going to take 20 hours to do something they used to be able to do in 10 due to a personal situation or would you rather be surprised when the deadline is missed?
You might even want to be assigned to easier work until the meds kick in. Give the tougher tasks to someone else for a bit. (I will warn you that people who are already poor performers will get less sympathy or slack from the boss. Why should he carry someone who won't be good even after the treatment kicks in?)

I have found the support from my bosses has been key to working through a major depressive episode (or other life issue like the loss of a spouse). They can't help unless they know. But I have also carefully chosen my bosses to be people that I could trust and I make sure to overperform when I am not in a depressive episode.

A developer has some options that other people don't have. If you don't have a policy of code review of all code in your office, then ask to make sure you code is reviewed while you are still in the major episode. You will probably catch some stuff that would have created problems that way. Or ask to spend some time pair programming, it is harder to just stare into space all day when you are pair programming.

It will take about a month or so for the meds to really kick in, so ask for a couple of months of grace before your performance will start to improve. Then if he gives you the slack, appreciate it and do your absolute best to justify his trust that you will be able to perform well again.

If this person needs to keep working I'd suggest (and this is just my experience, not clinically depressed, mind you, just really stressed out):

a. Break down the job into as many little tasks as possible (write them down or create a list online)
b. Check the tasks off as you go so you get a sense of accomplishment and momentum, even if they are just little things
c. Keep adding/editing the list
d. At the end of the day look back and appreciate what you've done

The key here for me has always been that when I get too stressed EVERYTHING seems virtually impossible to do. But little tasks, such as 1. Open email, 2. Respond to 1 email, 3. Run Report, etc. are much easier to take on then bigger projects. I've found that when I follow this strategy I get more done and it can often help take the stress off completely by making things seem achievable again.