share
Stack OverflowDepression after coding?
[+8] [10] csharpbaby
[2009-10-15 09:31:27]
[ self-improvement ]
[ http://stackoverflow.com/questions/1571252/depression-after-coding ] [DELETED]

This happens to me most of the time. After I have finished writing some code, I get this feeling that it is not the optimum code or there is a better way of writing the same code. Perhaps someone else is more intelligent than me who can implement the same alogrithm in more smarter way.

This sometimes let me down and sometimes leads to depression. Is it just me or has anybody else felt this same way? What do you do in such case?

Update: I do not know why this question was closed? I still think it is relevant to 'programming'. Does anyone thing this question is not as good as 'What’s your favorite “programmer” cartoon?'. Sorry but a bit dissaponited now.

From the FAQ linked on every page: "Avoid asking questions that [...] require extended discussion.", which is exactly what this question required. Further SO is not a support group. Thirdly if by some chance this was appropriate, it should be (and should have been from the start) Community Wiki. - dmckee
[+10] [2009-10-15 09:34:27] djna [ACCEPTED]

Whenever I look at my old code I always find things I would improve.

At the point of initial completion I in fact tend to be happy, because my Unit tests pass. So I have immediate feedback that something good is happening. Do you practice TDD? Perhaps that feedback may help.

I would say that it is quite remarkable how many really competent people in many fields (music, acting etc.) also feel full of self-doubt. Many of the techies I work with that I really rate are continually self-critical. Their defining characteristic though is that they don't let that stop them from getting on and delivering the next thing. Sometimes one just grits ones teeth and ploughs on ...


(4) +1 If you have test coverage and feel like the code can be improved, the tests will give you the confidence to do that freely. - Martin Owen
No we do not practice TDD. We only write unit test at the end of the development. I know practicing TDD will help me a lot. - csharpbaby
Are tests the only way to gain the confidence that your code is all right? What about the quality of the code?. This is where my confidence shakes. - csharpbaby
(1) I would say that tests are by no means the only way. Code reviews too can help. But I think you are asking about a how to adjust your mindset, how can you feel good. And positive feedback is one such way. - djna
@djna Yes it is more about my mindset. I need some mind boosting advices from you guys. Thanks! :-) - csharpbaby
The tests won't tell you that your code is as elegant or efficient as it can be, but they will allow you to make improvements safe in the knowledge that things are still working as they should be. Without the tests you may hesitate to make so many improvements. - Martin Owen
1
[+5] [2009-10-15 09:34:44] romaintaz

First thing: the perfect code does not exist.

Second thing: you will improve your coding skills by learning and coding. This is called "experience".

For example, take a piece of code you wrote some months ago, and see how you can improve it. If you can't, then it means that you are not learning enough from your work.


+1 - brilliant! - DanSingerman
Thanks for this suggestion. - csharpbaby
2
[+2] [2009-10-15 09:39:29] cletus

I'm not sure it would qualify as "depression" but it's certainly common among programmers to be perfectionists. Just one more refactor, one more rewrite, one more unit test and it'll be "perfect". It doesn't need to be perfect. In fact it'll never be perfect. It just needs to be "good enough".

A far more typical attitude is that no one else can do it as well as you can (it's why you get so many reinvented wheels).

Your issue isn't so much that as it is a basic lack of confidence so you're a perfectionist of a different sort. What you fear you create and if you become so fearful of what essentially amounts to criticism and judgement then you've got a problem that needs addressing. If you do get depressed then you also have a problem that needs addressing.

We do the best we can with the information, skills, experience and constraints (time, requirements, etc) that we have at the time. Do the best you can. Don't be afraid to make mistakes. Learn to take criticism (as in don't take it personally). Do things better the next time around.

No one can do more than that.


Thanks! That helps me a lot. - csharpbaby
3
[+1] [2009-10-15 09:36:02] Razzie

If you finish a project, look back at your code, and see no room for improvement, you're not a good programmer.


4
[+1] [2009-10-15 09:36:19] jao

I look back at code I wrote a year ago, start laughing and think: how could I've been so silly. Then I'm glad and thankful that I've improved over the last year. That keeps me going. because next year I will feel embarrassed over the code that I wrote today (to my best knowledge).


5
[+1] [2009-10-15 09:37:40] Marcel Jackwerth

I know this feeling too well. However this away after I realized:

  • There always will be someone else who is more intelligent than me and who can implement the same alogrithm in more smarter way.
  • As long as I think that this code is the best I can think of at the moment and others will be able to understand what I wrote... it's ok!

I will assure you that when you read your code in 10 or so years... you will be terrified what you did there! But that's what is so important in life - getting better with time.


6
[0] [2009-10-15 09:39:46] Joel

This is natural and means you're a perfectionist, which I think most of the time is a good trait in a programmer. Always make sure when you write code you minimise cross dependencies. This makes the refactoring process of swapping out large modules of poor code a breeze. The feeling of clean code working properly will feel great and no doubt cure your depression.


7
[0] [2009-10-15 09:41:05] Andrew Keith

If your feeling depressed a lot while doing work, it might be an early warning for some larger issues you are having.

Go talk to someone about this.


8
[0] [2009-10-15 09:41:33] Michael Foukarakis

There is always a better way of writing a program. It's the basis of the whole premise of compiler optimization, isn't it? Accept it and move on.

The real question is, does your code satisfy the problem requirements? If so, then it's good enough, so why depress yourself?


9
[0] [2009-10-15 09:49:56] Artelius

One solution is to change the role of programming in your life. For instance, become a programming teacher or maintainer. This way you don't need to obsess about the code you produce.


10