Ask HN: What habits make a programmer great?
518 pointsA 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* 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.
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/
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...
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.
By all means, make your Skinner cage to lengthen assumed times for rewards, but make sure you can still run.
No fun allowed then?
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.
#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-...
"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.
All comments shown.
Couldn't load more comments. Check your connection and try again.