Tuesday, September 28, 2010

The three best practices in software development

Michael Cusumano has documented the three most effective practices in software development  in his
book  "The Business of Software". These three practices have resulted in significant defect reductions in large companies.While  Six Sigma, Lean, CMMI and other methodologies can be applied to software and have been effective with varying degrees  , the following three practices have to be   implemented. All other methodologies and practices would be add-ons. So,  what are the three key practices ?.

1.Early prototyping -
Do a proof of concept by prototyping early and show it to the users.
Seeing is believing. When the users see something, they can spot obvious flaws and limitations.  

2.Reviews,reviews,reviews
We need reviews at each stage - High level design reviews ,detailed design review, code reviews, unit test cases reviews, system test reviews , project plan reviews etc. Review provides a negative feedback mechanism and hence stabilizes the output, to give an analogy of a closed look negative feedback control system.  In a control system with a negative feedback, the output Y = X * (G/1 + GH) .
X is the input, G is the gain/amplification/distortion  and H is the amount of feedback
In a  large project , G can be assumed to  be large and H close to 1 . Hence  GH  can be assumed to be much greater 
than 1. Thus Y = X * (G/GH) = X/H

Now if the review is 100% perfect , H =1 . Therefore,  Y =X .
Thus the output of the software stage equals the inputs which is the   specification to that stage.
In essence the output of the software development   will follow the specifications accurately if there are
rigorous reviews.

Linus Torvalds , the inventor of Linux said " Every bug appears shallow if a large number of eyes look at the code". How true ! No wonder why Linux is such a robust operating system despite being open source.
Millions of eyes look at each line of code each day  and suggest improvements.  So the next time you want to review code, call all developers in a room  and project their code . Let them all look at it and have fun dissecting it in a cordial  and friendly environment.

3.Daily regression tests and builds.

The code must be compiled and linked daily.
Automated regression tests must be run daily - the more the better and emails send to all concerned including
senior management when RT's fail. This ensures that as new features are added, existing features continue to work.

Sunday, September 26, 2010

Bayes theorem

Bayes theorem is the foundation of Bayesian statistics and the new and emerging discipline of  predictive analytics. Reverend Bayes , a 17th century British mathematician wrote the Bayes theorem as a special case of probability theory. He did not disclose the theorem  fearing that it might not pass rigorous scientific scruitiny. The theorem was recovered after his death .
Here's the theorem and  a  few practical applications.

P(Ri/E) = p(E/Ri) p(Ri) / sum [p(E/Ri) * p(Ri)] i = 1 to n

p(Ri) is called anterior probability  of event Ri. It represents what we already know from past history about event Ri..E is the fresh new evidence that has arrived that would influence the event Ri.

p(Ri/E) is the probability of event Ri given the evidence E.
p(E/Ri) is the likelihood of the evidence itself.

As can be seen above as new evidence surfaces, the theorem lets us update our knowledge about the probability of occurrence of the event Ri. p(Ri) was our knowledge of the event based on its history,
while p(Ri/E) is our updated knowledge after taking the evidence E into consideration.

These probabilities can be deterministic or may represent a certain distribution.
Here are a few practical examples  where the theroem could be applied.
(An example similar to the first example below was  cited in a recent issue of Sloan Management Review).

1.I know the history of rainfall in my region for the past 10 years. I now have the evidence that this year
the temperatures were higher than normal. We know that higher temperatures correspond to higher rainfall
and follows a certain distribution. Using this evidence, we can predict the probability of rains this year  .
If I calculated probability based on history alone (which is what frequentists would do)  , I would be ignorning the key evidence that surfaced this year.

2. We know the history of deliveries of a certain supplier. A new evidence has arrived that the supplier's capacity is full due to a new contract they have signed with some customer. We know the relationship between the supplier's capacity and on time delivery . Given the evidence, we can find out the probability of on time delivery this month. If we had not used Bayes theorem, (and instead relied  on history alone as a frequentist would do)  the probability would have been based solely on the supplier's  historical performance and hence would have ignored the critical new evidence.

Bayesian theorem does have certain limitations/gotchas  in practical life as would be seen in future blogs.

Monday, September 06, 2010

System thinking

Most engineers , when given something to analyze  try to break it up into several parts and then  analyze each one of those parts  one by one. While there is merit to  analyzing a problem , it is important to first synthesize it. Synthesis is the opposite of analysis. It involves 3 simple steps.

1.What  system  is the  object under investigation a part of ?
2.What are the other  objects in that system ?
3.How do these other objects interact ?

Once these questions are answered , the engineer gets  the so called  holistic view of the problem under investigation. Thereafter the process of analysis of the object in question  may begin which will be described in  my subsequent posts.

The system is always greater than the sum of its parts because of the complex interactions between those parts. A car transports people - however none of its parts, for example, the engine,gearbox or frame can perform that function. Hence theorists posit  that systems have  emergent properties which means functions evolve as various parts of the system interact.

This underscores the need for multiple rounds of system testing in the software development cycle because each round is essentially an attempt to discover emergent properties of the system , not anticipated in the unit testing of its parts. People, process and technology are the three basic parts of a software system or any system for that matter. They can interact in at least 4 ways - people and process, process and technology,
people and technology and people,process and technology  - therefore system test case design should consider these interactions. Compounding the equation is that these interactions are most of the time non linear  (i.e output is not proportional to input)  and higher order meaning one needs to differentiate them multiple times wrt the independent variable to remove the effect of the independent variable. These interactions could be static - time indepenent or dynamic - dependent on time. These interactions could be location dependent or independent - e.g. geography of where people,process or technology are located.
The interactions may have a causal loop meaning you do not know what is the  cause and what is the effect - e.g  Is the technology poor because processes are poor or proceeses are poor because technology is so. Modelling such an effect is very difficult because it is not clear what the dependent and independent variables are. That's where a system  consultant's expertise comes into play - to apply judgement in situations where  modelling is infeasible.  

Saturday, September 04, 2010

3 idiots and Five Point Someone

I finally managed to find some time to watch Aamir Khan's Bollywood movie '3 idiots' and read Chetan Bhagat's "five point someone" , the novel on which Aamir's movie is based. I am very impressed with Chetan's portrayal of life at the IIT's and the story's unusual plot . The protagonist - "Ryan" in the novel and "Rancho" in the movie carry a theme that resonated with me the most - "Follow your passion and success will follow you sooner or later" . Victor Menezes, former Chairman of Citigroup had once quoted the following in his speech to the students at Sloan. "Do a job that you like and you would not have to work throughout your life".
Of course following ones passion is easier said than done. There are constraints in practical life, there are sacrifices ,risks and costs associated with following your passions and more often than not pragmatic considerations triumph the pursuit of passion. Chetan represents the voice of the Indian youth aptly but would do well to avoid profanity in order to take his literature to the next level.Aamir on the other hand has replaced some of the profanity in the novel with some profound thoughts, events and music making the movie truely entertaining yet full of substance.