The day I understood TDD

6 באפריל 2010

תגיות: , , ,
8 תגובות

My blog has moved. You can view this post at the following address: http://blog.drorhelper.com/2010/04/day-i-understood-tdd.html

הוסף תגובה
facebook linkedin twitter email

כתיבת תגובה

האימייל לא יוצג באתר. (*) שדות חובה מסומנים

8 תגובות

  1. Paco8 באפריל 2010 ב 0:47

    // You are writing more code than tests
    internal class DiscreteNumberValueGenerator
    {
    private static byte lastValue = 0;
    private static bool odd;

    public object GetNextValue()
    {
    The_current_tests_will_still_be_green();
    return lastValue++;
    }

    public void Reset()
    {
    lastValue = 0;
    }

    private void The_current_tests_will_still_be_green()
    {
    odd = !odd;
    if (odd)
    {
    Reset();
    }
    }
    }

    להגיב
  2. tobi8 באפריל 2010 ב 1:26

    your implementation only generates 256 distinct values. seems like you are missing a test to guard against this ;-)

    להגיב
  3. N8 באפריל 2010 ב 8:10

    I still can't work out if this is a parody or not.

    להגיב
  4. dhelper8 באפריל 2010 ב 9:34

    Thanks for the comments

    1. This is not a parody – this is in fact how it was done (and should be done)
    2. I know we only support 256 unique values which is ok for this problem domain (we only needed two)
    3. Keep in mind that due to lack of interest I didn't put all of the test suite in this post nor did I wrote the whole implementation – I just wanted to explain how TDD was used in a real world problem. So if it seems that something is missing, its because it is.

    להגיב
  5. AH8 באפריל 2010 ב 10:42

    +1 for the previous comment :-)

    להגיב
  6. James8 באפריל 2010 ב 12:45

    Did you actually need a value generator that generated a value for all those types? Or did you want to make it more generic because that gives you something more reuseable?

    להגיב
  7. dhelper8 באפריל 2010 ב 13:17

    Because we've created the ValueGenerator using TDD I can guarantee that it only does what we needed it to do.

    להגיב
  8. SirAsad8 באפריל 2010 ב 14:38

    Good Initiate,
    Thanks to Share your Experience.

    להגיב