What Makes a Good Test?

The following are some generic rules that are valid for any unit test and not just PHPUnit:

Independent: Each test needs to run independently from other tests
and environments.

Fast: To have useful tests and be able to run them as often as possible
(for example, as pre- or post-commit hooks), tests need to be fast.

Repeatable: You should be able to run a test as many times as you want with the same result.

Up to date: Tests are written once, but code can be changed or extended. If you are not going to keep tests up to date, the initial investment in tests will be just a waste of time and money. The rule is, whoever breaks the test, fixes the test.

Short: Tests should be just a few lines—easy to read and understand.

Resilient: Once written, tests shouldn’t change till the behavior of tested
class/method changes.

PHPUnit Essentials  – by Zdenek Machek

Creative Experiments in Science

It is a surprising and extraordinary fact that Micheal Faraday derived all his insights from creative experiments, precise observations and an understanding of how nature works.

Faraday’s most important invention was and IS the generator. Instead of weak and expensive batteries, the generator opened up the possibility of large scale cheap power. Even today, all electricity produced by generators goes back to the principle of electromagnetic induction discovered by Faraday.

His contribution to humanity is hard to describe with just a few paragraphs. He was also son of a blacksmith, worked at a shop that bound paper into books and was horrible at math.

“How I Explained REST to My Wife” REST part 1

Wife: Who is “Roy Fielding”?

Ryan: Some guy. He’s smart.

Wife: Oh? What did he do?

Ryan: He helped write the first web servers and then did a ton of research explaining why the web works the way it does. His name is on the specification for the protocol that is used to get pages from servers to your browser. Continue reading “How I Explained REST to My Wife” REST part 1

Let’s Make The Code World A Better Place – #2

The Primal Conundrum

Programmers face a conundrum of basic values. All developers with more than a few years experience know that previous messes slow them down. And yet all developers feel the pressure to make messes in order to meet deadlines. In short, they don’t take the time to go fast! True professionals know that the second part of the conundrum is wrong. You will not make the deadline by making the mess. Indeed, the mess will slow you down instantly, and will force you to miss the deadline. The only way to make the deadline—the only way to go fast—is to keep the code as clean as possible at all times.

Clean Code