piątek, 24 maja 2013

Code Kata: shopping list search

We have a list of, let's say, goods we bought at a shop (or you can imagine any other list that you like):

|        Name        |      Quantity      |       Price      |
|        Beer          |           10          |        30            |
|       Pickles        |           1           |        12            |
|     Red beans    |            2           |        22            |

The task is to write a piece of code that will search through the list and will display each row that matches search criteria. Too simple? Maybe. But consider these additional hints:
  • search criteria may not be exact. The string "bean" might match "Red beans"
  • we may even be searching for any of a few items: rows one and three will both match if our search criteria are "any of 'beer', 'bean' ".
I recommend that you start this kata with an exact search for one item and then gradually move towards the "like/contains" criteria and to "any of" criteria and that you observe the impact these changes will have on your unit tests (needless to say, this should all be done using TDD).

Brak komentarzy:

Prześlij komentarz