Junilu Lacar wrote:I have a number of other comments about your test and main program code but will hold those back for later in this conversation. I think it will be worthwhile for you to start over and do your TDD cycle here, step by step, so we can get a better sense of your understanding of the technique. That way you can get proper guidance and feedback and the experience will more closely approximate one that you would have if you were doing pair or mob programming, which IMO is the best way to do TDD.
Tomek Kaczanowski wrote:By writing tests first, you have a chance of creating an API that is convenient for a client to use. Your test is the first client of this newly born API. This is what TDD is really about: the design of an API.
Junilu Lacar wrote:
If you really want to see what TDD is like, throw away everything that you've done and start over. I can be your partner. I will give you feedback at every step but you have to be patient and not get ahead of yourself or the process.
If you are ready to do that, then first start by replying with the general requirements for this password validator.
And DON'T write any code yet!
Junilu Lacar wrote:
(snip for brevity)
Anyway, I believe that most people who swear by TDD are in the designers camp and that criticism of TDD is directed mainly from experience with people from the verifiers camp. So, if you're going to see how TDD can really benefit, I think it's better if you approach it with a focus on coming up with a good design rather than verifying that your program works as you want it to work.
Jeremy Moore wrote:...going back to TPD - Test in production development :P
Junilu Lacar wrote:Here's one thing to retrospect about: Tell me what you think about this statement: "A failure is the test's way of saying that you have permission to write some production code."
So, are you ready to move forward at this snail's pace? If you are, then answer the questions: "What else can we refactor and why do you think you need a setter method?"
Jeremy Moore wrote:I need a setter method to implement requirement " Validator should check for a minimum length."
Junilu: "Introducing a variable in the test right now is premature. What's the simplest thing we could possibly do with this call?"
Jeremy Moore wrote:Is it just this ?
Junilu Lacar wrote:
Next step: What is the least amount of production code that you could possibly write to make this failing test pass? Remember, it has to be the least amount, and the simplest and most straightforward code you could write. It can even be "stupid" code. It really doesn't matter if you feel it's the "wrong" code to write. We will fix that later when the code tells us how to fix it. I'll give you a hint: you only have to change ONE WORD in the production code.
I like to think of it as something like sculpting stone. You have this big, shapeless block of white stone. You very slowly and carefully chip away at the white parts to reveal the colored parts beneath. You keep chipping away like that until you have revealed the colorful, beautifully shaped statue that was there all along.
Jeremy Moore wrote:After that, I am stuck. I am now thinking what to do next
Jeremy Moore wrote:I don't know why I chose "checkPasswordSize". Maybe I should rename that to checkPasswordMinimumSize.
There is no test to check if you can set the min length in the validator. So, should I add a test for that now ?
Junilu Lacar wrote:
Then, going back to design thinking again, I would say something like "Before we rename that method, let's think about the semantics of the API a little bit."
What should client code that uses a PasswordValidator look like? Here's what I can imagine:
Does that seem reasonable to you? Can you suggest an alternative way to interact with a PasswordValidator?
Jeremy Moore wrote: Yes, Enumeration is the right choice.
I am wondering if I should have one public checker method which will make use of private methods to check min length, max length, max capital chars etc.
I'll think this through.
moose poop looks like football shaped elk poop. About the size of this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
|