I made a really lame mistake in logic. Have you seen anything as lame as this ?
I was making a password validator class. Requirements were - check for min pass size, max pass size, min number of capital letters, min number of digits etc. I decided to have only a default, no args constructor. For the the min pass size and max pass size, I had setter methods. These setter methods had the following logic -
Also, you are not allowed to set the value below 1 for minSize or maxSize. After I finished adding the logic above, and ran the tests which I hoped would pass,
Junit threw the error "cannot initialize" the password validator. Duh ! Makes sense now. The minSize = 1 and maxSize = 1 by default. So, if you set any of those variables with a value > 1 using the setters, an exception will always be thrown and you can never set them. I feel so stupid now. But, the consoling fact is that I did not write any more validation methods and then discover this huge elephant size bug. Maybe I should have a constructor or single setter method that takes minSize and maxSize and does the checking instead of having separate setters.
Was this my stupidity or just the benefits of TDD ?