tag:blogger.com,1999:blog-5094340343398123932.comments2023-02-21T09:52:10.243+01:00coding is like cookingEmily Bachehttp://www.blogger.com/profile/07321005413961705103noreply@blogger.comBlogger146125tag:blogger.com,1999:blog-5094340343398123932.post-62841124459033621422013-05-06T08:40:41.383+02:002013-05-06T08:40:41.383+02:00I think so, too. That´s how it´s done traditionall...I think so, too. That´s how it´s done traditionally.<br /><br />But I´m thinking: should we continue doing it like this?<br /><br />Because what it leads to is deep object graphs where logic (control structures and expressions) are smeared all over the place.<br /><br />More and more I find this a violation of the single responsibility principle.<br /><br />Consider this:<br /><br />class C {<br />..private IS _s;<br />..public C(IS s) { _s = s; }<br /><br />..public int F(int a) {<br />....var x = ... a ...;<br />....var y = _s.G(x);<br />....return ... y ...;<br />..}<br />}<br /><br />One could say F() has a single responsibility which uses function G() on some interface IS.<br /><br />So there should be only one reason for F() to change: if and only if some aspect of its responsibility changes. It might be, how x is calculated, changes.<br /><br />But that´s not true. There are more reasons for F() to change. Here´s one:<br /><br />If by application of the Interface Segregation Principle G() is moved to another interface, then F() as well as C have to change, too.<br /><br />So there is not only a dependency on some "G semantics" (or IS service for that matter) but also on where (!) this semantic is located in the environment of C. There is logical as well as topological coupling.<br /><br />That, to me, is opposing true message passing style programming. Because when I send a message (like an email or a SMS) I don´t care where the recipient is located right now.Ralf Westphal - One Man Think Tankhttps://www.blogger.com/profile/05225416366856069349noreply@blogger.comtag:blogger.com,1999:blog-5094340343398123932.post-46752398482192812362013-05-06T08:27:46.056+02:002013-05-06T08:27:46.056+02:00Ralf - I think the normal case in an OO design is ...Ralf - I think the normal case in an OO design is that an object has both logic and collaborators. You usually test different aspects in different test cases. Perhaps how this works will become clearer in my next post (which I'm working on) where I'll use an illustrative example.Emily Bachehttps://www.blogger.com/profile/07321005413961705103noreply@blogger.comtag:blogger.com,1999:blog-5094340343398123932.post-91406718747003425882013-05-05T17:05:14.281+02:002013-05-05T17:05:14.281+02:00I like the emphasis on message passing style.
But...I like the emphasis on message passing style.<br /><br />But why does an object still need collaborators? Why still such dependencies?<br /><br />That makes objects hard to specify: it´s 1+n interfaces, I´d say. 1 interface for the object/class itself, and n interfaces for classes it depends on.<br /><br />If such an object (or function) then also has its own logic... that seems a lot of stuff going on.<br /><br />Also these dependencies make it hard to test the object. Because you need to test two aspects at the same time: the logic the object is responsible for plus the correct interaction with any dependencies.Ralf Westphal - One Man Think Tankhttps://www.blogger.com/profile/05225416366856069349noreply@blogger.comtag:blogger.com,1999:blog-5094340343398123932.post-16951685109198893382013-05-03T21:00:05.369+02:002013-05-03T21:00:05.369+02:00Insightful,thanks.also helps me to reflect my test...Insightful,thanks.also helps me to reflect my test writing and design style.holger krekelhttps://www.blogger.com/profile/00985924698593515074noreply@blogger.comtag:blogger.com,1999:blog-5094340343398123932.post-91257826102991434322013-05-02T09:50:50.802+02:002013-05-02T09:50:50.802+02:00Fredrik - does this article describe what you mean...Fredrik - does this article describe what you mean by managers & workers? He calls them "Sergeant" and "Private" methods:<br /><br />http://feelings-erased.blogspot.se/2013/01/single-method-perspective-vs-single.html<br /><br />Interesting article, in any caseEmily Bachehttps://www.blogger.com/profile/07321005413961705103noreply@blogger.comtag:blogger.com,1999:blog-5094340343398123932.post-12166349869974623982013-04-30T15:18:30.018+02:002013-04-30T15:18:30.018+02:00Michel - there are lots of similarities. Surely yo...Michel - there are lots of similarities. Surely you can work it out for yourself.Emily Bachehttps://www.blogger.com/profile/07321005413961705103noreply@blogger.comtag:blogger.com,1999:blog-5094340343398123932.post-39261149616814140872013-04-30T11:50:59.035+02:002013-04-30T11:50:59.035+02:00So what about cooking?
What is, according to you...So what about cooking? <br /><br />What is, according to you, the same?Michelhttps://www.blogger.com/profile/04346278971884634079noreply@blogger.comtag:blogger.com,1999:blog-5094340343398123932.post-73790687751108461802013-04-22T12:59:52.557+02:002013-04-22T12:59:52.557+02:00So what I'm hearing is that if your code is we...So what I'm hearing is that if your code is well designed, the tests likely are still useful when you come to change that design. So you don't automatically throw unit tests away when the guiding test passes.<br /><br />I also think it's worth examining your second point in more detail. How do you break dependencies when unit testing, without using mocks? That sounds like a topic for another post.Emily Bachehttps://www.blogger.com/profile/07321005413961705103noreply@blogger.comtag:blogger.com,1999:blog-5094340343398123932.post-75773474999906915872013-04-19T15:59:06.570+02:002013-04-19T15:59:06.570+02:00I think there a couple of questions here.
- if yo...I think there a couple of questions here.<br /><br />- if you have code with a lot of mocks, then we regard that as a design smell. The test is telling you to break up the object into something simpler. With more smaller objects, I find I'm less likely to break the world when the design changes.<br /><br />- if I only have "real" objects, how do I break dependencies when I'm unit testing? Do I write some minimal implementations? In which case, I might as well use a framework and we're back to square one.<br /><br />- unit tests are not (just) about regression, they're also about guiding us to cleaner designs. If I rip out my unit tests after the system passes, I lose that feedback when I need to change the working code.<br /><br />What I see frequently enough in practice is complaints about the maintainability of bad code tested with mocks. If the structure is weak, then mocks are not my biggest problem. That's not to say never delete existing tests, but not to throw them all out either.Steve Freemanhttps://www.blogger.com/profile/05232096120523172306noreply@blogger.comtag:blogger.com,1999:blog-5094340343398123932.post-11139519430980764122013-04-19T09:02:34.570+02:002013-04-19T09:02:34.570+02:00Thankyou for your comments!
Fredrik - I agree you...Thankyou for your comments!<br /><br />Fredrik - I agree you could use both styles in the same system, depending on context. Would like a better elaboration of what you see as a "worker" class vs a "manager" class<br /><br />Ian - I think I'll be taking up issues around white/black box more in the third article in this series I'm planning.<br /><br />Holger - sounds like you're doing classic TDD then :-)<br /><br />Machiel - If you're using tests purely as a design tool and they give no regression protection then you could remove them I guess. I don't see many expert London School practitioners removing all their tests afterwards, although I think they may prune more than classic TDDers. Not sure on that point.Emily Bachehttps://www.blogger.com/profile/07321005413961705103noreply@blogger.comtag:blogger.com,1999:blog-5094340343398123932.post-71438706587047946872013-04-14T07:59:22.586+02:002013-04-14T07:59:22.586+02:00I often don't use Mocks but Stubs (using Mocki...I often don't use Mocks but Stubs (using Mocking tools). In my experience tying your test to the exact calls in your code, makes them rigid and refactoring hard. <br /><br />The reason to use Mocks is for design, the test can then really drive your design process. The essential consequence that everyone misses is that the test should be removed when you're done. Machielhttps://www.blogger.com/profile/04372146720135172369noreply@blogger.comtag:blogger.com,1999:blog-5094340343398123932.post-18874912984016824402013-04-10T20:23:01.555+02:002013-04-10T20:23:01.555+02:00Co-incidences :) Am on the travel for giving a two...Co-incidences :) Am on the travel for giving a two-day in-house course on testing (using pytest) and a major part of the exercises is going to cover and discuss mocks. I tend to discourage people from using mocking as much as possible. Testing collaborations can be an exception i guess. <br /><br />Looking forward to more insightful posts :)holger krekelhttps://www.blogger.com/profile/00985924698593515074noreply@blogger.comtag:blogger.com,1999:blog-5094340343398123932.post-36896974239290616652013-04-10T17:37:12.765+02:002013-04-10T17:37:12.765+02:00I like London School TDD - it feels more like a pr...I like London School TDD - it feels more like a proper framework for emergent design than Classic TDD, although I imagine, as Fredrik says, you won't use one style exclusively.<br /><br />My nagging concern is that, once I've written my tests, they always look quite trivial. I feel with Classic TDD that I treat the class under test as a black box, whereas with London School I end up taking more of a white box view. I wonder what I am really testing.Anonymoushttps://www.blogger.com/profile/09648262315336532102noreply@blogger.comtag:blogger.com,1999:blog-5094340343398123932.post-75932218411230789172013-04-10T15:40:40.562+02:002013-04-10T15:40:40.562+02:00I really see it as "as you work your way thro...I really see it as "as you work your way through /managers/ down to /worker/ classes", you move from mocking to classical style.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-5094340343398123932.post-15155513975356541242013-03-26T08:46:00.482+01:002013-03-26T08:46:00.482+01:00Here is my solution: https://gist.github.com/xpmat...Here is my solution: https://gist.github.com/xpmatteo/5243745<br /><br />In retrospect, the table-style test could have been applied to all cases, but this is how I left it at the end of my exercise.xpmatteohttps://www.blogger.com/profile/16626755265235840659noreply@blogger.comtag:blogger.com,1999:blog-5094340343398123932.post-26284155192110378662013-03-21T12:30:37.206+01:002013-03-21T12:30:37.206+01:00So you're saying that although Bobby's tes...So you're saying that although Bobby's tests are Readable, they might not be so Updatable if for example the constructor for GildedRose changed.<br /><br />I'd like to see some tests for this written as a fit table (hint!)<br /><br />Glad you enjoyed doing the kata.<br /><br />Emily Bachehttps://www.blogger.com/profile/07321005413961705103noreply@blogger.comtag:blogger.com,1999:blog-5094340343398123932.post-19514888744785518262013-03-19T17:53:35.282+01:002013-03-19T17:53:35.282+01:00Actually I believe that Bobby Johnson is missing a...Actually I believe that Bobby Johnson is missing a test that when the sellIn date is past and the initial quality is 1, then quality is 0 (and not -1).<br /><br />Apart from this, I think that these tests should be refactored. There is a lot of duplication, expecially in the first line of most tests. You would have to pay for this duplication if the constructor for the GildedRose class were to change. And if you do remove this duplication and get to something like<br /><br />givenItem(so-and-so); updatedQualityIs(so-and-so)<br /><br />you can explain the business case more clearly, by simulating fit tables in NUnit.<br /><br />Thanks for advertising this kata! It was fun to write the tests.xpmatteohttps://www.blogger.com/profile/16626755265235840659noreply@blogger.comtag:blogger.com,1999:blog-5094340343398123932.post-48530838920068095192013-03-19T13:28:45.940+01:002013-03-19T13:28:45.940+01:00Excellent post! It was pointed out to me the other...Excellent post! It was pointed out to me the other day that Roy Osherove's next editionof The Art Of Unit Testing lists 9 properties of good unit tests, so it's good to see you keeping the number under control :)<br /><br />We still differ on whether Maintainability should be considered a property in its own right, or something emergent from others. My feeling is that there is so much interdependence between all the foundational properties that identifying one of them as different doesn't gain us anything.Sebhttps://www.blogger.com/profile/04730257560880188186noreply@blogger.comtag:blogger.com,1999:blog-5094340343398123932.post-31159681558187081732013-03-02T10:51:59.446+01:002013-03-02T10:51:59.446+01:00Helpful article, thanks!
Please note a couple of ...Helpful article, thanks!<br /><br />Please note a couple of dead links and a new site:<br />* katacasts.com seems to have moved to<br /> katas.softwarecraftsmanship.org<br />* codingkata.org redirects to coding.io, there is no content on this site<br />* coderdojo.com seems to be a new initiative to encourage young people to learn codingAKataStudenthttps://www.blogger.com/profile/07159761608529987848noreply@blogger.comtag:blogger.com,1999:blog-5094340343398123932.post-63251031899168684572013-01-10T13:26:24.128+01:002013-01-10T13:26:24.128+01:00Andrew,
The point of the basic editor is partiall...Andrew,<br /><br />The point of the basic editor is partially as a leveller - you can pair more equally since neither person is in their comfort zone. I could say more, but I think it's a blog post of its own...<br /><br />I don't think it would be the same with ed (I havn't used ed, but I'm assuming it's a bit like vim) since the usability for a complete beginner is poor, and most people will be beginners.<br /><br />I'm not sure what point you're making with your account about Algol. Perhaps you could ellaborate in a blog post?Emily Bachehttps://www.blogger.com/profile/07321005413961705103noreply@blogger.comtag:blogger.com,1999:blog-5094340343398123932.post-86869098543372675532012-12-21T22:52:52.073+01:002012-12-21T22:52:52.073+01:00I agree that it does 'throw me out of my comfo...I agree that it does 'throw me out of my comfort zone.' Could you elaborate on how it helps get us to 'really concentrate on the way [we] code'? Would it apply equally well to using, say, 'ed' as the editor?<br /><br />BTW, I recently read an autobiographical account of the development of Algol for Burroughs: Stories about the B5000 and People Who Were There, Richard Waychoff, April 9, 1979. I thought you might be interested in this remark due its rejection of prototyping in favor of a code-last approach:<br /><br />...our benchmarks seem to encourage minimal thought given to the design of our software. We see benchmarks such as:<br /><br />A. Successful Clear/Start.<br /><br />B. BOJ for an object program.<br /><br />C. Simple program compiled.<br /><br />This kind of benchmarking almost demands that coding starts as early as possible. I would much rather see benchmarks such as:<br /><br />A. Design of the language complete.<br /><br />B. Design of the Scanner complete.<br /><br />C. Design of the Statement Parsers complete.<br /><br />D. Start of programming.<br /><br />E. Project successfully completed.<br /><br /><br />Somehow I have the impression that Detroit does not feel that we have time to produce products that are superior in innovation and quality. So I can understand Lonergan's opinion that no company, including Burroughs, is likely to duplicate the feat in today's environment.<br /><br />Andrew Dalkehttps://www.blogger.com/profile/17091314849699854287noreply@blogger.comtag:blogger.com,1999:blog-5094340343398123932.post-25639309225166539532012-12-20T12:50:35.020+01:002012-12-20T12:50:35.020+01:00The Management and Customer are more interested to...The Management and Customer are more interested to know about how much cost savings can be expected and achieved by implementing <a href="http://www.kualitatem.com/automation-testing/" rel="nofollow">Test Automation</a>. However, it is not always true that cost savings is achieved thank you sharing a good content nice job keep it upAnonymoushttps://www.blogger.com/profile/06736819142095843941noreply@blogger.comtag:blogger.com,1999:blog-5094340343398123932.post-1663432622038720252012-12-11T12:29:41.878+01:002012-12-11T12:29:41.878+01:00Hi Emily,
I've tracked down (and fixed) the fa...Hi Emily,<br />I've tracked down (and fixed) the fault where the output was not updated. <br />Cheers<br />JonJon Jaggerhttps://www.blogger.com/profile/11560463167349216675noreply@blogger.comtag:blogger.com,1999:blog-5094340343398123932.post-52154344286198698522012-11-28T13:38:58.665+01:002012-11-28T13:38:58.665+01:00I had a little go with your "pulse" tool...I had a little go with your "pulse" tool and it was cool! Emily Bachehttps://www.blogger.com/profile/07321005413961705103noreply@blogger.comtag:blogger.com,1999:blog-5094340343398123932.post-36252127221606837982012-11-27T15:48:41.842+01:002012-11-27T15:48:41.842+01:00Very interesting, I'll try CodersDojo this eve...Very interesting, I'll try CodersDojo this evening :)<br />If you use use Eclipse, you might be interested in http://www.happyprog.com/pulse/, a very plugin simple plugin that show your tdd-cycles (including refactoring !) "pulse".<br />There is also a playfull version, http://www.happyprog.com/tdgotchi/.<br />Btw, I don't understand why so less of your posts are commented ! Most of them are really interesting.Olivier Demeijerhttps://www.blogger.com/profile/07348362930477806539noreply@blogger.com