Name that refactoring: 2 67

Posted by Brett Schuchert Mon, 14 Dec 2009 04:51:00 GMT

Ok, so I’m getting good feedback on the first picture. Now for a series of pictures.

How do you interpret this series?

Step 0

Step 1

Step 2

Step 3

Comments

Leave a response

  1. Avatar
    GBGames 20 minutes later:

    I interpret this as “How to insert an interface to an outside resource to make testing easier with code that depends on that resource.”

  2. Avatar
    PaulS 32 minutes later:

    Exposing services/programs to the internet.

  3. Avatar
    Ted M. Young 42 minutes later:

    0 to 1: Making the objects talk to a single class instead of talking to web services (? the cloud?) directly.

    1 to 2: Extracting an interface so the objects talk to an interface instead of the object directly.

    2 to 3: Now you can plug-in various test doubles for testing purposes.

  4. Avatar
    Markus Gärtner about 2 hours later:

    Looks like you’re introducing an Adapter for a subsystem. An interface is introduced so that the dependency is abstracted. The indirection then is added and can be manipulated in the last step using test doubles that implement that interface. Looks like a combined refactoring to me. Don’t have Fowler or Kerievsky here to look up the name, but the name seems to be something like “Extract Interface and introduce Adapter”.

  5. Avatar
    Aviv Ben-Yosef about 2 hours later:

    I actually see it as “Decouple Subsystem”, which first adds a class that defines an exact API, and then that class is transformed to an Interface for even greater decoupling and easier testing.

  6. Avatar
    Romain Verdier about 3 hours later:

    For me, this refactoring is about to isolate the left sub system from the whole system, by extracting a facade.

    The gray component is actually the only one which doesn’t belong to this subsystem.

  7. Avatar
    r. about 4 hours later:

    I like and second the Breaking Dependencies comments from Markus and Romain with the use of extract Interface / Facade and introduce Adapter. When presenting this one, I also discuss it as “A single place should change when changing the (right hand side) subsystem”. Easier to test and easier to change the dependencies.

  8. Avatar
    Manuel Küblböck about 4 hours later:

    Step 0: Many classes (left) access different classes of an external library (right)

    Step 1: Create a facade for the external library

    Step 2: Create an interface for the facade

    Step 3: Create test doubles to mock the external library to be able to test the classes on the left without the dependency on the external library

  9. Avatar
    a about 5 hours later:

    step 1: Extract class Step 2: Extract interface

  10. Avatar
    Cyrille Martraire about 7 hours later:

    I love the playful idea of the quizz.

    I would simply name this sequence of 4 steps “Introduce Test Double”. It does contain the refactoring “Decouple Service” (steps 1 to 3).

    1/ Various components depend on a service typically outside of our control. Select this service, then:

    2/ “Introduce Adapter” (almost a Proxy indeed), which becomes the service actually depended upon by the legacy components.

    This is the step with most impact on the code base. What is not explained here is how to retrieve the Adapter, as it will become key for step 4 (Dependency Injection? FactoryMethod? Singleton?)

    3/ “Extract Interface” on the proxy: we now have a degree of freedom (variability) to implement alternate implementations of the service

    4/ “Inject Test Double”. Create Mock implementation(s) + configure dependency injection

  11. Avatar
    Daniel Moura about 9 hours later:

    Extract a class from the cloud to create a Facade. Creates an interface. Create some mock classes.

  12. Avatar
    Pablo Fernandez about 11 hours later:

    Step Zero: Your classes have Un-DRY code that uses some other classes (represented as a cloud there)

    Step One: You realize that and abstract common behavior in a concrete class

    Step Two: You create an interface for the newly created class, so clients don’t depend on implementations but on interfaces instead.

    Step Three: Here you realize that you can stub/mock the implementation and test the client classes in isolation.

  13. Avatar
    zvolkov about 12 hours later:

    This one looses me. I liked the concise one-picture drawing better. So this looks like 0) identify commonalities amongst the consumers of a bunch of logic (represented by the cloud), 1) create a Facade, then 2) extract interface, then 3) implement bunch of test doubles. Too much for a single slide and the message is somewhat blurred. Also, w/o arrows the direction is difficult to figure out (who’s the consumer, who’s the provider)

  14. Avatar
    Giorgio Sironi about 13 hours later:

    Step 1: external service is hidden behind a Facade class. Step 2: an interface is extracted. Step 3: multiple implementations can be used for test purposes.

  15. Avatar
    Tim Ottinger about 17 hours later:

    without reading anyone else’s comments, my immediate interpretation was “encapsulate API”, “Extract interface”, “introduce test doubles”.

  16. Avatar
    ceferhat 1 day later:

    a consumer proxy has been created and strategy (may be adapter) applied, for connecting to other clouds.

  17. Avatar
    unclebob 1 day later:

    Arrowheads would help. If we could see that the little guys all use the cloud, then the extraction and subsequent decoupling of behavior from the cloud becomes clearer. The initial arrowheads ought to point at the cloud since they are using relationships.

  18. Avatar
    Chris Tinning 22 days later:

    Manuel for me offers the best explanation but the additions of arrows would make things clearer.

  19. Avatar
    Tendances de Mode about 1 month later:

    well… i’d say : Step 1: Extract class Step 2: Extract interface

  20. Avatar
    Josh 4 months later:

    step one: Extract class step two: Extract interface

  21. Avatar
    Blu-ray ripper mac 4 months later:

    Free download Blu-ray to iPad Mac, you can easily convert Blu ray and DVDs to iPad for playing.

  22. Avatar
    Pandora 12 months later:

    Ok, so I’m getting good feedback on the first picture. Now for a series of pictures.

  23. Avatar
    http://www.blacktowhiteiphone4.com about 1 year later:

    iphone 4 white and iphone 4 black, which one will be more suitable for yourself? Thinking of the black iphone 4 is too ordinary, iphone 4 white will be the one to make you feel different.

  24. Avatar
    Pneumatic fittings about 1 year later:

    Many thanks.Still an additional brilliant article, this is exactly exactly why My spouse and I arrive to the blog page over and over again!

  25. Avatar
    electronic ballast about 1 year later:

    Your site is amazing.I am very impressed to see this,i want to come back for visiting your site.Keep doing Good as well as you can.

  26. Avatar
    disney about 1 year later:

    Everyone has different growth process, maybe some feel difficult in his or her childhood memory, or others may think that this is a happy ending. Now, there is a adays boxset hot and popular Disney was growing pains is about growing pains as we all know, different people have different ideas. As such, it tells DVD boxset growing pains, the actor has troubled childhood, but he never gave up Dvd And Movie. Finally, he become a person of success, have a happy family, so like us, we must work harder to study, work harder what be what to write, we also must have a dream, never give up, in the end, we all have a bright future. Tell us a lot of useful things, our whole life whether you have time, you had Disney Dvds better buy the growth process full season, you will DVD benefited.

  27. Avatar
    okey oyunu oyna about 1 year later:

    Thank you very much.

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

  28. Avatar
    Pandora UK about 1 year later:

    Thanks for sharing new art print,This is very amazing for me.Thank you for the inspiration!

  29. Avatar
    wholesale imitation jewelry about 1 year later:

    I preferred the cloud as it more underline a potentially complex dependency good system

  30. Avatar
    como conquistar a un hombre about 1 year later:

    aprende en esta pagina las mejores tecnicas de seduccion.

    como conquistar a un hombre
  31. Avatar
    wow gold kaufen http://www.igx4u.com about 1 year later:

    Thank you for allowing me this message

  32. Avatar
    diesel jeans sale about 1 year later:

    Contrasted against the grand gowns offered by other couturiers, wonens diesel jeans look casual modern even today.Why were these diesel uk jeans considered so shocking? The idea that they look equally chic on men and women. When it comes to designer jeans , diesel jeans reflecting the subtle evolutions of this hardy fashion perennial through few decades. For a woman, diesel jeans sale is an indispensable garment with which she finds herself in fashion, because it is about style, not fashion. Fashions come and go, but style is forever. diesel jeans uk is a popular choice among young people, for Most of current diesel jeans cheap are designed to meet consumers’ demand. http://www.diesel-jeans-sales.net/

  33. Avatar
    como conquistar a un hombre about 1 year later:

    As commented I think “How to insert an interface to an outside resource depends on that resource.”

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

    l uk jeans considered so shocking? The idea that they look equally chic on men and women. When it comes to designer jeans , diesel jeans reflecting the subtle evolutions of this hardy fashion perennial through

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

    it was ringing like you.” Neat car everyone has contempt for the students to cast eyes. Students: ”... ...” Shen, had to be on the train, bus bad rescheap beats by dre beats by dre storeults on the road, near to the school the evening before. Cups a day ride the bus. 1, long neck, a few knots, take a day cream Mama. Turn the drawer to find a night cream, the wife asked me why then, do not lift my head to answer: find a Mobo Zi drugs it!

  36. Avatar
    ipad 2 case about 1 year later:

    Whoa this is just the info I was looking for! Glad to have found it here in your site.

  37. Avatar
    Juicy Couture outlet stores about 1 year later:

    I agree with one of the other posters – you write very well indeed.

  38. Avatar
    beats by dr dre about 1 year later:

    take a day cream Mama. Turn the drawer to find a night cream, the wife asked mebeats by dr dre beats by dre sale why then, do not lift my head to answer: find a Mobo Zi drugs it!

  39. 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.

  40. Avatar
    <a href="http://www.bagsupplyer.com/">bagsupplyer</a> about 1 year later:
  41. 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.

  42. Avatar
    women jordan heels about 1 year later:

    I like and second the Breaking Dependencies comments from Markus and Romain with the use of extract Interface / Facade and introduce Adapter.

  43. Avatar
    louboutinchaussures about 1 year later:

    Many this the industry superb e-commerce, over the internet wanting, precisely what MBT footwear? I’ t convinced you choosed conduct. Plus the release with e-commerce team obtained a on-line shopping for. Always be with all this mbt lami boots and shoes plus boot footwear and even lots of people over the internet hunting Masai boots and shoes plus boot footwear could be a wonderful liking.Christian Louboutin Rouges chaud Make sure you execute could be a site into the stay, Christian Louboutin Bottessports book odds your person’ vertisements working out and also journal to look for and also MBT boots low-priced and also seek MBT boots out there. North Face Apex Bionic Kvinder JakkerType in getting some keyword phrase, similar to an example is definitely the following MBT Masai boots and shoes plus boot footwear ideal for lists pertaining to recommendations boots and shoes plus boot footwear and also web-site may might seem when while in front of any one, and then motivateNorth Face Denali Jakker Kvinder hoodie, to illustrate, a person’s sensible Web pages should do,

    canada goose will likely be MBT footwear providing could great final decision. Then you could well anticipation any one not any specs of your webpage acceptable this mbt baridi boots and shoes plus boot footwear in the united kindom normally often be subject material, you will get you wantcanada goose outlet.

  44. Avatar
    superdry clothing about 1 year later:

    Superdry UK – Buy high-class Superdry clothing from Superdry UK stylish fashion brand.lacoste uk Wearing Superdry clothing can be successful grabbing attention of crowd. superdry uk

  45. Avatar
    Minnie Mouse Costume about 1 year later:

    I am happy to visit this site, it is very useful to me.

  46. Avatar
    Marc by Marc Jacobs on Sale about 1 year later:

    This looks absolutely perfect, Really its remarkable. You have some great content but are getting lots of none relevant comments here too. I really like in a site, very informative, no waste of time on reading.

  47. Avatar
    african Mango dr oz about 1 year later:

    hmm ,i’m not sure if this is what i’m looking for but anyway this is interresting and could be useful some day,thanks for taking time to write such cool stuff

  48. Avatar
    http://top-10-credit-repair.com about 1 year later:

    Continue to keep up sharing informative blog. I really enjoyed reading this.

  49. Avatar
    pc health advisor review about 1 year later:

    That is a nice point to carry up. I provide the thoughts above as common inspiration. pc health advisor review

  50. Avatar
    discount oakley fives sunglasses about 1 year later:
  51. Avatar
    Fake Oakley Gascan sunglasses about 1 year later:
  52. Avatar
    Christian about 1 year later:

    asas df00as78d0 +9a7fsd98fas

  53. Avatar
    moncler about 1 year later:

    asdfsa g3sdfs6ddd

  54. Avatar
    Louboutins about 1 year later:

    asdasdf8a78a8a888

  55. Avatar
    replica oakley gascan sunglasses about 1 year later:
  56. Avatar
    Air Jordan Max Fusion about 1 year later:

    A excellent dude is invariably ready to acquire little.

  57. Avatar
    Buy Nike Air Yeezy about 1 year later:

    The worst method to forget some one is for getting sitting centerbesidehim knowing you cant have him.

  58. Avatar
    swarovski uk about 1 year later:

    The exact very souvenirs include several different size and shapes also as a rule express a variety of canine, your widley known nature or just a well-known conclude coming from a child’s bringing up.

  59. Avatar
    moncler sito ufficiale about 1 year later:

    Moncler fa oscurare quasi 500 siti web. Con una sentenza moncler sito ufficialedel tribunale di Padova, Italy. Ma non è proprio così, solo pochi di quei siti vendevano moncler uomoprodotti contraffatti, altri erano canada goose outletdomini acquistati da utenti. Infatti la cosa clamorosa Moncler Borsenon è la sentenza per oscurare siti belstaff outletaccusati di contraffazione o ricettazione, ma chemoncler sito ufficiale il giudice abbia ritenuto un reato di contraffazione la registrazione di un indirizzo web Moncler Sweater Donnecontenente il marchio dell’azienda. I siti di appassionati di qualcosa, i tenutari di pagine Fan su facebook, ugg ???tutti tremano: la strada ell’oscurantismo in moncler uomoItalia si fa sempre più larga, e quindi? Intorno a me, who cares?

  60. Avatar
    louis vuitton canvas about 1 year later:

    louis vuitton canvas Why didn’t the Tunisian public reward the dynamic young secular activists who got rid of the dictator?

  61. Avatar
    Como Conquistar a Un Hombre about 1 year later:

    love the photos!!

    Como Conquistar a Un Hombre

  62. Avatar
    madison chiropractor about 1 year later:

    I gained so much knowledge from this excellent post.

  63. Avatar
    christian louboutin about 1 year 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.

  64. Avatar
    christian louboutin about 1 year later:

    I gained so much knowledge from this excellent post.

  65. Avatar
    chiropractic madison wi about 1 year later:

    I appreciate the good write up, Keep up the great job.

  66. Avatar
    nikeheelsdunk over 2 years later:


    A first aid kit is a must for small and accidental injuries. Of course it’s unavoidable to scrape your arm on rough bark or falling off the tree stand, at least there’s an available remedy in that box. Always make sure to dispose of the Nike heels for women material properly.

    Other equipment such as rifles or bows must be kept unloaded. Most States will commission a guide for hunters to carry the ammunition and probably help the hunter carry some of the necessary equipment. It’s not like having a Jordan Heels For Women caddy carrying the bag, but he is there to ensure the safety of the hunter as well as the forest.

    Never drink anything that may compromise or deteriorate your physical or mental faculties.
  67. Avatar
    juicy over 2 years later:

    Casual and dressy Juicy Couture outlet online provides this new coming season’ s best seller handbags, tracksuits, bikinis and other sassy Juicy accessories. Here our juicycouturelove.com is committed to have all the juicy within your easy reach. Choose discount Juicy Couture sale fashion everyday staples will surely help you taste like Couture and have a nice Juicy day. http://www.juicycouturelove.com

Comments