Friday, May 28, 2010

writing Bug free C code


The C language provides a minimal, efficient framework. A key to writing bug-free code is learning from your mistakes. Designing a module right the first time saves time. Programming without a goal is like a sailboat without a sail. You drift. Never reinvent the wheel. Always code what to do, not how to do it. As a general rule, try to keep functions under one page.


Always review changes before checking source code back in. An API must be designed right the first time because changes to an API are costly. Before you can write bug-free code, you must have a bug-free, rock-solid base. Provide a code wrapper around all system calls. Use macros as an aid to porting so that your code base does not change at all. Try to hide how something works to provide an abstraction that aids.

Macro names should be in uppercase. Macros beginning with an underscore are to be used only in other macros, not explicitly in source code. New data types should be in uppercase. New data types must be declared with a typedef statement, not a macro definition. Variables should be named using Hungarian notation. Hungarian notation allows you to know a variable's data type without seeing the data declaration. Functions should be named using the module/verb/noun convention. Think twice and do once.

    If I had eight hours to chop down a tree, 
    I'd spend six hours sharpening my axe.  -- AbrahamLincoln

    --
    Sam

    Wednesday, May 19, 2010

    A Leader Should Know How to Manage Failure


    Question: Could you give an example, from your own experience, of how leaders should manage failure?

    APJ Abdul Kalam: Let me tell you about my experience. In 1973 I became the project director of India 's satellite launch vehicle program, commonly called the SLV-3. Our goal was to put India 's "Rohini" satellite into orbit by 1980. I was given funds and human resources -- but was told clearly that by 1980 we had to launch the satellite into space. Thousands of people worked together in scientific and technical teams towards that goal.


    By 1979 -- I think the month was August -- we thought we were ready. As the project director, I went to the control center for the launch. At four minutes before the satellite launch, the computer began to go through the checklist of items that needed to be checked. One minute later, the computer program put the launch on hold; the display showed that some control components were not in order. My experts -- I had four or five of them with me -- told me not to worry; they had done their calculations and there was enough reserve fuel. So I bypassed the computer, switched to manual mode, and launched the rocket. In the first stage, everything worked fine. In the second stage, a problem developed. Instead of the satellite going into orbit, the whole rocket system plunged into the Bay of Bengal . It was a big failure.

    That day, the chairman of the Indian Space Research Organization, Prof. Satish Dhawan, had called a press conference. The launch was at 7:00 am, and the press conference -- where journalists from around the world were present -- was at 7:45 am at ISRO's satellite launch range in Sriharikota [in Andhra Pradesh in southern India ]. Prof. Dhawan, the leader of the organization, conducted the press conference himself. He took responsibility for the failure -- he said that the team had worked very hard, but that it needed more technological support. He assured the media that in another year, the team would definitely succeed. Now, I was the project director, and it was my failure, but instead, he took responsibility for the failure as chairman of the organization.

    The next year, in July 1980, we tried again to launch the satellite -- and this time we succeeded. The whole nation was jubilant. Again, there was a press conference. Prof. Dhawan called me aside and told me, "You conduct the press conference today."


    I learned a very important lesson that day. When failure occurred, the leader of the organization owned that failure. When success came, he gave it to his team. The best management lesson I have learned did not come to me from reading a book; it came from that experience.

    Source: This is from Former President of India APJ Abdul Kalam at Wharton India Economic forum, Philadelphia , March 22,2008

    --
    Sam

    Tamil News Live Online HD

    Tamil News Live Online HD