Thursday, July 23, 2009

Mistakes you can make in your first job

1. Not taking time to study the fundamentals.
Eg: If you are expected to write C++ program, first learn C++. Take time to understand classes, inheritance, composition, etc. By understand, I mean you not only need to know the syntax, but also imagine the scenarios in which they are useful (an which they are not). If you don't know STL or smart pointers, believe me you would be re-inventing some of its code inefficiently :) and your code might be prone to bugs.

2. Google search before you ask your team lead or team members. This protects you from asking stupid questions or worse committing stupid mistakes.

3. Under-estimating the importance of "requirement gathering" and "design" phase aka Start coding immediately. A good programmer always takes time to understand the problem and create a big picture of the project in his/her head.

4. Trying too hard to present what you are not. It is extremely difficult to live a lie. Remember honesty should be coupled with extreme desire to improve yourself and also hard-work.

5. Blaming others to improve your chances of staying in the job. Believe me nobody likes a snitch. If you commit a mistake, be brave and accept the responsibility. Be proactive and ask the mentor for what you can do to improve your chances instead.

6. Disregarding "Murphy's law" and not clearing your expectations with team members.
If you think there is slightest possiblity of any team member to commit certain mistake or make certain wrong assumption, clarify it.

7. Delving into details without getting the big picture (kind of re-statement of point 3). But this is so common that I need to mention it again.

8. While using new software library, not differentiating the interface part and core problem part of the project.

9. Ignoring the coding standards of company. If you company does not have one, try to follow the coding standards given in the book C++ Coding Standards: 101 Rules, Guidelines, and Best Practices.

10. Reinventing the wheel in your design aka not knowing what are design patterns. If you don't know what design pattern mean read Head First Design Pattern. If you have already taken course in design patterns, then revising Gang of Four book won't hurt.

11. Not using a version control. Chances are that you would break the working code when you are trying to add new functionality. If you are using a version control, then remember to add messages like "Working version 1.4", etc. and learn how to revert back to certain version. If you are not allowed to use version control, make copies whenever you implement and test new functionality.

12. Not discussing your design with others aka school-children syndrome. Think of it this way rather than sharing your trade-secrets; by explaining or helping others, you improve your knowledge base.

13. Not respecting chain of command. Always give credits to your mentors, even if you think they have not helped you in it. It is even worse, if you complain against your mentors to their managers. Remember habit 4 (Think Win-win) of 7 habits of highly effective people.

Two books you must read and re-read before joining the job,
1. 7 habits of highly successful people by Stephen Covey. (Summary)
2. Getting things done by David Allen. (Summary)

Sunday, July 05, 2009

Why are Indians targetted ?

I am writing this article in response to the article of same name in "Times Life" (a section in the news paper Times of India) dated July 5th 2009. Most of the ideas are borrowed from this article.

Let us first enumerate what could be the major reasons why Indians are targeted:
  1. Racism and jealousy
  2. Cultural and Behavioral habits (the "Herd" mentality)
I would like to ignore the first reason and want to focus on the second reason only. Here are the points that support my assumption:
  1. Serenity Prayer
  2. My experience in Gainesville, Florida suggests that most people are comfortable with working in a multi-cultural society. Some people may not like some sect of people, but it is usually due to personal preference rather than racism (It is important to note there is a difference. Just because I am from different race or ethinicity doesnot mean the other person has to like me. It is only when the other person starts humiliating you, it is racism).
  3. Whenever there is a inter-relationship problem, it is better to start identifying the problem in yourself first and try to improve it rather than finding problems in others and blaming them for the situation.
Statistically speaking, I have seen most Indians hanging out with only Indians. There are several reasons for that:
  1. We do not want to put extra effort to understand the cultural diversity and to come up with a harmony of both Indian cultural system and the host cultural system. For example, most jokes we share with our "Indian" friends might not be funny when we share it with people from different race.
  2. Fear of rejection/intrusion: We do not take up the initiative to talk to a "non-Indian" colleague and bond with him/her. By bonding, I mean come up with a level of comfortableness, where both you and him/her can enjoy daily discussions (say sports, politics, family, etc ..). Usually, people take this initiative only when both parties have to spend a lot of time with each other as colleagues.
  3. And many more ...
The bottom line is this ... Assume non-racist environment and ignore few "racist" wise-a**. It is very important to understand and respect the host culture. Put effort to find out common trivia regarding politics, sports, etc which might be a topic of daily discussions among peers. Participate in some (host-cultural) social events, such as going to a bar, bbq, etc. Always respect the host law. And be a good guest (i.e. make the host comfortable around you) !!!

This article does not in any way suggest changing your value system. I am proud to be an Indian, and I will never change by values (eg. respecting elders, praying, helping others, etc ..). But it doesnot mean only the Indian value system is the best and all others are inferior. I think I could learn a lot from US and it is necessary to put effort to learn the host culture.

Sunday, June 21, 2009

Shuffle functions

Very frequency asked question is "Write a program to shuffle a set of cards". There are many approaches to solve this problem.

Almost all of them treat the set of cards as a list and write the program to shuffle the list.

One approach is to emulate the human shuffling:
Hindu Shuffle; Riffle shuffle

Other techniques are discussed in more details in wikipedia

Here is an interesting but not optimal way(O(n lgn)) to shuffle a list:
In Ocaml:
let shuffle l1 =
let sortComparator x y =
(
match (Random.int 3) with
0 -> 0
| 1 -> -1
| 2 -> 1
| _ -> failwith "Error in shuffle"
)
in
List.sort sortComparator l1
;;

C++ Code:

template < class T >
bool sortComparator(T x, T y){
if(rand % 2 == 0)
true;
else
false
}

template < class T >
vector < t > shuffle(vector < t > cards) {
sort(cards.begin(), cards.end(), sortComparator);
return cards;
}

Friday, June 19, 2009

Kindle DX review

1. PDF capability:

For pdf documents, treat Kindle DX as a READING device and nothing else.

Does not Support: Note-taking, highlighting, zooming(both the document and font ) capability and has bad searching capability. Also there is no dictionary for PDFs

But it serves the purpose of READING - Resolution is good, it does not strain your eyes, and landscape view is good enough for most of my documents. Also, I prefer to take active notes rather than just higlight, it's not a big deal for me.

Transferring PDF - very easy ... just connect to USB and copy your PDFs to Kindle.

Steve Bain has more critical review on it.


2. Weight:

Extremely light atleast for me.


3. Durability:

Though material looks good, please don't expect it to be extremely sturdy. Hence I recommend using cover(either leather or neophryne) while traveling.


4. Battery life:

Extremely good. I haven't tested it very much but just turn off whispernet and you should expect 4 weeks of battery life


5. Choices of Books:

Amazon is undoubtedly the best choice.


6. Awesome feature:

Wikipedia is free .... anywhere in US !!!


7. Cost:

If you think $359 is OK for Kindle 2, Kindle DX is definitely worth $489.


If you donot like to read research papers on computer, you will save on great deal of printing and "trees" :)

As an engineering student, you will save a huge amount of money and space on printed books if you chose to buy Kindle DX.


Bottom line:

If you cannot live without highlighting and note-taking, DON'T BUY KINDLE DX ... go for Sony PRS-700(if you like text notes) or iRex Iliad(if you absolutely cannot live without handwritten notes)


If you think iRex is too costly (apart from the fact it has no support in US, you have to ship iRex to Germany) and it you want to READ pdfs without straining you eyes, definetely go for Kindle DX.

Thursday, June 18, 2009

Swine Flu

CDC has announced H1N1 flu as pandemic disease and my parents (back in India) were worried. Here are the few facts(as of June 12, 2009) that might ease their concern:
1. Respiratory mask are advised only to people with high risk of influenza (See table 1 at http://www.cdc.gov/h1n1flu/masks.htm)
Most of young college graduates do not fall into this category (unless you are studying health care or related fields). See http://www.cdc.gov/h1n1flu/masks.htm#footnote3

2. Number of confirmed or probable cases: 17,855
Number of Deaths: 44

Well, if you are an Indian, I guess you are pretty much immune to it (See Statistics of Malaria for India)
number of deaths | 9352 deaths per year
cause of death probability | 1 in 1110 ~~ 0.090%
rate of death | 1 death per 100000 persons per year
DAILY | 843 738 life years lost per year
DAILY rate | 80 life years per 100000 persons per year
For US, Statistics for Malaria are:
number of deaths | 3 deaths per year
cause of death probability | 1 in 768898 ~~ 0.00013%
rate of death | 0.0011 deaths per 100000 persons per year
DALY | 57 life years lost per year
Well, you can see statistically if you were not paranoid about fever or malaria or cold/cough in India (or US), you need not be worried about Swine flu either.

However, here are prescribed precautions by CDC for Swine flu:
  • Cover your nose and mouth with a tissue when you cough or sneeze. Throw the tissue in the trash after you use it.
  • Wash your hands often with soap and water, especially after you cough or sneeze. Alcohol-based hand cleaners are also effective.
  • Avoid touching your eyes, nose or mouth. Germs spread this way.
  • Try to avoid close contact with sick people.
  • If you are sick with a flu-like illness, stay home for 7 days after your symptoms begin or until you have been symptom-free for 24 hours, whichever is longer. This is to keep from infecting others and spreading the virus further.
  • Follow public health advice regarding school closures, avoiding crowds and other social distancing measures.
Reference: Statistics are gathered from Wolfram Alpha and CDC