Improving Testability of GUI Code, an Eample 46

Posted by Brett Schuchert Fri, 11 Sep 2009 04:08:00 GMT

Just finished first draft. More to come, questions/comments appreciated.

http://schuchert.wikispaces.com/tdd.Refactoring.UiExample

Comments

Leave a response

  1. Avatar
    Mark Roddy 3 days later:

    I’d suggest changing the validateUrl() method (later renamed validate) to accept the ‘String body’ variable as it’s argument.

    This solves the problem of the method being aware of the user interface code (as does the TextSource interface), but it also removes the dependency on the external interface (ala Law of Demeter).

  2. Avatar
    Brett L. Schuchert 5 days later:

    Mark,

    1. I like the idea of passing in the String. It does not resolve the problem of reporting both an error message and success or failure. There are ways around that. E.g., retuning a “result” object that has success/failure and the optional error message. That’s certainly an option. I’ve actually used both options in different systems and I cannot say that one is clearly better than the other. (Returning back a string that is empty for “success” and otherwise an error message is another option. I think that is a bit messy, but it would also certainly work.)

    2. Law of Demeter violation. Passing in an interface is not a violation of the Law of Demeter. Sending message to that interface is also not a violation. There is a violation if I send message to the String I get back from the interface.

    Violation of the Law of Demeter is a problem because it introduces structural coupling. Sometimes violating the law is a better option that the potential interface bloat that can be associated with not violating. Typically, for long chains, removing part of the violation is the best option. This example is not that situation, however.

    In this case, the violation doesn’t seem too bad since the dependency is on a string. The risk of that needing to change is small, so the potential down side is small.

    Technically for the UrlValidator there is no violation since it gets a string and the passes it to another object. It does not send a message, so no violation. I cannot get away with that in the other two validators, however.

    So then the question is this: Is the violation of the Law of Demeter (sending message to the string) plus the introduction of an interface better or worse than returning a composite object (or a string which must be interpreted – let’s rule this option out – in real systems we typically return all errors not just one, so the string itself becomes a composite string – /ugly/).

    I’m not sure there’s enough context to decide. We either introduce an interface or a concrete class (the return object). So no win there. There is the creation of an instance of a return object versus no object creation (plus in the pass in the interface option). Again, I’m not convinced that there’s enough to make a decision.

    I think I still prefer the interface over passing in the string when considering that there are 2 return values (success/failure and error message). But, it certainly doesn’t rule out your suggestion. It’s just my preference

  3. Avatar
    isaiah 13 days later:

    Have you considered using a GUI testing framework such as http://code.google.com/p/windowlicker/

  4. Avatar
    Brett L. Schuchert 15 days later:

    isaiah,

    Yes, of course. However, such tools are only one piece of an overall checking (to use Michael Bolton’s term) strategy.

    The refactoring introduces a separation of concerns that should have been there in the first place. This allows for focused verification of functionality without having to resort to a “gui driver.”

  5. Avatar
    ed hardy 24 days later:

    Good post….thanks for sharing.. very useful for me i will bookmark this for my future needed. thanks for a great source.

  6. Avatar
    nike shoes hosting 3 months later:

    The refactoring introduces a separation of concerns that should have been there in the first place. This allows for focused verification of functionality without having to resort to a “gui driver.”

  7. Avatar
    FLV extractor 7 months later:

    chang it

  8. Avatar
    four loco 10 months later:

    I agree, this should only be one tool in a multi-valent set of strategic checking. I agree, in this instance, that passing in the string is a little dangerous when you have multiple return values.

  9. Avatar
    cheap vps 11 months later:

    So then the question is this: Is the violation of the Law of Demeter (sending message to the string) plus the introduction of an interface better or worse than returning a composite object (or a string which must be interpreted – let’s rule this option out – in real systems we typically return all errors not just one, so the string itself becomes a composite string – /ugly/).

    I’m not sure there’s enough context to decide. We either introduce an interface or a concrete class (the return object). So no win there. There is the creation of an instance of a return object versus no object creation (plus in the pass in the interface option). Again, I’m not convinced that there’s enough to make a decision.

    I think I still prefer the interface over passing in the string when considering that there are 2 return values (success/failure and error message). But, it certainly doesn’t rule out your suggestion. It’s just my preferencecheap VPS

  10. Avatar
    Listings 12 months later:

    The re factoring introduces a separation of concerns that should have been there in the first place.Thanks for sharing.. very useful for me i will bookmark this for my future needed. thanks for a great source. Listings

  11. Avatar
    Cheap golf Gloves about 1 year later:

    Nice post, Thanks.

  12. Avatar
    Pandora about 1 year later:

    your initial website design may need to be frames based because you don’t have time to build an Ajax framework.

  13. Avatar
    http://www.whiteiphone4transformer.com about 1 year later:

    The white iphone 4 hardware design hasn’t changed from the one we already knew about. It uses the same materials as the prototype: Black glass and stainless steel rim.

  14. Avatar
    Bubble Shooter about 1 year later:

    Web master & all thanks for kind information.. I am going to bookmark this page. keep it up.

  15. Avatar
    fx about 1 year later:

    i found that it is very impressive & nice post you r such a good writer any how thank you for sharing with us

  16. Avatar
    css tutorials for beginners about 1 year later:

    thanks for your useful posting and sharing with us

  17. Avatar
    darmowe krzyzowki about 1 year later:

    Great blog post, I have been waiting for that

  18. Avatar
    darmowe pozycjonowanie about 1 year later:

    Great blog post, I have been waiting for that

  19. Avatar
    okey oyunu oyna about 1 year later:

    nice information

    internette görüntülü olarak okey oyunu oyna, gerçek kisilerle tanis, turnuva heyecanini yasa.

  20. Avatar
    brand watches sale about 1 year later:

    I am just new to your blog and just spent about 1 hour and 30 minutes lurking and reading. I think I will frequent your blog from now on after going through some of your posts. I will definitely learn a lot from them.

  21. Avatar
    virtual offices toronto about 1 year later:

    You brought some nice points there. i did a search and found that mostly people gave u compliments.

  22. Avatar
    Ed Hardy Outlet about 1 year later:

    Men at some point understands that they will be the master-gardener involving the heart, your representative involving the lifestyle. Men whom dares for you to squander an hour of your energy haven’t found out the significance involving lifestyle. Most lifestyle is surely an research. Greater findings anyone create better. The many art work involving existing is based on a fine interacting involving enabling get along with holding on. Just about any idiot could deal with an emergency – it can be day by day existing that will has on anyone out and about. Feel that lifestyle may be valued at existing plus your notion might help develop simple fact.

  23. Avatar
    Content Security about 1 year later:

    One thing I can tell you for sure after checking your code sample here: you are a better programmer than I am. I have trouble understanding some sequences. That tells a lot, doesn’t it?

  24. Avatar
    Ash women leather boot about 1 year later:

    I love to read this type of stuff. Good and attractive information I take from it..Thank you for posting such a nice article

  25. Avatar
    beats by dre store about 1 year later:

    . Good and attractive information I take from it..Thank you for posting such a nice articlecheap beats by dre beats by dre store

  26. Avatar
    tory burch high heels shoes about 1 year later:

    Women’s high heels of four- to six-inches are very hot for all occasions and with all levels of dress, from casual to professional.The Softspots sandals also offer heels of varying sizes to suit different tastes and needs.The use of soft genuine leather adds to both the comfort and stylistic elements of these women’s dress sandals.While some women are drawn to comfortable flats, others are sporting extreme high heels that measure up to 8-inches high.High heel shoes are better for those brides whose grooms are much taller than them, it’s a good to wear heel shoes so bride can match their height.Below is a look at the women’s trending shoe styles that are hot and selling fast this year in stores and through online shopping.The wide width dress sandals from Softspots are extremely popular because of the high level of comfort they offer while retaining the style element.

  27. Avatar
    abercrombie and fitch about 1 year later:

    If Abercrombie & Fitch is really concerned that the Situation and company have appeared on air in its garments, it doesn’t appear that angry.Bienvenue pour parcourir Abercrombie France site en ligne, vente en ligne New Style Belstaff en France, vous pouvez acheter la qualite superieure et escompte.Teen apparel retailer Abercrombie & Fitch Co. is offering to pay Michael “The Situation” Sorrentino not to wear its merchandise.Abercrombie Paris est le vêtement de la marque originale et riche d’une histoire enracinee dans le grand air et de la cote Est Ivy League.

  28. Avatar
    Tory Burch about 1 year later:

    This looks absolutely perfect. All these tinny details are made with lot of background knowledge. I like it

  29. Avatar
    Moncler over 2 years later:

    the 2011 moncler for the winter is beautiful.

  30. Avatar
    vindiesel over 2 years later:

    fort jefferson Thanks for sharing this information. I really like your way of expressing the opinions and sharing the information. It is good to move as chance bring new things in life, paves the way for advancement,

  31. Avatar
    canada goose jackets sale over 2 years later:

    Thank you for taking the time to publish this information very useful!I’m still waiting for some interesting thoughts from your side in your next post thanks These articles written too great,they rich contents ma le scarpe non ti donano. meglio dei sandali con stringe più sottili e caviglia libera Perfect! and data accurately.they are help to me.I expect to see your new share.

  32. Avatar
    online pokies over 2 years later:

    One thing I can tell you for sure after checking your code sample here: you are a better programmer than I am. I have trouble understanding some sequences. That tells a lot, doesn’t it? online pokies

  33. Avatar
    <a href="http://www.cheapsuprasuk.com/supra-high-tops-supra-skytop-shoes-c-4_13.html">Supra Muska Skytop</a> over 2 years later:

    Its perhaps a secure choice to express that a good deal of most people, when installing packages, overlook a particular exceptionally essential point. They overlook that they will need to look at the owners manual. Failure to master the connected substance is often the downfall of each and every application application during the marketplace. Nowhere is this truer than with Shoes robot software application. Various men and women set up their obtained software application and proper away start playing straight to the Shoes marketplace. This might be a horrible prepare and only one absolute to lead to anybody to shed cash. Hence when Supra shoes started out delivering its mini-course, it was a blessing in disguise.

  34. Avatar
    Fake Oakley Radar over 2 years later:
  35. Avatar
    Sunglasseshut discount online shop over 2 years later:
  36. Avatar
    discount oakley fives sunglasses over 2 years later:
  37. Avatar
    Fake Oakley Gascan sunglasses over 2 years later:
  38. Avatar
    replica Oakley Frogskins Sunglasses over 2 years later:
  39. Avatar
    pandora bracelets ireland over 2 years later:

    That was a great piece of information

  40. Avatar
    christian louboutin over 2 years later:

    The professional design make you foot more comfortable. Even more tantalizing,this pattern make your legs look as long as you can,it will make you looked more attractive.Moveover,it has reasonable price.If you are a popular woman,do not miss it.

    Technical details of Christian Louboutin Velours Scrunch Suede Boots Coffee:

    Color: Coffee
    Material: Suede
    4(100mm) heel
    Signature red sole x

    Fashion, delicate, luxurious Christian louboutins shoes on sale, one of its series is Christian Louboutin Tall Boots, is urbanism collocation. This Christian louboutins shoes design makes people new and refreshing. Red soles shoes is personality, your charm will be wonderful performance.

  41. Avatar
    christian louboutin over 2 years later:

    That was a great piece of information

  42. Avatar
    Spyder Jackets over 2 years later:
  43. Avatar
    Arcteryx Jackets over 2 years later:
  44. Avatar
    allen over 2 years later:

    En mer personlig ljus, men ocks? cool. ralph Lauren detta m?rke ?r verkligen ?lskling de europeiska konsumenterna. Speciellt m?nnen ut av det mer polo Ralph Lauren sweater En herre. N?r ?r det mer viktigt s? att kvaliteten ?r mycket bra, ?r stilen mycket nytt, aldrig inaktuell. discount Ralph Lauren polo

  45. Avatar
    Running shirt slogans over 2 years later:

    Señor blog impresionante. Sus artículos son increíbles. Pase por mi blog en el corto plazo si desea alguna información fresca sobre las camisas en ejecución.

  46. Avatar
    iPhone contacts backup over 2 years later:

    It is really a good example that most of the programmer should think about this. If we want to do much better for the code. I should understand it. right? You are very good at this and show us good coding idea.

Comments