Sunday, March 8, 2009

Program Debugging Guide

Programming is a humbling experience. An experience that causes one to reflect on human error. One major cause of these errors is syntax, syntax, syntax. We tend not to notice when we have made a typo. It is too easy to spend an hour trying to fix a problem that was caused by a typo. Accepting human error, that you made a mistake, is a reasonable first assumption.

Another important assumption to fixing problems is Occam's razor - the simpliest explanation is more often than not the best. When we initially expect a simple error we don't try to over complicate things and we are more likely to use basic techniques to trap the error; we use simple debugging procedures.

Sometimes just writing a message is enough to see what is going on. One easy technique is to trap the error in a try catch block and write the error message. Its surprizing how often this simple technique is not used.

A very important step to avoiding errors in your application is testing. This is best done on a separate machine to the development and production servers. Even if you don't have access to a test environment this is no reason not to test. We developers are not the best testers. Get someone else or preferably a group to test, believe me you'll save time and probably money.

One of the most common errors is the 'object reference not set to an instance of an object'. Null reference errors are common too. Something, a reference or a parameter for example, is missing. So check the page references and parameters. Look in that error line to see what may be missing or null. Write any values that may be null.

A simple thing that you can do is continue to practice. Programming in an unfamiliar language is slow to start with, but experience is cumulative. As you get more practice, things like error handling become easier. It doesn't become easier if you just copy & paste all the time, there is no substitute for understanding what's going on.

There are many debugging techniques, but that is not the point of this article. Its not until I started to appreciate the number of my errors and the simplicity of fixing them, that I really started to make progress. At times I am still guilty of skipping the diagnosis and heading straight for the medicine cupboard. This has almost always been a mistake.

I hope that you avoid some of the frustrations that I have had over the years by not ignoring human error and accepting how simple steps can resolve most problems.

Happy programming!

Saturday, March 1, 2008

How the Sensex is calculated ?

Sensex is calculated using the "Free-float Market Capitalization" methodology. As per this methodology, the level of index at any point of time reflects the Free-float market value of 30 component stocks relative to a base period. The market capitalization of a company is determined by multiplying the price of its stock by the number of shares issued by the company. This market capitalization is further multiplied by the free-float factor to determine the free-float market capitalization. The base period of Sensex is 1978-79 and the base value is 100 index points. This is often indicated by the notation 1978-79=100. The calculation of Sensex involves dividing the Free-float market capitalization of 30 companies in the Index by a number called the Index Divisor.
The Divisor is the only link to the original base period value of the Sensex. It keeps the Index comparable over time and is the adjustment point for all Index adjustments arising out of corporate actions, replacement of scrips etc. During market hours, prices of the index scrips, at which latest trades are executed, are used by the trading system to calculate Sensex every 15 seconds and disseminated in real time.

Saturday, March 17, 2007

मन मन उधाण वाऱ्याचे

मन मन उधाण वाऱ्याचे...मायेच्या हळव्या स्पर्शाने खुलते ,नात्यांच्या बंधात धुंद मोहरते..मन उधाण वाऱ्याचे गुंज पावसाचे ,का होते बेभान कसे गहिवरते...मन उधाण वाऱ्याचे ...आकाशी स्वप्नांच्या हरपुन पान शिरते,हुरहुरत्या सांजेला कधी एकटेच झुलते,सावरते बावरते झडते अडखळते का पडते..कधी आशेच्या हिंदोळ्यावर मन हे वेडे झुलते..मन तरंग होउन पाण्यावरती फ़िरते..अन क्षणात फिरूनी अभाळाला भीडते..मन उधाण वाऱ्याचे...रुणझुणते गुणगुणते कधी गुंतते हरवते..कधी गहिऱ्या डोळ्यांच्या डोहात पार बुडते..तळमळते सारखे नकळत का भरकटते..कधी मोहच्या चार क्षणांना मन हे वेडे भुलते..जाणते जरी हे पुन्हा पुन्हा क चुकते..भाबडे तरी भासांच्या मागुन पळते..उधाण वऱ्याचे..