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

Testability and Managing Software Architectures

abingham
October 23, 2013

Testability and Managing Software Architectures

This presentation looks at how testability can be used to help us monitor and manage software architectures.

abingham

October 23, 2013
Tweet

More Decks by abingham

Other Decks in Programming

Transcript

  1. 2

  2. 3

  3. 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 10
  4. Help Wanted! Software Architect Job responsibilities include: •Drawing Boxes and/or

    Arrows •Managing Non-Functional Requirements MUST KNOW HOW TO CODE! 11
  5. Help Wanted! Software Architect Job responsibilities include: •Drawing Boxes and/or

    Arrows •Managing Non-Functional Requirements MUST KNOW HOW TO CODE! 14
  6. Help Wanted! Software Architect Job responsibilities include: •Drawing Boxes and/or

    Arrows •Managing Non-Functional Requirements MUST KNOW HOW TO CODE! 15
  7. 19

  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 23
  9. 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 24
  10. Modularity + Testability Independent instantiation Testing in isolation Fewer hidden

    dependencies Confident testing Easier to understand Thorough testing 26
  11. 27

  12. 28

  13. 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 30
  14. 34

  15. 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 38
  16. 40

  17. 41

  18. 42

  19. 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 47
  20. Single responsibility ComponentObject ComponentObject(. . .); void render(); bool serialize();

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

    uint activate(); COList children(); bool isAlive(); void dealloc(); void kill(); void ensureActiveIfVisible(); CompoundCO MainView StorageMgr 51
  22. 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? 52
  23. Single responsibility ComponentObject ComponentObject(. . .); void render(); bool serialize();

    uint activate(); COList children(); bool isAlive(); void dealloc(); void kill(); void ensureActiveIfVisible(); Displayable Serializable Activatable 53
  24. 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 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 56
  25. 57 “How many if statements does it take to add

    a feature?” Rob Galanakis, Technical Director, Eve Online 57
  26. 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 { . . . }; 71
  27. SOLID Principles Single responsibility Open-closed Liskov substitution Interface segregation Dependency

    inversion SOLID code is testable code. Testable code is probably SOLID! 72
  28. 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 73
  29. 74

  30. 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 79
  31. 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 80
  32. 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 Be involved in the code Agile methods Test-Driven Design Domain-Driven Design Greenfield vs. Brownfield 81
  33. 83

  34. 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 Be involved in the code Agile methods Test-Driven Design Domain-Driven Design Greenfield vs. Brownfield 84
  35. individual developer Planning Sprint Review 1 2 3 stand-up Agile

    and feedback Testability can be a strong signal in agile feedback loops 86
  36. 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 Be involved in the code Agile methods Test-Driven Design Domain-Driven Design Greenfield vs. Brownfield 89
  37. Implicit Benefits are “built in” Testability is always a focus

    Explicit Refactoring loop Well positioned! 94
  38. 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 94
  39. 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 Be involved in the code Agile methods Test-Driven Design Domain-Driven Design Greenfield vs. Brownfield 95
  40. A DDD domain model is highly testable Modular? Performant? Scales

    up? Modifiable? SOLID? Strong reasons to consider using DDD! 100
  41. 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 Be involved in the code Agile methods Test-Driven Design Domain-Driven Design Greenfield vs. Brownfield 101
  42. 102

  43. 103

  44. “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 106
  45. “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 108