Re: [testdrivendevelopment] "bottom-up" TDD and common behaviors
"Ron Jeffries" <[email protected]> Tue, 3 Dec 2019 07:49:53 -0500
| Newsgroups | gmane.comp.programming.test-driven-development |
|---|---|
| Message-ID | <[email protected]> |
--Apple-Mail=_8BCEED05-D50C-43DF-9605-7AF9E4859542 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii Hi Brian, I certainly don't know ... I'll think aloud and in terms I understand and = see what happens. I know less than nothing about Elixir. > On Dec 2, 2019, at 7:18 PM, Brian Marick <[email protected]> wrote: >=20 > However, for various reasons, I was trying to avoid the use of mocks in = this app. So, if you were doing this in a non-mockish way, what tests would= you have? (Remember, there are four functions that do pretty much the same= thing.) I'm pretending that I just sat down to pair with you, all full of total ig= norance but great curiosity. It seems to me that this operation, read and make updatable (maybe form-co= mpatible), would properly be a constructor.=20 I guess that updatable! returns an updated animal (or hurls). I guess anim= al -> is magically the return result of the Read. I guess that functions re= turn the last thing computed and that put_updatable_fields() will return th= e animal it updates.=20 I want a test, probably, for put_updatable_fields, and it needs to check a= ll the fields. Since that takes and returns an animal, it can be tested wit= h a canned empty animal and a canned full one and an irritating compare equ= al of some kind. But in mocks, I think it'd be much the same, since we have= to check each field to see if it has been changed.=20 I guess if I were mocking, then I'd just do the mock thing you show that s= ays that updatable! does in fact call the put. Since I wouldn't likely be m= ocking (Detroit school, y'know), what would I do? I'd write a test that wou= ld fail if some should-be-updatable field wasn't updatable. (Which I really= think means displayable or something.) I'm guessing that a non-updatable animal is still a valid animal. (That mi= ght be a bug.) It appears that updatable is a pure cosmetic thing to get th= e form to work, and that the animal has no reason to know whether it is upd= atable. I'm wondering why they aren't always made updatable out of the box.= (Complete Constructor Method). If they were, would that change our thinkin= g on how to do this? I think it might: we don't worry any more. Anyway, now we're writing four functions which, I guess? could conceivably= read animals wrongly, not calling updatable! and we want to be sure that t= hey do? Tell the truth, since this is a display issue (?), I think I'd just look. = If I worry that someone will try to make these four functions more efficien= t by removing the updatable bit, though, I need tests. So either A) I'd have only one way to get an animal and it would be updata= ble, end of story I think, or B1) write tests for each of those four functions. Do whatever is_updatable= checking one does, one or many fields, etc.=20 B2) observe duplication and remove it. (def check_is_updatable(animal))? I'm just about certain that I've missed some key thing here. What is it? Ron Jeffries ronjeffries.com <http://ronjeffries.com/> Everything that needs to be said has already been said. But since no one was listening, everything must be said again. -- Andre Gi= de -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#35801): https://groups.io/g/testdrivendevelopment/mess= age/35801 Mute This Topic: https://groups.io/mt/64491946/3268755 Group Owner: [email protected] Unsubscribe: https://groups.io/g/testdrivendevelopment/leave/6156322/74455= 6386/xyzzy [[email protected]] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- --Apple-Mail=_8BCEED05-D50C-43DF-9605-7AF9E4859542 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=us-ascii <html><head><meta http-equiv=3D"Content-Type" content=3D"text/html; charset= = =3Dus-ascii"></head><body style=3D"word-wrap: break-word; -webkit-nbsp-mod= e: space; line-break: after-white-space;" class=3D"">Hi Brian,<div class=3D= ""><br class=3D""></div><div class=3D"">I certainly don't know ... I'll thi= nk aloud and in terms I understand and see what happens. I know less than n= othing about Elixir.<br class=3D""><div><br class=3D""><blockquote type=3D"= cite" class=3D""><div class=3D"">On Dec 2, 2019, at 7:18 PM, Brian Marick &= lt;<a href=3D"mailto:[email protected]" class=3D"">[email protected]</a= >> wrote:</div><br class=3D"Apple-interchange-newline"><div class=3D""><= span style=3D"caret-color: rgb(0, 0, 0); font-family: ArialMT; font-size: 1= 8px; font-style: normal; font-variant-caps: normal; font-weight: normal; le= tter-spacing: normal; text-align: start; text-indent: 0px; text-transform: = none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0p= x; text-decoration: none; float: none; display: inline !important;" class= =3D"">However, for various reasons, I was trying to avoid the use of mocks= in this app. So, if you were doing this in a non-mockish way, what tests w= ould you have? (Remember, there are four functions that do pretty much the = same thing.)</span></div></blockquote><br class=3D""></div><div>I'm pretend= ing that I just sat down to pair with you, all full of total ignorance but = great curiosity.</div><div class=3D""><br class=3D""></div>It seems to me t= hat this operation, read and make updatable (maybe form-compatible), would = properly be a constructor. </div><div class=3D""><br class=3D""></div>= <div class=3D"">I guess that updatable! returns an updated animal (or hurls= ). I guess animal -> is magically the return result of the Read. I guess= that functions return the last thing computed and that put_updatable_field= s() will return the animal it updates. </div><div class=3D""><br class= = =3D""></div><div class=3D"">I want a test, probably, for put_updatable_fie= lds, and it needs to check all the fields. Since that takes and returns an = animal, it can be tested with a canned empty animal and a canned full one a= nd an irritating compare equal of some kind. But in mocks, I think it'd be = much the same, since we have to check each field to see if it has been chan= ged. </div><div class=3D""><br class=3D""></div><div class=3D"">I gues= s if I were mocking, then I'd just do the mock thing you show that says tha= t updatable! does in fact call the put. Since I wouldn't likely be mocking = (Detroit school, y'know), what would I do? I'd write a test that would fail= if some should-be-updatable field wasn't updatable. (Which I really think = means displayable or something.)</div><div class=3D""><br class=3D""></div>= <div class=3D"">I'm guessing that a non-updatable animal is still a valid a= nimal. (That might be a bug.) It appears that updatable is a pure cosmetic = thing to get the form to work, and that the animal has no reason to know wh= ether it is updatable. I'm wondering why they aren't always made updatable = out of the box. (Complete Constructor Method). If they were, would that cha= nge our thinking on how to do this? I think it might: we don't worry any mo= re.</div><div class=3D""><br class=3D""></div><div class=3D"">Anyway, now w= e're writing four functions which, I guess? could conceivably read animals = wrongly, not calling updatable! and we want to be sure that they do?</div><= div class=3D""><br class=3D""></div><div class=3D"">Tell the truth, since t= his is a display issue (?), I think I'd just look. If I worry that someone = will try to make these four functions more efficient by removing the updata= ble bit, though, I need tests.</div><div class=3D""><br class=3D""></div><d= iv class=3D"">So either A) I'd have only one way to get an animal and it wo= uld be updatable, end of story I think, or</div><div class=3D""><br class= =3D""></div><div class=3D"">B1) write tests for each of those four functio= ns. Do whatever is_updatable checking one does, one or many fields, etc.&nb= sp;</div><div class=3D"">B2) observe duplication and remove it. (def check_= is_updatable(animal))?</div><div class=3D""><br class=3D""></div><div class= = =3D"">I'm just about certain that I've missed some key thing here. What is= it?<br class=3D""><div class=3D""> <div style=3D"color: rgb(0, 0, 0); letter-spacing: normal; orphans: auto; = text-align: start; text-indent: 0px; text-transform: none; white-space: nor= mal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-= wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white= -space;" class=3D""><span class=3D"Apple-style-span" style=3D"border-collap= se: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-style: norm= al; font-variant: normal; font-weight: normal; letter-spacing: normal; line= -height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; te= xt-transform: none; white-space: normal; widows: 2; word-spacing: 0px; bord= er-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-str= oke-width: 0px;"><div class=3D""><br class=3D"Apple-interchange-newline">Ro= n Jeffries</div><div class=3D""><a href=3D"http://ronjeffries.com" class=3D= "">ronjeffries.com</a></div><span class=3D"Apple-style-span" style=3D"borde= r-collapse: separate; border-spacing: 0px;"><div class=3D"">Everything that= needs to be said has already been said.</div><div class=3D"">But since no = one was listening, everything must be said again. -- Andre Gide</div></span= ></span></div> </div> <br class=3D""></div></body></html> <div width=3D"1" style=3D"color:white;clear:both">_._,_._,_</div> <hr> Groups.io Links:<p> You receive all messages sent to this group. <p> <a target=3D"_blank" href=3D"https://groups.io/g/testdrivendevelopment/mes= sage/35801">View/Reply Online (#35801)</a> | <a target=3D"_blank" href=3D"mailto:[email protected]?subj= ect=3DRe:%20Re%3A%20%5Btestdrivendevelopment%5D%20%22bottom-up%22%20TDD%20a= nd%20common%20behaviors">Reply To Group</a> | <a target=3D"_blank" href=3D"mailto:[email protected]?subject= = =3DPrivate:%20Re:%20Re%3A%20%5Btestdrivendevelopment%5D%20%22bottom-up%22%= 20TDD%20and%20common%20behaviors">Reply To Sender</a> | <a target=3D"_blank" href=3D"https://groups.io/mt/64491946/3268755">Mu= te This Topic</a> | <a href=3D"https://groups.io/g/testdrivendevelopment/post">New Topic</a>= <br> <br> <a href=3D"https://groups.io/g/testdrivendevelopment/editsub/3268755">Your= Subscription</a> | <a href=3D"mailto:[email protected]">Contact Group Own= er</a> | <a href=3D"https://groups.io/g/testdrivendevelopment/leave/6156322/7445563= 86/xyzzy">Unsubscribe</a> [[email protected]]<br> <div width=3D"1" style=3D"color:white;clear:both">_._,_._,_</div> --Apple-Mail=_8BCEED05-D50C-43DF-9605-7AF9E4859542--