The 10 rules of Productive Programming

I’ve read the book “The Productive Programmer” by Neal Ford, there are many great ideas in this book. This gave me the idea to write – just for fun – the 10 rules of Productive Programming.

DO NOT talk about Productive Programming!!

1. Do not talk about Productive Programming

Well, you know where that first rule come from, don’t you?

2. Be DRY: Do not repeat yourself

This mantra comes from The Pragmatic Programmer, it says that you shall not repeat more than once a block of code. If you are about to, that means you need to refactor something. The less you repeat yourself, the better your code quality and maintainability.

3. Think YAGNI: You ain’t gonna need it

Donald Knuth is probably the first one who pointed out that sane rule, in The Art of Computer Programming: “Premature optimization is the root of all evil“.

When working on something, you may start thinking about future issues you may have, and here you start to optimize your code for problem you don’t have yet. This is very bad. The fact is that you’re going to spend energy and time on a virtual issue, that may never come true. Focus on your real issues, and let the time tell you where an optimization is needed.

4. Kill distractions

Distractions are the inner enemy: your email client notifications, your instant messaging system, your Facebook page, your Twitter account…

All this leads to disturb your attention. Every distrcation slows down a bit more your productivity. Choose when to check your emails, don’t connect your instant messaging system all day, choose when to connect with your twitters, and when not.

5. Be careful of angry monkeys

The “Angry Monkeys” metaphor symbolizes the fact that people tend to fear changes. When a team is used to do something in a particular way, that team will hardly think about changing its strategy, because of the mantra: “we always did it that way”.

Changes can be good for software. Don’t fear them.

6. Work your flow

The flow is the state of mind where you are when you’re focused on your code. This is a very fragile state, and can be broken very quickly (by distractions). The better your flow, the higher your code quality. Try to control external events that can break your flow, kill districations, and focus on one single task at a time, with a clear target in mind. Move step by step.

7. Write unit tests

Unit tests are the way to go in modern programming. Write tests and use a test coverage analyzer. Target 100% of test coverage. Try to write tests before you write code, use the Test-Driven Development technique as many times as possible.

8. Refactor comments into functions

If you’re writing some comments inside a functions, chances are that this function should be splitted into smaller ones. Those comments you write, they can basically be renamed as functions, you’ll see the resulting code will look much more readable and … testable!

9. If you find a bug, write a test

Whenever a bug is found, the first thing you have to do is to write a test that reproduce the bug. A bug you can reproduce is a bug near to be closed.

10. Apply these rules daily

Well, rules are nice, but they’re even better when applied ;)

All right, I broke rule #1, I know ;-)

Get Adobe Flash playerPlugin by wpburn.com wordpress themes