Created
June 10, 2011 09:51
-
-
Save gregoryyoung/1018566 to your computer and use it in GitHub Desktop.
Probability Kata part 2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
OK so now you have implemented the kata. Your tests should look something like this: | |
We can say that the tests define the object "in a calculus of itself". They are not state based tests, they define how the behaviours of the object interact with each other. | |
To see the real value of this let's introduce some change ... I hear real system's do this occasionally. Because this is a high performance system decimal math is too slow. You now need to use floats instead. | |
Need help on floating point math? Check out: http://www-users.math.umd.edu/~jkolesar/mait613/floating_point_math.pdf | |
You will need to use a non-exact equality... How will this change your code? | |
Are you doing a refactor for this or a refuctor? Did you change a test? If you did the kata right you should not have any changes to your tests to make this change. | |
Remember there is no such thing as changing a test. A change to a test is a new test | |
you have no saftey net from it. Changing a test means a refuctor |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here's what I did:
Ok, so I didn't actually implement the floating point math. I'm free to do so without any change to my tests since the Probability class is properly encapsulated. I know from experience that comparing floats probably cannot be reliably satisfied by a simple override of object.Equals, but I guess it is enough for this excercise.