©ASERT/Suncorp2006-2008
Technical lessons learned
turning the agile dials to eleven!
Dr Paul King
ASERT, Australia
Craig Smith
Suncorp, Australia
Agile 2008 - 1
©ASERT/Suncorp2006-2008
Topics
• Introduction
• Quality Metrics
• Dealing with Boundaries
• Easing the
mocking burden
• Instance providers
• Autochecking
• Atoms, Molecules and
disposable tests
Agile 2008 - 2
Introduction
• Initial goals (dials to ten)
– 100% code coverage from unit tests
– All production code paired and test-driven
– Minimal design up front but an appreciation
for when such design made sense
– Customer focused outcomes
– Full continuous integration
– Daily pair rotation
– Continuous improvement through retrospectives
– High levels of automation
– Light-weight metrics to monitor progress
• Now how can we crank the dials further?
Agile 2008 - 3
©ASERT/Suncorp2006-2008
Agile 2008 - 4
Quality Metrics
• Duplication
– 0% duplication or build breaks (threshold = 4 lines)
• Now cranking back this metric for acceptance tests
• Method and Class Complexity
– Extremely simple classes and code
• Rarely used escape mechanism
• Graph true exceptions over time
• Method and Class Size
– Approx 10 lines per method, 80 lines per class
• 5-7 lines led to Ravioli code so we cranked this back
• Still hard to do try … catch … finally
but for us that need mostly occurs in boundaries
• To split 50 lines, use approx 7 methods of 7 lines not
two 25-line methods or twenty five 2-line methods
©ASERT/Suncorp2006-2008
Dealing with Boundaries
• Boundaries used with 3rd party APIs
• Ways to create
– IDE plugin to create static boundaries
– Groovy to automatically eliminate checked
exceptions through a language feature
– Use autoboundaries of an interface
Agile 2008 - 5
©ASERT/Suncorp2006-2008
package autoboundary.java.io;
public interface File {
String getCanonicalPath();
}
public class FileBoundary {
private File delegate;
public String getCanonicalPath() {
try {
return delegate
.getCanonicalPath();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}
Easing the mocking burden…
• Mocking became a pain point
– JMock 1 style mocking, small classes, 100% test
driven, rampant refactoring
• Want to avoid boiler plate set up of tests
– Instead of this:
– Have ‘magic’ framework allowing auto mock creation
• Based on most specific constructor matching fields
• Using naming conventions or annotations (shown):
Agile 2008 - 6
©ASERT/Suncorp2006-2008
private DocumentProperties docProps;
private DocumentReader reader;
private WordCounter counter;
@Before public void before() {
reader = context.mock(DocumentReader.class);
counter = context.mock(WordCounter.class);
docProps = new DocumentPropertiesImpl(reader, counter);
}
@Subject DocumentPropertiesImpl docProps;
@Mock DocumentReader reader;
@Mock WordCounter counter;
…Easing the mocking burden
• Avoid cumbersome expectation DSL:
– Not this:
– Instead this:
– Then have IDE support to convert between the two:
Agile 2008 - 7
©ASERT/Suncorp2006-2008
expectOneCallTo("getName", mockAuthor)
.will(returnValue(name));
name = author.getName();
Instance providers
• Instance/mock creation (annotations):
• Also have auto instance provider (naming
convention example):
– POJOs generated recursively or overridden using
numerous other conventions Agile 2008 - 8
©ASERT/Suncorp2006-2008
@Subject(auto=false) DocumentPropertiesImpl docProps;
@Mock private DocumentReader reader;
@Stub private String fileName;
@Wired private DocumentWriter writer;
String uniqueStringA;
String uniqueStringB;
Summer subject = new Summer();
public void testSumStringsAutoTriangulation() {
assertEquals(
uniqueStringA + uniqueStringB,
subject.sum(uniqueStringA, uniqueStringB));
}
Autochecking
• Numerous checks built in to testing
framework
– Auto null checking for public
methods and public constructors
– Auto check getters and setters
– Particular project-wide rules to
do with final, equals, hashCode
(not covered by checkstyle)
• Numerous types of classes had further
checks
– Immutable
– Serializable
– Components (remotable)
– Data (non-persistent POJO)
– Domain (persistent POJO)
Agile 2008 - 9
©ASERT/Suncorp2006-2008
Atoms, Molecules and disposable tests
• Deleting tests that don’t pull their weight:
– Distinguish between atoms and molecules
– Only support reuse at the molecular level
– Require 100% test coverage at the molecular level
– Can safely discard atomic interaction-based unit tests
• IDE automation allows them to be recreated trivially
– Allow state-based atomic tests to be kept if desired
Agile 2008 - 10
©ASERT/Suncorp2006-2008
Stage 2 Velocity
Agile 2008 - 11
©ASERT/Suncorp2006-2008
0
1000
2000
3000
4000
5000
6000
7000
8000
9000
10000 Iteration9
Iteration10
Iteration11
Iteration12
Iteration13
Iteration14
Iteration15
Iteration16
Iteration17
Iteration18
Iteration19
Iteration20
Iteration21
Iteration22
Iteration23
Iteration24
Iteration25
Iteration26
Iteration27
ScopeinIdealDeveloperHours
Schedule in Iterations
Release 7 Burn-Up Chart Burn-Up
Future Directions
• Acceptance-TDD or Functional-TDD
when appropriate
– Grails, Tester and Customer involvement
• Evolve how we use TDD & CI
– Disposable Atomic Tests, Groovy,
BDD, EasyB, Instinct, Performance
• Leverage a broader base
of testing approaches
– Jester, AllPairs, Reductio, Theories, Exploratory, Grids
• Further use of DSLs
– Testing, Business Rules, Workflows, Configuration
• Further use of more powerful languages
– Groovy, Scala, Ruby, Polyglot programming
Agile 2008 - 12
©ASERT/Suncorp2006-2008
About the contributing organizations
• About ASERT
– ASERT helps organisations define and make best use of their
eBusiness platforms by providing professional and cost-
effective training and consulting & system development
solutions including but not limited to Agile development,
Java/J2EE development, Groovy and Grails development, SOA
and web services implementations and agile deployment.
• About Suncorp
– Suncorp is one of Australia and New Zealand's largest
diversified financial services providers, supplying banking,
insurance and wealth management products to around 7 million
customers through well-established and recognized brands
such as AAMI, Australian Pensioners Insurance Agency,
Shannons, Vero, Asteron and Tyndall, as well as Suncorp and
GIO. Today, Suncorp is Australia's sixth largest bank and
second largest domestic general insurance group, with over
16,000 staff. Suncorp has representation in 450 offices,
branches and agencies throughout Australia and New Zealand.
Agile 2008 - 13
©ASERT/Suncorp2006-2008

Technical Lessons Learned Turning the Agile Dials to Eleven!

  • 1.
    ©ASERT/Suncorp2006-2008 Technical lessons learned turningthe agile dials to eleven! Dr Paul King ASERT, Australia Craig Smith Suncorp, Australia Agile 2008 - 1
  • 2.
    ©ASERT/Suncorp2006-2008 Topics • Introduction • QualityMetrics • Dealing with Boundaries • Easing the mocking burden • Instance providers • Autochecking • Atoms, Molecules and disposable tests Agile 2008 - 2
  • 3.
    Introduction • Initial goals(dials to ten) – 100% code coverage from unit tests – All production code paired and test-driven – Minimal design up front but an appreciation for when such design made sense – Customer focused outcomes – Full continuous integration – Daily pair rotation – Continuous improvement through retrospectives – High levels of automation – Light-weight metrics to monitor progress • Now how can we crank the dials further? Agile 2008 - 3 ©ASERT/Suncorp2006-2008
  • 4.
    Agile 2008 -4 Quality Metrics • Duplication – 0% duplication or build breaks (threshold = 4 lines) • Now cranking back this metric for acceptance tests • Method and Class Complexity – Extremely simple classes and code • Rarely used escape mechanism • Graph true exceptions over time • Method and Class Size – Approx 10 lines per method, 80 lines per class • 5-7 lines led to Ravioli code so we cranked this back • Still hard to do try … catch … finally but for us that need mostly occurs in boundaries • To split 50 lines, use approx 7 methods of 7 lines not two 25-line methods or twenty five 2-line methods ©ASERT/Suncorp2006-2008
  • 5.
    Dealing with Boundaries •Boundaries used with 3rd party APIs • Ways to create – IDE plugin to create static boundaries – Groovy to automatically eliminate checked exceptions through a language feature – Use autoboundaries of an interface Agile 2008 - 5 ©ASERT/Suncorp2006-2008 package autoboundary.java.io; public interface File { String getCanonicalPath(); } public class FileBoundary { private File delegate; public String getCanonicalPath() { try { return delegate .getCanonicalPath(); } catch (IOException e) { throw new RuntimeException(e); } } }
  • 6.
    Easing the mockingburden… • Mocking became a pain point – JMock 1 style mocking, small classes, 100% test driven, rampant refactoring • Want to avoid boiler plate set up of tests – Instead of this: – Have ‘magic’ framework allowing auto mock creation • Based on most specific constructor matching fields • Using naming conventions or annotations (shown): Agile 2008 - 6 ©ASERT/Suncorp2006-2008 private DocumentProperties docProps; private DocumentReader reader; private WordCounter counter; @Before public void before() { reader = context.mock(DocumentReader.class); counter = context.mock(WordCounter.class); docProps = new DocumentPropertiesImpl(reader, counter); } @Subject DocumentPropertiesImpl docProps; @Mock DocumentReader reader; @Mock WordCounter counter;
  • 7.
    …Easing the mockingburden • Avoid cumbersome expectation DSL: – Not this: – Instead this: – Then have IDE support to convert between the two: Agile 2008 - 7 ©ASERT/Suncorp2006-2008 expectOneCallTo("getName", mockAuthor) .will(returnValue(name)); name = author.getName();
  • 8.
    Instance providers • Instance/mockcreation (annotations): • Also have auto instance provider (naming convention example): – POJOs generated recursively or overridden using numerous other conventions Agile 2008 - 8 ©ASERT/Suncorp2006-2008 @Subject(auto=false) DocumentPropertiesImpl docProps; @Mock private DocumentReader reader; @Stub private String fileName; @Wired private DocumentWriter writer; String uniqueStringA; String uniqueStringB; Summer subject = new Summer(); public void testSumStringsAutoTriangulation() { assertEquals( uniqueStringA + uniqueStringB, subject.sum(uniqueStringA, uniqueStringB)); }
  • 9.
    Autochecking • Numerous checksbuilt in to testing framework – Auto null checking for public methods and public constructors – Auto check getters and setters – Particular project-wide rules to do with final, equals, hashCode (not covered by checkstyle) • Numerous types of classes had further checks – Immutable – Serializable – Components (remotable) – Data (non-persistent POJO) – Domain (persistent POJO) Agile 2008 - 9 ©ASERT/Suncorp2006-2008
  • 10.
    Atoms, Molecules anddisposable tests • Deleting tests that don’t pull their weight: – Distinguish between atoms and molecules – Only support reuse at the molecular level – Require 100% test coverage at the molecular level – Can safely discard atomic interaction-based unit tests • IDE automation allows them to be recreated trivially – Allow state-based atomic tests to be kept if desired Agile 2008 - 10 ©ASERT/Suncorp2006-2008
  • 11.
    Stage 2 Velocity Agile2008 - 11 ©ASERT/Suncorp2006-2008 0 1000 2000 3000 4000 5000 6000 7000 8000 9000 10000 Iteration9 Iteration10 Iteration11 Iteration12 Iteration13 Iteration14 Iteration15 Iteration16 Iteration17 Iteration18 Iteration19 Iteration20 Iteration21 Iteration22 Iteration23 Iteration24 Iteration25 Iteration26 Iteration27 ScopeinIdealDeveloperHours Schedule in Iterations Release 7 Burn-Up Chart Burn-Up
  • 12.
    Future Directions • Acceptance-TDDor Functional-TDD when appropriate – Grails, Tester and Customer involvement • Evolve how we use TDD & CI – Disposable Atomic Tests, Groovy, BDD, EasyB, Instinct, Performance • Leverage a broader base of testing approaches – Jester, AllPairs, Reductio, Theories, Exploratory, Grids • Further use of DSLs – Testing, Business Rules, Workflows, Configuration • Further use of more powerful languages – Groovy, Scala, Ruby, Polyglot programming Agile 2008 - 12 ©ASERT/Suncorp2006-2008
  • 13.
    About the contributingorganizations • About ASERT – ASERT helps organisations define and make best use of their eBusiness platforms by providing professional and cost- effective training and consulting & system development solutions including but not limited to Agile development, Java/J2EE development, Groovy and Grails development, SOA and web services implementations and agile deployment. • About Suncorp – Suncorp is one of Australia and New Zealand's largest diversified financial services providers, supplying banking, insurance and wealth management products to around 7 million customers through well-established and recognized brands such as AAMI, Australian Pensioners Insurance Agency, Shannons, Vero, Asteron and Tyndall, as well as Suncorp and GIO. Today, Suncorp is Australia's sixth largest bank and second largest domestic general insurance group, with over 16,000 staff. Suncorp has representation in 450 offices, branches and agencies throughout Australia and New Zealand. Agile 2008 - 13 ©ASERT/Suncorp2006-2008