The first principle is that you must not fool yourself�and you are the easiest person to fool.
In 1974, Richard Feynman gave a speech at the graduation ceremony at Caltech. He talked about what he called cargo cult science and about maintaining your scientific integrity.
Cargo cults formed in the Pacific after the Second World War. The native tribes on several Pacific Islands were exposed to western manufactured goods. Not knowing of western manufacturing processes, the tribes believed these goods were gifts from the ancestors. When the westerners left after the war, the planes carrying the manufactured goods stopped landing. To please the ancestors, and to make the planes land again, the tribes built runways, built control towers, and fashioned radio headsets out of straw and coconuts. They manned these radio towers, staged military drills and marches, set up cross shaped grave markers. They replicated the conditions that had caused the planes to land before, but the planes did not land.
The tribes were wrong in their belief of the cause of the cargo, but as Feynman pointed out, scientist can make similar mistakes.
One example: Millikan measured the charge on an electron by an experiment with falling oil drops, and got an answer which we now know not to be quite right. It's a little bit off, because he had the incorrect value for the viscosity of air. It's interesting to look at the history of measurements of the charge of the electron, after Millikan. If you plot them as a function of time, you find that one is a little bigger than Millikan's, and the next one's a little bit bigger than that, and the next one's a little bit bigger than that, until finally they settle down to a number which is higher.
Why didn't they discover that the new number was higher right away? It's a thing that scientists are ashamed of�this history�because it's apparent that people did things like this: When they got a number that was too high above Millikan's, they thought something must be wrong�and they would look for and find a reason why something might be wrong. When they got a number closer to Millikan's value they didn't look so hard. And so they eliminated the numbers that were too far off, and did other things like that. We've learned those tricks nowadays, and now we don't have that kind of a disease.
They doubted their own results because they had a misplaced faith in Millikan's results. They has fooled themselves, and by doing so had made their own experiments pointless. What is the point of doing an experiment if only one result is acceptable.
Feynman talks about some of the things that are required for scientific integrity, beyond not fooling yourself: you need to publish your results regardless of the outcome, you need let people know of every way you can think of that might invalidate your results, you need to state any alternative interpretations of the results that you can think of that might also explain your results.
I'm talking about a specific, extra type of integrity that is not lying, but bending over backwards to show how you are maybe wrong, that you ought to have when acting as a scientist.
Sometimes, Feynman points out, it is business or politics that get in the way of integrity. A government adviser often won't be allowed to publish results that go against the views of the government. It is not really scientific advice at that point, it is just bad science.
Often scientist won't be allowed to repeat previous experiments on their own apparatus before trying an extension to that experiment (why waste money when you won't discover anything new?). This is also bad science. You can't know that you control all the things you need to control to produce valid results. Thus, even if you do discover something interesting, people will have good reason to doubt you.
Feynman ends by wishing the graduating students the freedom to have integrity.
So I have just one wish for you�the good luck to be somewhere where you are free to maintain the kind of integrity I have described, and where you do not feel forced by a need to maintain your position in the organization, or financial support, or so on, to lose your integrity. May you have that freedom.