Lurker News
A quote by Kent Beck: I'm not a great programmer; I'm just a good programmer with great habits.

So what are the habits I should cultivate to be a great programmer or even a good one? What are the bad habits that I should drop?

Comments (183) 79 threads

Earlier comments
inDigiNeous1 reply#
Hard to say any definite habits that work for everyone, as each person is so different, but just for the fun of it, I'll try to list habits that work for me:

* Keep a diary. Write out problems and solution propositions first, if the solution is not trivial.
* Keep your mind clean, always finish what you started, so you can have completion and not clutter your thought process. This means not leaving code in a state of disarray, should compile when returned back to
* Let go. If the solution does not propose itself, take a break. Sleep over it. The solution will come, with time, not by bruteforcing of overdosing caffeine. Sometimes these work too, but as a habit, better to focus on long term goals than short term successes.
* KEEP IT SIMPLE. KISS! When solution starts to look too complex, it probably is. Break it down, simplify, line by line, so that the code is understandable and easy to read. Write for humans to read, not for machines to parse.
* There is no ready made solution. Accept the fact that to get results, work must be done and days and even weeks might go before getting there.
* It's ok to write code that is not "smart", that is not "perfect", that just freaking works right now as should and expected. It's just code, and in the end it all transforms into zeros and ones. Implement new features gradually towards more flexible and standardized solutions, first find a solution for the problem at hand and remember KISS again.
Some of the main points that come to mind. Especially the point of KISS, is so easy to go overboard with, starting to overthink all kinds of fancy structs, class inherintance models, whatever fancy code-beauty around a solution that could be solved with a simple function and evolved later if needed to something more flexible.
This KISS also applies to general software design, user interfaces etc also, probably the most useful habit is to remember when thinking about systems, keep it simple! It should also be fun to write at least in some level, if it feels like crap, don't do it for your own sake.

noway421#
One way I started to look at KISS is that there are so many ways for software to be complex on higher architectural level, that there is absolutely no reason to make your life harder and go for implementing complex solutions on low level. Get it to a point where it's simple, the complexity will come later.
itamarst#
Assume there's always a better, faster solution to the problem than the one you've come up with. Finding it will require deeply understanding the problem, and sometimes redefining the problem.

Put another way, working long hours is a bad habit because you end up solving problems the brute force way instead of figuring out how to come up with better solutions.
I think of this aiming towards becoming a 0.1× programmer: achieving same or better results with 1/10th the lines of code and effort. More here: https://codewithoutrules.com/2016/08/25/the-01x-programmer/

lj35 replies#
1. Embrace the grind. Motivation comes and goes, but the grind remains. This doesn't mean working all day every day, but rather setting aside specific blocks of time and doing the same thing every single day. Workouts should happen at the same time every day. Work should happen at the same time every day. Each of these things should be daily habits and doing them at the same time every day helps them become habits.

2. Avoid flow[0]. It's tempting, seducing and addicting, but you don't learn anything when you're in a state of flow. Anything sufficiently hard as to improve your skills should leave you feeling a little frustrated. Get used to that feeling.
3. Drop TV, Porn, news, music and video games. These things all give you rewards without having to do any work. In doing so, they steal your motivation and energy.
4. Stop eating sugar. If you want to get things done, strive for a steady blood sugar level. It's hard to work when your blood sugar drops and you fall asleep at your desk.
5. Sleep during the hours of 10pm and 2am[1]. That's when your body makes most of the hormones you need every day.
6. Do the opposite of this video: 7 ways to maximize misery by CGP Grey: https://www.youtube.com/watch?v=LO1mTELoj6o
[0]: http://calnewport.com/blog/2011/12/23/flow-is-the-opiate-of-...
[1]: http://www.anitarossiter.com.au/blog/early-nights-are-in-ord...

parthdesai1 reply#
Can you elaborate on point 3 ( Music part).
lj31 reply#
Recorded music is great. I listen to recorded music all the time when I'm at the gym or at the office. I use it to set the mood. I use it to fill the silence. I use it to block out office noise. But here's the big question: could you go a week without listening to any recorded music at all? You'd be surprised how many people try to stop and find themselves feeling symptoms of withdrawal. That implies some form of psychological addiction, which in turn robs motivation.

The whole point of point 3 is to work for your rewards instead of getting them instantly at the push of a button. It's too easy to get addicted to the latter and with any kind of addiction comes a decrease in motivation.

allhailkatt#
Exception state: Music helps with chronic fatigue/pain. If you're one of the unlucky ones, go with any and all effective pain management.

By all means, make your Skinner cage to lengthen assumed times for rewards, but make sure you can still run.

kennydude1 reply#
> Drop TV, Porn, news, music and video games.

No fun allowed then?

lj3#
Active things. Go for a hike, play frisbee, walk the dog, play piano or guitar or whatever floats your boat. The whole point is to work for your rewards instead of getting them instantly at the push of a button.
goatlover1 reply#
Is this a live to code philosophy?
lj3#
It's not a philosophy at all. It's just a list of random things that have improved my life for the better.
jeremywho#
I find #3 (minus the music part) to be so important and yet so challenging, having grown up in a house where the TV was ALWAYS on in the background. I spent my teen years falling asleep with the TV on. It feels very uncomfortable at first to forego TV/Movies, FOMO hits hard.

A couple of ideas for taming it.
0) Media detox. It's can be so uncomfortable at first, feel what its like to go without for a week. A similar thing worked for me when I was trying to lose weight, getting used to fasting and what true hunger felt like allowed me to restrict my calories effectively without falling off the wagon.
1) Don't pick up new shows, finish out current seasons and leave it at that.
2) Make a rule that you won't watch TV/movies unless you are watching with someone else, so it's a social activity.
3) Only watch shows when you are working out, cleaning, other mundane task like that. Although you could go the other direction and say those are great activities to practice mindfulness with.
4) Pick one day/week to allow for watching things, ie Part of Sunday is just a lazy day in bed. Kind of like a cheat day.

elliotec#
This is some pretty odd advice. Basically it amounts to "stop doing things that you enjoy". Drop music, news, and video games? Not listening to music will not make you a better programmer. I agree about sugar in moderation and getting good rest (though the specific times seem debatable).

#2 is a serious misunderstanding of flow[0] and is against research arguing that flow states facilitate learning[1].
Flow is not easy-peasy non-frustration time, it is getting "fully immersed in a feeling of energized focus, full involvement, and enjoyment in the process of the activity." To deny yourself that is blocking yourself from the most productive and rewarding of human experiences.
One of the fundamental ideas of flow is that when the task is challenging enough to break one out of the state, additional skills are learned to return to the flow state.[2]
In my opinion, to achieve your maximum potential as a programmer, you should be striving to hit a flow state as much as possible.
[0]: https://en.wikipedia.org/wiki/Flow_(psychology)#Education
[1]: https://www.learning-theories.com/flow-csikszentmihalyi.html
[2]: https://www.amazon.com/Flow-Psychology-Experience-Perennial-...

mhomde#
One habit that I think is important, and often overlooked, is to be able to break out of a mindset and questioning yourself with:

"Am I solving the problem at the correct level, using the appropriate method/technique/tool? Don't forget the big picture"
It's easy to just keep coding and add to existing code, architecture and methods. But sometimes the frog is starting to boil. Better then to re-evaluate whether to do some major refactoring, or add some layer of abstraction to keep it maintainable.
Sometimes you need to recognize that you're merely treating symptoms rather than a underlying problem. Sometimes you need to recognize that there are some library/tool/algorithm etc that can eliminate the need to solve a problem yourself.

Load more comments