Transformation Priority Premise @Softwerkskammer MUC

Post on 15-Jan-2017

498 views 1 download

transcript

The Transformation

Priority Premise

Softwerkskammer Meetup Munich

11.02.2016

David Völkel

Agenda

● Pizza

● Theory

● Kata

● Another Beer

Solution

Take Baby Steps

Image by Seattle Municipal Archives

Test Driven Development

red

refactor

green

Types of Code

Testcode

red

refactor

green

„Transformation“

= Implementation

Refactoring

Design

Transformation Priorities

● ({}–>nil) no code at all -> code that returns nil

● (nil->constant)

● (constant->constant+) simple to a more complex constant

● (constant->scalar) replacing a constant with a variable

● (statement->statements) adding more unconditional

statements

● (unconditional->if) splitting the execution path

● (scalar->array)

● (array->container)

● (statement->recursion)

● (if->while)

● (expression->function)

● (variable->assignment) replacing the value of a variable.

Strategy

• When passing a test, prefer

higher priority

transformations

• Choose as next test the one

that can be implemented

with higher priority

transformations

green

refactor

red

Strategy

• When passing a test, prefer

higher priority

transformations

• Choose as next test the one

that can be implemented

with higher priority

transformations

• Even during refactoring

green

refactor

red

The Kata

Transformation priorities:

● ({}–>nil) no code at all -> code that returns nil

● (nil->constant)

● (constant->constant+) simple to a more complex constant

● (constant->scalar) replacing a constant with a variable

● (statement->statements) adding more unconditional

statements

● (unconditional->if) splitting the execution path

● (scalar->array)

● (array->container)

● (statement->recursion)

● (if->while)

● (expression->function)

● (variable->assignment) replacing the value of a variable.

http://agilekatas.co.uk/katas/RomanNumerals-Kata

Share your experience!

The Kata

Transformation priorities:

● ({}–>nil) no code at all -> code that returns nil

● (nil->constant)

● (constant->constant+) simple to a more complex constant

● (constant->scalar) replacing a constant with a variable

● (statement->statements) adding more unconditional

statements

● (unconditional->if) splitting the execution path

● (scalar->array)

● (array->container)

● (statement->recursion)

● (if->while)

● (expression->function)

● (variable->assignment) replacing the value of a variable.

http://agilekatas.co.uk/katas/RomanNumerals-Kata

Share your experience!

Benefits?

Benefits

Easier and more effective TDD ● Complexity based guideline for choosing

next test & implementation

● Reduces getting stuck with too big steps

● Less tests that are already green

● Less tests left out

Issues?

Issues

● Are there other transformations? (almost certainly)

● Are these the right transformations? (probably not)

● Are there better names for the transformations? (almost

certainly)

● Is there really a priority? (I think so, but it might be more

complicated than a simple ordinal sequence)

● If so, what is the principle behind that priority? (some

notion of “complexity”)

● Can it be quantified? (I have no idea)

● Is the priority order presented in this blog correct? (not

likely)

● The transformations as described are informal at best.

Can they be formalized? (That’s the holy grail!)

Raised by Uncle Bob

Retrospective

Special Thanks

to Ivan Kusalic

@ikusalic

for your inspiration

Lizenz

Creative Commons Attribution-ShareAlike 3.0

https://creativecommons.org/licenses/by-sa/3.0/de/