Some Rough Draft TDD Demonstration Videos 28

Posted by Brett Schuchert Wed, 31 Mar 2010 02:01:00 GMT

I’m doing a series of videos on TDD. The ultimate result will be a much more polished version with embedded slides, and such. But as a part of the development process, I’m creating scratch videos.

Much of what you see in these videos will be in the final versions, but those are far in the future relative to this work.

Hope you find them interesting.

Comments welcome.

Here is what is already available: Next up:
  • Removing violation of Open/Closed principle
  • Removing duplication in operations with a combination of the Strategy pattern and the Template Method pattern
  • Adding new operators after the removal of duplication.
  • Reducing coupling by using the Abstract Factory pattern, Dependency Inversion and Dependency Injection
  • Adding a few more operations
  • Allowing the creation of complex “programs” or “macros” by using the Composite pattern – and avoiding Liskov Substitution Principle inherent in the GoF version of the pattern
  • Driving the calculator via FitNesse + Slim

Anyway, that’s the plan. I’ll try to add each of these videos over the next few weeks.

Comments

Leave a response

  1. Avatar
    google?? about 2 hours later:

    Very Good , thank you!

  2. Avatar
    skim about 3 hours later:

    I look forward to this wonderful series. Thanks for doing this!

  3. Avatar
    Jörgen about 4 hours later:

    Looking forward to seeing the whole series!

  4. Avatar
    Marius about 5 hours later:

    Nice. Thank you for taking time to create this. This video lessons should be viewed also by .NET people. I liked the fact that you have explained even the most obvious things, this is very important. For example, in the first video you explained the bad smell code called “Feature Envy” and the solution to it. Great!!!!

  5. Avatar
    Jamie about 7 hours later:

    Simply amazing thanks Brett!

  6. Avatar
    JonKristian about 9 hours later:

    Awesome video. Very informative.

    Looking forward to the rest!

  7. Avatar
    Krzysztof Jelski about 9 hours later:

    Great videos! I especially liked your explanation of BDD style and the Testcase Class per Fixture pattern.

    I saw you run into problems with running all the tests together. My way of doing it is running the whole package first just as you did, but later on I use a shortcut bound to command “Rerun JUnit Test”. You can define shortcut for this action in eclipse preferences.

    Also note that if you press alt+shift+x, j (or mac equivalent) when the cursor is on a test method, then only this test is run.

  8. Avatar
    Krzysztof Jelski about 9 hours later:

    alt+shift+x, t I meant of course

  9. Avatar
    zhaorui about 9 hours later:

    in chinese, I don’t access the http://vimeo.com, would you mind give some other alternative web address or direct download address.

    thanks!

  10. Avatar
    Stefano Ricciardi about 10 hours later:

    Excellent stuff. A very nice refresher on the basics of TDD. Looking forward to next episodes.

  11. Avatar
    Klinger about 14 hours later:

    The first video is excellent.

    I look forward to see the rest of the series.

    It would be interesting if you could provide some info on how to handle the incorporation of the infrastructure/architectural “stuff” while practicing TDD/BDD. Things like db, logging, exception handling and so on.

    Big thanks.

  12. Avatar
    Brett L. Schuchert about 17 hours later:

    zhaorui,

    Try the following link: http://schuchert.wikispaces.com/VideoDemonstrations.

    That probably won’t work. If not, is there a site I can upload the videos to that you will be able to access? They are too big to email.

  13. Avatar
    Esko Luontola about 23 hours later:

    I browsed through the “Getting started” video and it looked promising (I’ll have a better look after sleeping).

    It appears that your style of organizing tests is quite close to my style, when you split the test class for RpnCalculator into ANewlyCreatedRpnCalculatorShould and ACalculatorWithThreeValuesShould. (Although I have dropped the “should” word long time ago, because it was not adding value but only noise. IMO, the value is in focusing on the behaviour/features, not in using some predefined words. But unfortunately many testing frameworks force the use of some predefined words, for example “should” or “it”, in the test names, so that it inclines the users to organize their tests always the same way, which sometimes is suboptimal.)

    A problem with JUnit is that it does not natively support that style of organizing tests, so by default I use some different testing framework. But since JUnit is popular and widely supported, it’s a good choice when teaching TDD. Fortunately it was quite easy to make a custom JUnit runner which allows nesting those test fixtures into one top-level test class (someday I’ll release that class as its own Maven artifact). Then it’s possible to put all the related tests into the same file using that style, so that it’s easier to get an idea that what some component/feature does, because everything that relates to that component/feature is in one place (here are some simple and more complex examples).

  14. Avatar
    Micha? Margiel 1 day later:

    I really liked your videos. I am sure that it took a lot of time to complete them so huge congrats to you.

    I just have few small comments :

    1. In ANewlyCreatedRpnCalculatorShould test class you do not need to declare @Before method. It would be enought to have just:

    private RpnCalculator calculator = new RpnCalculator();

    And this field will be initialize before every test method (just like @Before method).

    The same applies for OperandStackTest.

    2. I do not see any reasons to have both setAcumulator() and enter() methods. On mac calculator that you have shown “enter” is needed because one has to confirm that he/she finished typing the number. There is no need to do this in your program since you do not have any method that collects digits to create a number, so imho enter() is redundant.

    3. You should use code template named “test”. If you would write it in eclipse editor and then hit alt+space() twice then enter you would get template:

    @Before public void testname(){ }

    it will save you a lot of typing.

    4. to run all tests in single package just select it in “package explorer” and then just alt+shift+x,t(). To run all test in a single project again select it in package explorer view and hit the same short cut. It is a lot faster then context menu.

    5. I like that you do not put parenthesis in one line blocks of for/if/... we have the same convention in our company.

    6. why you are not splitting test method body into //given //when //then section? We are practicing this convention in our company and I have to admit that it gives additional readability.

    7. ctrl+/ for commenting selected lines ;)

    I hope to see more your videos.

    Cheers!

    (*) – ale my shortcuts are for non-mac keyboard of course ;)

  15. Avatar
    Micha? Margiel 1 day later:

    “eclipse editor and then hit alt+space() twice then enter you would get template: “

    of course ctrl +space not alt+space

    @Esko If think that Categories in JUnit is something, you can use to group few Test Classes into one. Maybe its API is not so great :) but Kent Beck posted1 that he wants to change it in future JUnit releases.

    [1] http://www.threeriversinstitute.org/blog/?p=456

  16. Avatar
    Brett L. Schuchert 3 days later:

    I should use more shortcuts. Problem is, I keep switching languages and development environments and OS’s, so it’s tough to get they into muscle memory. That’s a good thing for a kata!

    As for using a template, I won’t do that unless I show setting it up. In fact, if you notice in those videos, I end up with an extra “}” quite often. I use a vi plugin for eclipse and it works much better to turn off that feature. But I’m doing close to native eclipse, so there won’t be any surprises. However, I think it would be useful (based on this feedback) to:
    • Set up a template
    • Configure Eclipse
    • Mention that I’ve done this early on (and maybe remind people of that fact)
    • Have a video with that configuration and setup.

    Regarding not using @Before versus using it. Old habits die hard. In any case, I’m not convinced of that behavior across xunit testing tools, I use multiple tools, so I try to keep habits that will work in all situations.

    I will say, however, I’ve been VERY tempted to do that. In fact, I did that in one of the videos (I think), then I “fixed” it. That’s a style issue for me.

    Esko wrote:

    I have dropped the “should” word long time ago, because it was not adding value but only noise
    ... You forgot to add “in your opinion” to that. You’ve stated this “fact” as truth, but in fact that’s your opinion. We’ve already had several arguments you and I.

    Micha wrote:

    6. why you are not splitting test method body into //given //when //then section?

    I don’t do that for several reasons:
    • Never picked up the habit.
    • Think it can make the test longer and not add a lot of value
    • Prefer the “given” as the fixture
    • Prefer one or afew number of “then”, which is the last line

    However, I do like that style for acceptance tests and integration tests. I just don’t like the ceremony for unit level tests. AND this is all my opinion. If that form of organization works for you/your group/your company, you should continue do it.

  17. Avatar
    Esko Luontola 3 days later:

    ... You forgot to add “in your opinion” to that. You’ve stated this “fact” as truth, but in fact that’s your opinion.

    You didn’t directly say it, but is it your opinion that the “should” word brings value? Could you expand on that? What in your opinion is the difference between “new calculator has 0 in its accumulator” and “new calculator should have 0 in its accumulator”?

  18. Avatar
    following@thevideo.com 3 days later:

    FYI The last two videos 7 (mockito) +8 (factory) do not have commentary…silence! Someone mentioned that the downloaded movie had sound, but I would rather not have to register for vimeo.

    Really enjoying this series you’re putting together. I appreciate this as I am trying to become a TDD developer, but do not have anyone to work with/learn from. thanls

  19. Avatar
    Derek Smyth 3 days later:

    enjoyed the introduction video very much and like the idea of using BDD naming in the unit tests (the idea of context driven test fixtures). This approach was new to me and I like it.

    one suggestion, if you don’t mind, your not covering both the inner and outer loop of TDD. It would be good to see an example of an outer acceptance test driving the inner unit testing.

    looking forward to the rest of the series and just want to say thanks for putting these videos together and making them available.

  20. Avatar
    Matt W. 4 days later:

    Brett, Thanks for fixing the audio on the last couple of videos. Really enjoying the series, and I am following along with my own project in C#. cheers!

  21. Avatar
    AVI to iPad Converter 19 days later:

    iPad Mate, enjoy the hd video freely on iPAD

  22. Avatar
    five finger shoes about 1 month later:

    i believe you are good at writing. a good writter need many good topics

  23. Avatar
    m2ts to mkv converter about 1 month later:

    M2TS to MKV Converter is the best software for user to convert M2TS to MKV file, With the powerful M2TS to MKV converter,you can convert M2TS to MKV with best quality and convert M2TS to all the video formats.m2ts to mkv converter

  24. Avatar
    http://www.daniusoft.com/convert-ipad/put-movies-on-ipad.htmlconvert movies to iPad@ 3 months later:

    Good idea to make a series of videos on TDD. AVI to iPad

  25. Avatar
    burn MP4 to DVD Mac 3 months later:

    Nice work! Keep up your good job.

  26. Avatar
    pice suit dress 4 months later:

    Sorching summer, is coming. The most comfortable, put a cool and refreshing way, wear a dress out of fashion, wear a comfortable , should be the one summer MMS chasing dreams. Bright colours by all the summer dress up, also can let your mood will no longer dry frowsty upset!

  27. Avatar
    Blouse 4 months later:

    Flower skirt seems to be in summer, forever ChanYi as thin as the flower skirt, can not only a cool summer, and all sorts of design and color, let you do in summer “ever-changing princess”, plus all sorts of collocation, individual character is dye-in-the-wood, the flower skirt collocation of snow, cowboy ma3 jia3, formed the integral style of contrast, let you both cooling and handsome!Tie-in skill: flower skirt handsome ma3 jia3

  28. Avatar
    supplynflshop 5 months later:

    thanks for sharing

Comments