Upgrade to Pro — share decks privately, control downloads, hide ads and more …

The Primacy of Testability

abingham
December 05, 2014

The Primacy of Testability

This presentation is on how to use testability as a proxy for other quality attributes, and how to leverage it as a tool for managing architectures.

This version of the slides was presented at XP Days Ukraine 2014.

abingham

December 05, 2014
Tweet

More Decks by abingham

Other Decks in Programming

Transcript

  1. @sixty_north The Primacy of Testability A barometer for the busy

    architect 1 Austin Bingham @austin_bingham
  2. Ground Rules Some definitions to set the stage Qualities Correlated

    with Testability Review of a few software qualities and their relationship to testability Application How these principles apply to the real world 1 2 3
  3. Help Wanted! Software Architect ! Job responsibilities include: •Drawing Boxes

    and/or Arrows •Managing Non-Functional Requirements !
  4. Help Wanted! Software Architect ! Job responsibilities include: •Drawing Boxes

    and/or Arrows •Managing Non-Functional Requirements ! MUST KNOW HOW TO CODE!
  5. Ground Rules Some definitions to set the stage Qualities Correlated

    with Testability Review of a few software qualities and their relationship to testability Application How these principles apply to the real world 1 2 3
  6. Ground Rules Some definitions to set the stage Qualities Correlated

    with Testability Review of a few software qualities and their relationship to testability Application How these principles apply to the real world 1 2 3 Modularity Performance Scaling up development SOLID Modifiability
  7. Modularity + Testability Independent instantiation Testing in isolation Fewer distant

    dependencies Confident testing Easier to understand Thorough testing
  8. Ground Rules Some definitions to set the stage Qualities Correlated

    with Testability Review of a few software qualities and their relationship to testability Application How these principles apply to the real world 1 2 3 Modularity Performance Scaling up development SOLID Modifiability
  9. ! ! Performance ! ! ! Everything else ! Testability

    is key to hitting performance goals
  10. Qualities Correlated with Testability Review of a few software qualities

    and their relationship to testability Application How these principles apply to the real world 2 3 Modularity Performance Scaling up development SOLID Modifiability Ground Rules Some definitions to set the stage 1
  11. Qualities Correlated with Testability Review of a few software qualities

    and their relationship to testability Application How these principles apply to the real world 2 3 Modularity Performance Scaling up development SOLID Modifiability Ground Rules Some definitions to set the stage 1
  12. Single responsibility ComponentObject ComponentObject(. . .); void render(); bool serialize();

    uint activate(); COList children(); bool isAlive(); void dealloc(); void kill(); void ensureActiveIfVisible();
  13. Single responsibility ComponentObject ComponentObject(. . .); void render(); bool serialize();

    uint activate(); COList children(); bool isAlive(); void dealloc(); void kill(); void ensureActiveIfVisible(); CompoundCO MainView StorageMgr
  14. Single responsibility ComponentObject ComponentObject(. . .); void render(); bool serialize();

    uint activate(); COList children(); bool isAlive(); void dealloc(); void kill(); void ensureActiveIfVisible(); How many tests? Expected behavior? Interactions?
  15. Single responsibility ComponentObject ComponentObject(. . .); void render(); bool serialize();

    uint activate(); COList children(); bool isAlive(); void dealloc(); void kill(); void ensureActiveIfVisible(); Displayable Serializable Activatable
  16. Open-closed double getSpeed() { switch (_type) { case EUROPEAN: return

    getBaseSpeed(); case AFRICAN: return getBaseSpeed() - getLoadFactor() * _numberOfCoconuts; case NORWEGIAN_BLUE: return (_isExParrot) ? 0 : getBaseSpeed(_voltage); } throw new RuntimeException ("Should not be unreachable"); } Bird European African NorwegianBlue getSpeed(): double «abstract» getSpeed(): double getSpeed(): double getSpeed(): double M = E - N + 2P M = 4 - 5 + 2×4 M = 7 M = 1 M = 1 M = 1 ΣM = 3
  17. 57 “How many if statements does it take to add

    a feature?” Rob Galanakis, Technical Director, Eve Online
  18. Dependency inversion void relayMessage(string msg) {! SatelliteUplink sup;! sup.initialize();! sup.send(msg);!

    }! void relayMessage(string msg, Relay& r) {! r.send(msg);! }! ! class SatelliteUplink : public Relay { . . . };! ! class MockRelay : public Relay { . . . };!
  19. SOLID Principles Single responsibility Open-closed Liskov substitution Interface segregation Dependency

    inversion SOLID code is testable code. Testable code is probably SOLID!
  20. Qualities Correlated with Testability Review of a few software qualities

    and their relationship to testability Application How these principles apply to the real world 2 3 Modularity Performance Scaling up development SOLID Modifiability Ground Rules Some definitions to set the stage 1
  21. Qualities Correlated with Testability Review of a few software qualities

    and their relationship to testability Application How these principles apply to the real world 2 3 Modularity Performance Scaling up development SOLID Modifiability Ground Rules Some definitions to set the stage 1
  22. Qualities Correlated with Testability Review of a few software qualities

    and their relationship to testability Application How these principles apply to the real world 2 3 Ground Rules Some definitions to set the stage 1
  23. Qualities Correlated with Testability Review of a few software qualities

    and their relationship to testability Application How these principles apply to the real world 2 3 Agile methods Test-Driven Design Domain-Driven Design Ground Rules Some definitions to set the stage 1
  24. Agile and feedback Testability can be a strong signal in

    agile feedback loops individual developer Planning Sprint Review 1 2 3 stand-up
  25. Qualities Correlated with Testability Review of a few software qualities

    and their relationship to testability Application How these principles apply to the real world 2 3 Agile methods Test-Driven Design Domain-Driven Design 4 Ground Rules Some definitions to set the stage 1
  26. Implicit Benefits are “built in” Testability is always a focus

    Explicit Refactoring loop Well positioned! TDD’s strength is based on some of the same ideas
  27. Qualities Correlated with Testability Review of a few software qualities

    and their relationship to testability Application How these principles apply to the real world 2 3 Agile methods Test-Driven Design Domain-Driven Design 4 Ground Rules Some definitions to set the stage 1
  28. “One reasonable definition of good design is testability. It is

    hard to imagine a software system that is both testable and poorly designed. It is also hard to imagine a software system that is well designed but also untestable.” Uncle Bob Martin
  29. “There appears to be a synergy between testability (at the

    unit level) and good design. If you aim for testability and make some good choices, design gets better. If you aim for good design, your design becomes more testable.” Michael Feathers Photo by Fraser Speirs