I certainly believe that, I am not a good programmer. But some of my friends who knew my programming skills insisted that I write a book on C. I just asked them to shut up. I am not some great guy like Yeshwant Kanetkar to write a book. Some three years back, I had a subject in college called Numerical Methods and C programming. That was my first encounter with C and I really hated it. It was only after I went through Yeshwant Kanetkar's "Let Us C", that triggered an interest in me. Its probably the only book on earth which I have read from start to end, atleast a dozen times. I read Kanatkar's book before I read ANSI C by Kernigan & Ritchie. I later referred to many C books by great authors, but none were as interesting and absorbing as Kanetkar. What's more important is the language and the presentation skills, rather than merely explanation of concepts. Its better to explain a concept in just five quality words rather than talking all nonsense for 25 pages. With this idea in mind, I just started to write my own notes in C. In about 18 months time, I am surprised to see that it has grown over 400 pages. I think, I must start contacting publishing houses!!! I still believe that I am an amateur C programmer. Last year somebody told me about Brainbench Certifications. I just thought to give it a try. The questions were tricky and I didn't really expect to pass. By stroke of luck, I did pass. But what surprised me the most was my score. It showed a score of 4.76 out of 5. I think these Brainbench people have gone bananas !!!. I wish we had some international C certification tests like that of Java, Oracle and Networking. Unfortunately, there is none. |
All, I can say is that, over a period of two years, I have certainly developed a unique style of programming. I write codes that are easy to understand at a glance. My choice of variables is totally non-conventional. I don't sacrifice simplicity even for standard notations. For eg. I would never choose conventional variables like lpszArgs or hWnd usually used as standard variables for denoting command line arguments and handle to a window respectively . Simple variables like cmdlineargs and windowhandle could better do a job. Too much of commenting is also bad. It looks stupid to see comments like "This is an integer variable". Only key comments normally suffice for any programmer studying my programming codes. On an average, the ratio of code to comment should be around 10:1. |
#
Programming Tip !!! Whenever you want to perform a comparison for equality of a variable with a constant in an IF or a WHILE statement, always try to keep the constant expression on the left hand side. Eg. Instead of if (a==5) use if ( 5==a) . Instead of if (a&&b==0) use if(0==a&&b) Instead of while(x==7) use while (7==x) Instead of if(filehandle==INVALID_HANDLE_VALUE) use if(INVALID_HANDLE_VALUE==filehandle) By using the constant on the left hand side, in case you make a mistake by putting a single = instead of double, you can easily detect the error, as the compiler will complain and give a syntax error that you are trying to modify a constant. Thus if(a=5) is syntactically correct and will not display error while if(5=a) is syntactically wrong and would display an error. Though this tip is well known hardly anyone uses it, including myself. The reason is that we are all over confident that we simply cannot forget the double== . Nevertheless, good programming practice never hurts. |
|