Monday, November 16, 2009

Best coding practices

Over the many years of my programming experience. I have found common mistakes which people make again and again. In this series of articles I will post some of best practices one by one and common mistake which you will avoid by using it.

1) Read the API documentation carefully.

It is very common that programmer does not read API documentation carefully. Which include what are parameter boundaries. What are side effect of passing certain parameters.
Under what condition function will fail. What are error code or exceptions thrown by the api. If programmer take 10 min of extra time and reread the documentation once again carefully. I can bet many of programming errors can be avoided.
2) There should be very good logging mechanism in place.
While developing any piece of software there should be very good logging in place. Log statement should be well thought. These should give comprehensive description about the event. I have seen logger statement like enter the function exit the function. these are really of no value. There should be different log levels which should be configurable. In case of failure log should give clear picture why the failure has happened.
3) Write simple code
We should write as simple code as possible. We should avoid complex code. One hint for complex code could be, if one has to write comments to make the code understandable it is time to review the lines of code you have written. See if you can make these lines simpler.
4) Use standard libraries and api's :-
Many programmer keep inventing same thing again and again. e.g function to reverse a strings etc. There many standard functions for many tasks like this. Read all the standard api's and try to use already tested and used api's

Saturday, November 7, 2009

Plasama vs LCD

Here is quick comparison

S.NOPlasmaLCD
1.Life15years 20 years
2.Picture quality Best as good as CRT Blur
3.Power More less
4.Moving picture BestBlur
5.Weight More less
6.HeatMore Less
7.Still pictureCreate pixel burns Good
8.Moving picture Good Create ghosts

Tuesday, October 6, 2009

VMware webaccess does not work

Recently I observed that vmware web access does not work sometime.Initially i did restart of computer and it used to work. I used to see the eventvwr to see it any vmware service has failed.
Finally i found the root cause of the issue.

1) vmware Host Agent service was down.
So next time don't forget to check this service if you are not able to access the vmware web page.

Spark - value for money

Finally i bought new car Chevrolet Spark LS :)

I did lot of research before i zeroed on this car. I started with intention to buy second hand car. I kept searching for it. I had two option
1) To buy from known second hand car dealer e.g. First choice or maruti true value. I found although these will give warranty for one year, but prices were very high. I did not find it worth buying cars from these dealers.
2) To buy using sulekha.com etc. there i was able to find 1-2 deals worth looking most other were not good. Moreover most second hand cars were as old 10 years.

Finally i give it a deep thought that best period to enjoy a car is when it is new. In first three years or 20000KM. As car has lot of moving part after approx 3 years vehicle starts degrading exponentially.

So now i was clear that i will buy new car. Then started the test drives.

I saw many cars from many companies, TATA, MARUTI,HUNDAI,CHEVROLET, Many i found expensive in terms of value for money...

I observed general consumer behaviour that what other is doing they were buying the same thing without seeing the available good alternate.
E.g. Maruti is selling same old 800 repackaged to alto with cost of 3.35 or more!!! and people still buying it :) and in masses..

Other patterns i observed that people were looking for resale value. Although it does not matter for most of people....

I found lot of value in spark. I got it in 3.5 on road. with 1000 cc engine with fully loaded.

Wednesday, May 20, 2009

TATKAL WAITING IS SURE COFIRMED

Recntly i was at my native. I did not book ticket until very late when i was about to travel. I did tatkal booking through internet for RAJDHANI. It was from DELHI to BANGALORE. I was worried whether it will get confirmed or not. I talked to one broker he assured me that he will get it confirmed. He took RS - 500 for this. He finally got it confirmed before my journey. But later i found out the boker has actully looted me.

So lesson learned. TATKAL WAITING GET CONFIRMED ATLEAST UPTO 35+. DO NOT GIVE MONEY TO BROKERS

Monday, February 9, 2009

Buy grocery from local players

Q Why should we do this. ?

Ans. This will help our country to become self dependent and to strengthen Indian economy by arresting the wealth drain abroad.

Q Why grocery ? we can stop buying huge arms from abroad.

Ans.  Grocery is zero technology product most of time produced here in India only. But marketed by foreign companies and finally profits are taken to abroad. But technology which are used in arms are not currently available in India. 

Q I do not get all products by Indian players ?

Ans.  At least start buying which are available. 

Q Indian companies are not having good Quality products.

Ans. This is totally wrong perception. For instance take the example of ITC,  it has wide range of products which has same quality as of HLL (Hindustan lever limited) and in some cases it has even better quality then HLL. You will be surprised to know that it sources its raw material directly from farmers in western Utter Pradesh , thus helping them as well as client by removing the middle man from the chain.

Tuesday, January 20, 2009

IRibbonControl->get_Id Gives Access violation

While developing Custom Ribbon interface for excel we were Getting Access violation while calling function get_Id() in one of my control callback. Following is code snip for that


STDMETHOD(ButtonClicked)( IDispatch * RibbonControl)
{

CComQIPtr pRibbonControl;
pRibbonControl = RibbonControl;
BSTR bstr;
pRibbonControl->get_Id(&bstr);

....

above line was giving access violation in debug build. But it works in release build ...

So do not get blocked due to this...
}

I spent almost one day for this ...
Note: This was happening only on vs6

Thursday, January 8, 2009