Chapter 3. Our Project

Let's build an online lottery system. Imagine that our client is a lottery operator from Tristan da Cunha, and they want to open their lottery to the world.[7]

Lottery rules

The lottery operator organises weekly draws, in which punters pick six out of forty possible balls. All the money from lottery tickets goes into the draw pool before the draw. The lottery operator takes a large part of the money for operational costs and the rest is divided amongst the winners. (Money available for prizes is called the payout pool). Several prizes are allocated from this pool, typically grouped by the winning combination. So, for example, 68% of the payout pool is reserved for people who guess correctly all six numbers — they all get a share of the 6-out-of-6 prize. All the winners in the 5-out-of-6 category share 10% of the payout pool, and so on.

Our task is to develop a system that will enable players to purchase tickets and participate in lottery draws. Players will have an online account where they will be able to deposit money with their credit card or by wire transfer. All winnings will be paid into this account automatically when the operator enters draw results into the system , and the players will be able to spend money from the account to buy new tickets or withdraw the money by wire transfer. The operators will typically offer draws for the next two months online.

[Note]Stuff to remember
  • First write a test that fails, then write code to make it pass, then clean up and retest.

  • The first step in development is to describe acceptance tests that define when the work is done.

  • Test to prevent defects, not to find them.

  • Guidance tests should always reflect the intention, not the implementation.

  • Unit tests focus on the code, acceptance tests focus on customer benefits.

  • When you hear “acceptance test”, think about “executable specification”.



[7] Tristan de Cunha is the most remote inhabited archipelago in the world. They probably don't have Internet access or a local lottery on the island, but with a bit of imagination, this application will serve well as an example. See http://en.wikipedia.org/wiki/Tristan_da_Cunha.