7 habits of highly effective programmers

Programmers
Programmers? Nah

I recently came across a list of seven rules for beginning programmers. I could agree with only one of the rules – each procedure should have a purpose, an input and a defined output. However, programming is an ecosystem of related disciplines, and the rules ought to control not just coding. Here is my attempt:

1. A successful program is one which meets the customers’ requirements, is flexible (well designed) and requires least effort from the programmer. Such a successful program has three ingredients: Plan, Plan and Plan. If you intend to spend an hour doing the coding, spend 20 minutes up front to plan the design.

2. Procedures should not be created just because it’s written about as a good programming practice. Each procedure should have a need, an objective and a clear input with a defined output. Procedures should not modify global variables, to the extent possible.

3. Unless you plan to complete the program in one sitting, or if you think you might to tweak or debug it later (which is true in most cases), start maintaining notes on the highlights of the design as early as possible. I normally add comments within the code mentioning future enhancements or improvements to the coding design to be done as phase II.

4. Assume that your program will need debugging, and enable that while writing the code itself. Create a debug flag, and emit verbose details when that flag is enabled. This one is most difficult to implement with beginner programmers.

5. When I need to develop code for a new requirement, in the ‘first draft’ I may write only the pseudo code for certain sections where I will need to check language features, or I am not sure of the syntax. Later, I grapple with completing the code. This allows me to focus on the overall algorithm during the first draft, and saves overall time debugging.

6. Simple coding of an efficient design will help, not the other way around. Even in the first draft one needs to focus on the efficiency of the code, only from an algorithm perspective. For example, if I need to extract data from a database, I will ensure I extract only the minimum number of rows I need. I will ignore the fact that the loop needs to do an extra iteration.

7. There are many more rules, and yet an effective programmer is one who knows when to break the rules. Coding is beyond all rules, like a poem. Quoting from The Tao of Programming by Geoffrey James:

A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity.

A program should follow the `Law of Least Astonishment’. What is this law? It is simply that the program should always respond to the user in the way that astonishes him least.

Happy coding, please add comments if you can think of rules more important than the ones I have stated. I will too.

Share

Needle in Haystack Part II – the solution

Needled
Needled

Okay so we have faced the problem. What do we do?

It may be prudent, to obtain bye-in from the person who will be looking for the needle in the haystack. Especially if this is a boring task you will need to explain to the person why it is necessary to find the needle and how it fits in with the vision/mission.

In case this is a repetitive scenario, you may want to track how many times each resource has failed to find the needle and penalize the one at the top. If this specific scenario is not repetitive you may want to club with similar scenarios where the group overall is repetitive. This can also be subjected to statistical analysis (more on the statistical analysis in another post here).

One way, as I suggested earlier, is to create a verification procedure that is shorter than looking for the needle in the haystack itself. Ask a peer to carry out the verification – call him the “supervisor” (he will be better motivated this way).

Another way to handle this problem is through the usual reward/punishment strategy. Either offer a reward for finding it, or offer a punishment for not finding it. The reward does not have to big, neither does the punishment need to be huge. Token punishments are enough. For example, a task required everyone to fill up a template, and one person to consolidate each Friday. People would need reminders, etc – so we decided that whoever is the defaulter the highest number of times would get the task of consolidating for the next few weeks. Then on to the next defaulter.

Share

Needle in Haystack Part I – the problem

Needle in Haystack
Needle in Haystack?

One of the problems I have faced repeatedly in not just project management but in a wide variety of scenarios (even at home) is what I call the ‘Needle in Haystack’ problem. Say I am the manager of a project where the task is to find a needle in a haystack. I assign the task to Mr.X. He comes back after three days and tells me there is no needle in there. I am confronted with three possibilities:

  1. He actually spent three days actively looking for the needle and was unable to find it. There is indeed no needle in there.
  2. He actually spent three days actively looking for the needle and was unable to find it. There is a needle there, only he was unable to find it (the methods may be not very efficient for example).
  3. Mr.X went on a movie watching spree 🙂

The real problem here however, is that in order to find out which of the scenario is factual, I will have to find the needle myself – and maybe spend three days myself. There is no benefit obtained through delegation.

One course of action, obviously, is to seek evidence from Mr. X. A bus ticket from office to the haystack for example.
Another is to find a way to verify if there is a needle or not, in say 3 hours. In most cases one of these solutions is possible, but is hard to find. In the next few postings on this topic I will share case studies around this, to give you some ideas around it. There is no magic wand though, everyone needs to invest thought.

All postings in this series will be accessible through this link: http://blog.2cent.me/tag/ndlinhstk

Share