Architecture is a Second Order Effect 62

Posted by Uncle Bob Sat, 20 Oct 2007 06:58:29 GMT

We often argue that in order to achieve flexibility, maintainability, and reusability, it is important to have a good software architecture. This is certainly true. Without a well ordered architecture, software systems become masses of tangled modules and code. However, the effect of architecture on the ‘ilities is secondary to the effect that a good, fast, suite of tests has.

Why don’t we clean our code? When we see an ugly mass of code that we know is going to cause of problems, our first reaction is “This needs to be cleaned up.” Our second reaction is: “If I touch this code I’ll be spending the next two weeks trying to get it to work again.” We don’t clean code because we are afraid we’ll break it.

In this way bad code hooks itself into our systems and refuses to go away. Nothing stops clean code from going bad, but once it’s bad, we seldom have the time, energy, or nerve to clean it. In that sense, bad code is permanent.

What if you had a button? If you push this button a little light instantly turns red or green. Green means your system works. Red means it’s broken. If you had a button like this, you could make small changes to the system, and prove that they didn’t break anything. If you saw a batch of tangled messy code, you could start to clean it. You’d simply make a tiny improvement and then push the button. If the light was green you’d make the next tiny change, and the next, and the next.

I have a button like that! It’s called a test suite. I can run it any time I like, and within seconds it tells me, with very high certainty, that my system works.

Of course, to be effective, that test suite has to cover all the code in the system. And, indeed, that’s what I have. My code coverage tools tell me that 89% of the 45,000 lines in my system are covered by my test suite. (89% is pretty good number given that my coverage tool counts un-executable lines like interfaces.)

Can I be absolutely sure that the green light means that the system works? Certainly not. But given the coverage of my test suite, I am reasonably sure that the changes I make are not introducing any bugs. And that reasonable surety is enough for me to be fearless about making changes.

This fearlessness is something that needs to be experienced to understand. I feel no reluctance at all about cleaning up the code in my system. I frequently take whole classes and restructure them. I change the names of classes, variables, and functions on a whim. I extract super-classes and derivatives any time I like.

In short, the test suite makes it easy to make changes to my code. It makes my code flexible and easy to maintain.

So does my architecture of course. The design and structure of my system is very easy to deal with, and allows me to make changes without undue impact. The reason my architecture is so friendly, is that I’ve been fearless about changing it. And that’s because I have a test suite that runs in seconds, and that I trust!

So the clean architecture of my system is a result of on-going efforts supported by the test suite. I can keep the architecture clean and relevant because I have tests. I can improve the architecture when I see a better approach because I have tests. It is the tests that enable architectural improvement.

Yes, architecture enables flexibility, maintainability, and reusability; but test suites enable architecture. Architecture is a second order effect.

Comments

Leave a response

  1. Avatar
    Washu 5 days later:

    I’ve been interested in how you deal with environments where there are no existing automated test, a whole lot of dirty code, and the very likely chance for side effects.

    Clearly this is a case where you need to write tests before you refactor, however how can you be sure of the coverage of your tests when your dealing with languages like C++, where ones tools are so much more primative?

    I do realize that on platforms like java and .net the tools are significantly more mature, but one doesnt always have the luck to work in one of those languages.

    Its amusing to note how much better the tools are for such young languages than for those older ones like C+. One also notes the lack of a proper C+ compiler, guess kiss holds even in language design. :)

  2. Avatar
    Ashok Gudur 14 days later:

    Currently I’m working on a project where the whole application is written in SQL Server 2000 Stored Procedures. It runs as a SQL job and updates the 2-3 tables with final results.

    The application is a vehicle transport routing logic. It calculates the low cost route from various locations to various destinations by applying different business rules. The database size is very huge. The existing application takes lot of time (4-5 weeks) to complete the whole process.

    My task is to improve the execution performance of the application but the final results should be same. It’s exactly like what we do in Refactoring where the internal design/structure is improved but the external behavior will remain same.

    There are 2-3 tables where the final results are stored once it processes the entire database. I can use these tables to compare the final results of both new code and old code.

    The whole process takes lot of time to complete even if I take small set of data. Initially I prepared some tests by taking several possible combinations and started doing improvement by running these tests for each single modification. Gradually my numbers of tests are increased and my development is progressing.

    Now the problems are like:

    1. since the process takes lot of time to execute tests. My development cycle: Modification – run tests – very the results: are taking lot of time.

    2. Is with test code coverage. I fear that, whether my tests are still covering all of the code? i.e. even though the tests are passing but they are doing on small set of data. So if I take it to production, will it pass? What if I get some wrong results? How should I know which change caused that?

  3. Avatar
    Convert DVD to HTC over 3 years later:

    ah ha ,it is really good! Here ,our PDF to BMP Converter will show you its main features and the easy-to use

    steps that how to convert PDF to BMP. With PDF to BMB Converter, you will find that it is very simple to convert PDF to BMP.also

    ,you can try tg rth

  4. Avatar
    jewellery over 3 years later:

    am preparing the manuscript for production

  5. Avatar
    carmeron over 3 years later:

    I have a button like that! It’s called a test suite. I can run it any time I like, and within seconds it tells me, with very high certainty, that my system works.

  6. Avatar
    bag factory over 3 years later:

    wever, the effect of architecture on the ‘ilities is secondary to the effect that a

  7. Avatar
    vuitton louis over 3 years later:

    ghf

  8. Avatar
    clothing button over 3 years later:

    Before you enter louis vuitton wallets that credit card rolex watch number,check that the page is secure. There replica rolex watches should be a small lock icon on the bottom pane of your browser.Setup a free web-based gucci purses.zf

  9. Avatar
    Best Area Rugs over 3 years later:

    Hi , I found your site on bing. It is very nice. Good job, keep this site alive. Thanks

    Best regards

  10. Avatar
    Pandora over 3 years later:

    In short, the test suite makes it easy to make changes to my code. It makes my code flexible and easy to maintain.

  11. Avatar
    iPhone SMS Transfer over 3 years later:

    I don’t know much about it. So, I want to study. When I come to here, I think I am in the right place. the web gives me a lot of infomation, it is very informative. I think lots of people can learn much here. I will come to here again. Thanks.

  12. Avatar
    sophia Bracelets over 3 years later:

    I like this information and it has given me some sort of desire to have success for some reason, so thanks. Furthermore I?m definitely considering blogging these facts in my own blog!

  13. Avatar
    beats by dr dret over 3 years later:

    I was looking out the window. I was waiting for the plane to take off. I was wearing Monster Cable’s Beats by Dr. Dre Studio headphones . I was listening to Pens’ burning, fuzzed-out, 27-minute onslaught, Hey Friend, What You Doing? I was shouting with sudden shock and pain.”>

  14. Avatar
    http://www.blacktowhiteiphone4.com over 3 years later:

    Thanks for your share. If you have any news about iphone 4 white plz tell us, i will be really appreciate.

  15. Avatar
    helen over 3 years later:

    we have rolex watch to sell.the website:www.watch24club.com,and the email:helen.24club@gmail

  16. Avatar
    Silicone Molding over 3 years later:

    Mold making is the core business of Intertech (Taiwan). With world level technology, Intertech enjoys a very good reputation for making Injection Mold and Plastic Moldsfor their worldwide customers.

  17. Avatar
    coach purses outlet over 3 years later:

    thanks for your sharing, I appreciate this. keep up the good work

  18. Avatar
    christian louboutins over 3 years later:

    Great article and your blog template is so cool. Is this template free or not? If so, Where could i download this template? if not, how much does it cost? Thanks a lot!

  19. Avatar
    iPad to mac transfer over 3 years later:

    Thanks for shareing! I agree with you. The artical improve me so much! I will come here frequently. iPad to Mac Transfer lets you transfer music, movie, photo, ePub, PDF, Audiobook, Podcast and TV Show from iPad to Mac or iPad to iTunes.

  20. Avatar
    Criminal Check over 3 years later:

    So the clean architecture of my system is a result of on-going efforts supported by the test suite.

  21. Avatar
    nitrile gloves over 3 years later:

    Nice share. I think your website should come up much higher in the search results than where it is showing up right now….

  22. Avatar
    replica belts over 3 years later:

    replica gucci belts, replica belts, replica louis vuitton belts, replica hermes belts.

  23. Avatar
    lv belts over 3 years later:

    lv belt, lv belts, lv Mens belts, lv belts for men.

  24. Avatar
    Gucci belts over 3 years later:

    gucci belts for men, gucci belts, gucci mens belt, gucci mens belts.

  25. Avatar
    replica belts over 3 years later:

    replica gucci belts, replica gucci belt, replica gucci belts for men, replica gucci mens belt.

  26. Avatar
    hermes belt over 3 years later:

    Hermes belt, Hermes belts, Hermes Mens belts, Hermes belts for men.

  27. Avatar
    Men's belts over 3 years later:

    Men’s belts, LV men’s belts, Gucci men’s belts, Hermes men’s belts.

  28. Avatar
    lv belts over 3 years later:

    LV belt, LV belts, LV belts for men, LV Mens belts, louis vuitton mens wallets,gucci mens wallets,hermes mens wallets,prada mens wallets.

  29. Avatar
    Tenant Screening over 3 years later:

    I am reasonably sure that the changes I make are not introducing any bugs. And that reasonable surety is enough for me to be fearless about making changes.

  30. Avatar
    Criminal Records over 3 years later:

    There are 2-3 tables where the final results are stored once it processes the entire database. I can use these tables to compare the final results of both new code and old code.

  31. Avatar
    Designer Sunglasses over 3 years later:

    Buy sunglass hurry up limited periode and get a discount

  32. Avatar
    Hermes belts over 3 years later:

    Strongly recommended for shopping at Hermes belts store.

  33. Avatar
    Hermes belts over 3 years later:

    Strongly recommended for shopping at Hermes belts store.

  34. Avatar
    Hermes belts over 3 years later:

    Strongly recommended for shopping at Hermes belts store.

  35. Avatar
    okey oyunu oyna over 4 years later:

    nice paragraph. Thanks

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

  36. Avatar
    Hermes belts over 4 years later:

    Strongly recommended for shopping at Hermes belts store.

  37. Avatar
    Hermes belt over 4 years later:

    Hermes belt store offers high quality and cheap designer belts, please have a look.

  38. Avatar
    coach purses over 4 years later:

    Mr Coates coach purses is the longest U.S. market popular with one of the most successful leather brand. Mr Coates coach purses store represents the most admirable American fashion innovative style and traditional skills . Mr Coates coach bags have durable quality and exquisite technology, Conspicuous Coach Heels in the female consumers have good reputation. Welcome to our shop Elegant Coach Purses

  39. Avatar
    Hermes belts over 4 years later:

    Strongly recommended for shopping at Hermes belts store.

  40. Avatar
    Hermes belt over 4 years later:

    There are various kinds of Hermes belt available to match your needs.

  41. Avatar
    handbags for sale over 4 years later:

    If you are really going to sell the dress, I’d totally be interested in it, since it’s one of my dream dresses :333

  42. Avatar
    Jewellery over 4 years later:

    xcv

  43. Avatar
    Supra For Sale over 4 years later:

    Not because they are not good, it is simply because of the recession and that not many people are willing to shell out money for properties.

  44. Avatar
    Cookies Gift over 4 years later:

    it needs a bokmark so i can come back to it later ,nice stuff

  45. Avatar
    Crystal Jewellery over 4 years later:

    Great post! Nice and informative, I really enjoyed reading it and will certainly share this post with my friends . Read everything about the different colors of gold

  46. Avatar
    beats by dre store over 4 years later:

    high quality headphones new design headphones “We two have been 6. Yesterday a student was sick, I take a bus 930 back to school to see her, afraid of boring so far way to buy the basketball magazine, all the way t

  47. Avatar
    canada goose coat over 4 years later:

    Canada Goose Outlet is Marmot 8000M Parka. The Marmot 8000M Parka is really a waterproof, breathable jacket with 800 fill canada goose jacket feathers. It truly is design and light colored shell is produced for trendy, but uncomplicated, protection from cold temperatures. Reinforced shoulders, elbows and adjustable waist and hem make the Marmot a perfect alternate for skiing and other outdoor sports that want fairly a bit of arm motion. The 8000M Parka weighs three lbs., comes in bonfire and black colours and might be stuffed and stored like a sleeping bag to your convenience.This is one of well-know and prime down jacket brands.Hope our friends like its!Like canada goose womens and Canada Goose Expedition Parka.There are wholesale canada goose.

  48. Avatar
    african Mango dr oz over 4 years later:

    When I at first left a comment I clicked the “Notify me when new comments are added” checkbox and now each time a comment is added I get three notification emails with the same comment. Is there any way you can take away people from that service? Thanks a lot!

  49. Avatar
    Rejser til Thailand over 4 years later:

    I am happy when reading your blog with updated information! thanks alot and hope that you will post more site that are related to this site.

  50. Avatar
    forex-tradingplatform over 4 years later:

    I enjoyed reading it and i learn a lot! Thanks for sharing this wonderful blog. Keep posting.

  51. Avatar
    best sleep aid over 4 years later:

    i think this can be bookmarked for future referenses , i think i could make use of this ,many thanks for the time you spend writing this , best regards for Canada

  52. Avatar
    Tips For Bowling over 4 years later:

    I was assigned to do a job by the attorney general, and that was to find out whether crimes were committed.

  53. Avatar
    fine wines singapore over 4 years later:

    It was a very nice thought! Just wanna say thank you for the selective information you have distributed. Just continue composing this kind of post. I will be your patriotic reader. Thanks again.

  54. Avatar
    beats by dr dre over 4 years later:

    A university studentbeats by dr dre caught by the enemy, the enemy tied him at the poles,just beats solo headphones purple and then asked him: say, where are you? You do not say it electrocuted! Scheap dr.dre beats studio headphones balck/yellowtudents back to the enemy a word, the result was electrocuted, he said: I am TVU.Hot sale beats by dr dre pro headphones

  55. Avatar
    Maine Criminal Justice Academy over 4 years later:

    Thanks for this nice article. Will be sure to share this and knowing about Maine Criminal Justice Academy can also be searched for in the succeeding articles.

  56. Avatar
    moving company in malaysia over 4 years later:

    I really do think this was a very special and interesting article. I have really enjoyed this great information so much.Thanks for sharing this information with us.

  57. Avatar
    outcall massage singapore over 4 years later:

    I just love it ….. well i don’t have any doubt about your articles… your articles are awesome… Honestly you are simply the best.Thanks for sharing this with us.

  58. Avatar
    backup iPhone SMS over 4 years later:

    It is necessary to do the program with you and make a right choice. good luck.

  59. Avatar
    mbtshoe over 4 years later:

    Australia Beats By Dre Studio dr dre beats headphones beats studio beats pro beats solo hd pro headphones music Official store Monster Beats By Dre Pro

  60. Avatar
    louboutin sales over 5 years later:

    Architecture is a Second Order Effect 59 hoo,good article!!I like the post!50

  61. Avatar
    bladeless fans over 5 years later:

    Architecture is a Second Order Effect 60 good post145

  62. Avatar
    belt hermes over 5 years later:

    Want to be a cool Dad – then you need to check out the Diaper Dude range?

Comments