Which came First? 23

Posted by Brett Schuchert Thu, 02 Aug 2007 21:43:00 GMT

I like mnemonics. Many years ago, a colleague of mine, James, gave me a way to remember something. First I’ll give you the letters:
  • CCCCDPIPE
These letters are a way to remember Craig Larman’s GRASP patterns (version 1). This and knowing that in the second version of the GRASP patterns Craig replaced the D for P (D – Don’t talk to strangers – the Law of Demeter, P – Protected Variation). By the way, here are all of them:
  • Coupling (low)
  • Cohesion (high)
  • Creator
  • Controller
  • Don’t talk to strangers (mentioned above and replaced with Protected Variation)
  • Polymorphism
  • Indirection
  • Pure Fabrication
  • Expert
How do I remember the letters? Well walk through this bad pun with me:
  • CCCC (4 c’s, foresees)
  • D (the)
  • PIPE (pipe)

So who foresees the pipe? The Psychic Plumber.

The Psychic Plumber??? I know, it’s awful. However, I heard it once in something like 1999 and I’ve never forgotten it.

That leads me to some other oldies but goodies: SOLID, INVEST, SMART and a relative new-comer: FIRST. While these are actually acronyms (not just abbreviations but real, dictionary-defined acronyms), they are also mnemonics.

You might be thinking otherwise. Typically what people call acronyms are actually just abbreviations. And in any case, they tend to obfuscate rather than elucidate. However, if you’ll lower your guard for just a few more pages, you might find some of these helpful.

Your software should be SOLID:
  • Single Responsibility
  • Open/Closed Principle
  • Liskov Substitution Principle
  • Interface Segregation
  • Dependency Inversion Principle (not to be confused with Dependency Inversion)

I think we should change the spelling: SOLIDD and tack on “Demeter – the Law Of. But that’s just me. Of course if we do this, then it is no longer technically an acronym. That’s OK, because my preference is for mnemonics, not acronyms.

When you’re working on your user stories, make sure to INVEST in them:
  • Independent
  • Negotiable
  • Valuable
  • Estimable
  • Small
  • Testable
And if you’re working on tasks, make sure to keep them SMART:
  • Specific
  • Measurable
  • Achievable
  • Relevant
  • Time-boxed
What what is FIRST? Well have you ever heard Test Driven Development (TDD)? Some people call it by an older name, Test-First Programming (TFP). I don’t think of these as the same thing but that’s neither here nor there. What if the F in TFP really stands for FIRST (notice how I sneaked in the capitals)? If so, then here’s one possible interpretation:
  • Fast – tests should run fast. We should be able to run all of the tests in seconds or minutes. Running the tests should never feel like a burden. If a developer ever hesitates to execute tests because of time, then the tests tests take too long.
  • Isolated – A test is a sealed environment. Tests should not depend on the results of other tests, nor should they depend on external resources such as databases.
  • Repeatable – when a test fails, it should fail because the production code is broken, not because some external dependency failed (e.g. database unavailable, network problems, etc.)
  • Self-Validating – Manual interpretation of results does not scale. A test should * verify that it passed or failed. Going one step further, a test should report nothing but success or failure.
  • Timely – tests should be written concurrently (and preferably before) with production code.

So where does this acronym come from? A while back, a colleague of mine, Tim Ottinger, and I were working on some course notes. I had a list of four out of five of these ideas. We were working on the characteristics of a good unit test. At one point, Tim said to me “Add a T.”

I can be pretty dense fairly often. I didn’t even understand what he was telling me to do. He had to repeat himself a few times. I understood the words, but not the meaning (luckily that doesn’t happen to other people or we’d have problems writing software). Anyway, I finally typed a “T”. And then I asked him “Why?” I didn’t see the word. Apparently you don’t want me on your unscramble team either.

Well eventually he led me to see the word FIRST and it just seemed to fit (not sure if that pun was intended).

Of course, you add all of these together and what do you get? The best I can come up with is: SFP-IS. I was hoping I could come up with a Roman numeral or something because then I could say developers should always wear SPF IS – which is true because we say out of the sun and burn easily. Unfortunately that did not work. If you look at your phone, you can convert this to the number: 73747

If there are any numerologists out there, maybe you can make some sense of it.

In any case, consider remembering some of these mnemonics. If you actually do more than remember them and start practicing them, I believe you’ll become a better developer.

Comments

Leave a response

  1. Avatar
    Jason about 5 hours later:

    Schuberry’s Greatest Hits indeed! For me personally only hearing you “ctrl-space” me to death is a founder memory than having you throw out Liskov or Law of Demeter.

    Good stuff Brett. It seems a lot of developers are always looking for concise no fluff items they can print out and put in their cube wall to act as a reminder. It seems coming up with a big font version of these acronyms and mnemonics would work well.

  2. Avatar
    Bill Wake about 7 hours later:

    T’s seem to give you trouble:) The “T” in “INVEST” is for Testable. (See http://xp123.com/xplor/xp0308/index.shtml)

  3. Avatar
    Brett Schuchert about 7 hours later:

    Oh duh on my part. Thank you! ... I’ll fix it.

  4. Avatar
    Torbjörn Kalin about 11 hours later:

    FIRST… I like it! And thanks for the summary of acronyms.

    Regarding Law of Demeter: I think of it as a subset of SRP, as a means to achieve it. But then again, ISP and SRP are also very related, as well as OCP and DIP, so perhaps it’s not a bad idea to emphasize the importance of the Law of Demeter.

  5. Avatar
    Brett Schuchert about 20 hours later:

    You know, I find violating it makes testing very hard (probably obvious). In reality, when I come across a large code base it probably is hard to test AND this is correlated with violation of both LOD and, typically, SRP. But something I only recently became aware of was the effect of TDD on the Law of Demeter.

    In my practice, when I use TDD, which is most of the time, I find that the Law of Demeter does not really come into play. By using Test Doubles and mocking libraries, I write without long chains. Because I want to focus my test to a small unit, I plugh in other objects that offer a service rather than a chain of objects I can use. By avoiding the dependencies that make testing more difficult, I happen to not violate Demeter.

  6. Avatar
    Tim about 21 hours later:

    The law still has “come into effect” if it is violated by no one. Rather, I think, you mean it is not violated.

    pedantically yours, tim

  7. Avatar
    Javid Jamae 2 months later:

    I’ve always known the rule to be that if you pronounce it as a word its an acronym, and if you pronounce each letter, then it is an initialism:

    http://lyberty.com/encyc/articles/abbr.html

  8. Avatar
    Pandora over 3 years later:

    on’t belittle or humiliate people who didn’t have the chance to learn how to write good code.

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

    News about Apple’s much-delayed white iPhone 4 continues to fly fast and furious, with a new claim from Boy Genius Report suggesting that the model has been canceled entirely instead of merely delayed until next spring as the company announced yesterday.

  10. Avatar
    Criminal Records over 4 years later:

    I was hoping I could come up with a Roman numeral or something because then I could say developers should always wear SPF IS – which is true because we say out of the sun and burn easily.

  11. Avatar
    Jones over 4 years later:

    glad to see you!

  12. Avatar
    Matteo over 4 years later:

    glad

  13. Avatar
    Backup iPhone SMS over 4 years later:

    Keep your Contacts and SMS safe! Actually, the contacts and SMS have more values than a cell phone’s own value. You can pay money to buy a new iPhone, but cannot buy your lost contacts and SMS back. So it’s important for you to backup your contacts and SMS in iPhone. And we recommend you backup contacts and SMS regularly. Our backup software can help you take a snapshot for your contacts and SMS. Your important personal information will be never lost.

  14. Avatar
    iPhone SMS to Mac Backup over 4 years later:

    Would you like to banckup iphone SMS to mac, macBook, macbookPro as .txt files? Now a software iphone SMS to Mac Backup can help you to realize it.

  15. Avatar
    okey oyunu oyna over 4 years later:

    good article

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

  16. Avatar
    tiffany uk engagement rings over 4 years later:

    I am in support of wonderland, this project is seeing very good fame and should be continued.

  17. Avatar
    wellensteyn jacken over 4 years later:

    Wellensteyn-Jacken Wellensteyn werden getragen von qualitätsbewussten Menschen,Wellensteyn Jacken für die Stil und Outdoor-Bekleidung keinen Gegensatz darstellt. So sind die funktionalen Jacken mittlerweile Alltag auf den Straßen Jacken Von Wellensteyn deutscher und internationaler Großstädte.

  18. Avatar
    swarovskicry crystals over 4 years later:

    Swarovski crystal jewelry, on top of that also known as these Austrian Swarovski Crystals, is definitely the most beneficial many costly type of Crystals Swarovski uk . As a result, a majority of these Swarovski Uk items need be adopted special care involving to allow them to last perpetually.

  19. Avatar
    herren winterjacken over 4 years later:

    I am carrying this bag myself,Herren Winterjacken when I wear very girly stuff, mine is smaller than large,herren winter still can fit lap top and all I need…I had been looking for it for several years until I found it 3 years ago in UK.Belstaff Jacken I saw it for the first time in the movie “Interpreter”, carried by Nicole Kidmann, and then in “I, Legend” carried by Will Smith.http://www.herrenwinterjacken.com/

  20. Avatar
    Jordan Retros over 4 years later:

    Family Family Jordan Retros Family and Friends of Lesbians and Gays (PFLAG).Just last month, New York City Jane Isay wrote an essay, Keeping Marital Secrets Closeted about learning her psychoanalyst psychoanalyst air Jordan 7 psychoanalyst husband was gay 15 years into their marriage in 1965. The couple to keep his coming out from their two sons - aged 10 and and Kid Jordan Shoes and 14 - and stayed in the marriage for the sake of the 72, Isay looks back on that decision with mixed feelings. When they finally

  21. Avatar
    iPhone contacts backup over 4 years later:

    Get to know about C# and C++. In fact, I find there is no much difference between the two. However, If we want to do much better. I need work hard.

  22. Avatar
    louboutin sales over 5 years later:

    Which came First? 21 hoo,good article!!I like the post!36

  23. Avatar
    bladeless fans over 5 years later:

    Which came First? 22 good post151

Comments