from mess to masterpiece - jfokus 2017

106
prepare for… From mess to masterpiece refactoring done right @SvenRuppert

Upload: sven-ruppert

Post on 13-Apr-2017

42 views

Category:

Software


1 download

TRANSCRIPT

Page 1: From Mess To Masterpiece - JFokus 2017

prepare for…

From mess to masterpiecerefactoring done right

@SvenRuppert

Page 2: From Mess To Masterpiece - JFokus 2017

@SvenRuppert has been coding java since 1996

Projects in the field of: •Automobile-industry •Energy •Finance / Leasing •Space- Satellit- •Government / UN / World-bank

Where?

•Europe •Asia - from India up to Malaysia

2

Page 3: From Mess To Masterpiece - JFokus 2017

Our journey todaywhat is the situation…..

3

@SvenRuppert

Page 4: From Mess To Masterpiece - JFokus 2017

4

@SvenRuppertAt the time I started - 3 yrs ago

Codebase is > 13 years old no test coverage

Code Lordsnearly 15% are retired soon

over 50% are since 15 yrs in the company

the developers learned Java at this project

hiring only students

the first feeling was like ……

Page 5: From Mess To Masterpiece - JFokus 2017

5

@SvenRuppertAt the time I started - 3 yrs ago

Page 6: From Mess To Masterpiece - JFokus 2017

6

What is part of a refactoring ?

the teamthe source code

the processesthe project management

the knowledgebudget and time line

infrastructure

@SvenRuppert

Page 7: From Mess To Masterpiece - JFokus 2017

7

What is part of a refactoring ?

the team

the source code the processes

the project managementthe knowledge

budget and time line} }team transformation

C-level transformation

infrastructure

@SvenRuppert

Page 8: From Mess To Masterpiece - JFokus 2017

prepare for

Refactoring - the first stepswithout this you should not start

8

@SvenRuppert

Page 9: From Mess To Masterpiece - JFokus 2017

9

@SvenRuppertfirst steps - Start Small

Page 10: From Mess To Masterpiece - JFokus 2017

10

@SvenRuppertfirst steps - Think Bigger

Page 11: From Mess To Masterpiece - JFokus 2017

11

@SvenRuppertfirst steps - Build a Team

Page 12: From Mess To Masterpiece - JFokus 2017

12

@SvenRuppertfirst steps - build trust

Page 13: From Mess To Masterpiece - JFokus 2017

prepare for

Refactoring - the way of workingstart with individual responsibility

13

@SvenRuppert

Page 14: From Mess To Masterpiece - JFokus 2017

14

@SvenRuppertThe way of working

20% Time have time to play or try

start learning how to practice it ?Closed Source versus Open Source

work from everywhere at your time

we started step by step

Page 15: From Mess To Masterpiece - JFokus 2017

15

@SvenRuppertwork from everywhere

Page 16: From Mess To Masterpiece - JFokus 2017

16

@SvenRuppertwork from everywhere

change your environment

use Messenger like Slack avoid mailsremote meetings with zoom

remote Pair-Programmingwork async.

work at your time that is the best for you

Page 17: From Mess To Masterpiece - JFokus 2017

17

@SvenRuppertwork from everywhere

work at your time that is the best for youmy „normal“ day…

working05AM to 07AMbreakfast with the family07AM to 09AMworking09AM to 12AMplaying with my son12AM to 07PMplaying with my wife 07PM to 09PMworking09PM to 11PM

and yes… I need only 6h sleep ;-)

Page 18: From Mess To Masterpiece - JFokus 2017

18

@SvenRuppertwork from everywhere

work at your time that is the best for youmy „normal“ day…

working05AM to 07AMworking09AM to 12AMworking09PM to 11PM

working with Asiaworking with Europeworking with US

Page 19: From Mess To Masterpiece - JFokus 2017

19

@SvenRuppertThe way of working

why you should do it?20% Time

lost in daily business

Page 20: From Mess To Masterpiece - JFokus 2017

20

@SvenRuppertThe way of working

how to make it useful ?

example : POC with the team in the Mountains

for the developer

for the company

20% Time

Page 21: From Mess To Masterpiece - JFokus 2017

prepare for

Refactoring - Divide your codewhat is the part you are earning money with

21

@SvenRuppert

Page 22: From Mess To Masterpiece - JFokus 2017

22

@SvenRuppertClosed- versus Open Source

Analyzing the existing Code in our case : a lot of infrastructure…

..with this we are not earning money

we divided the code base

dev. environment

Page 23: From Mess To Masterpiece - JFokus 2017

23

@SvenRuppertClosed- versus Open Source

we divided the

code base dev. environment

could write articles about itdiscuss at conferences

will lead to better documentation

out of company rulesfree choice of tools

higher motivation

Page 24: From Mess To Masterpiece - JFokus 2017

prepare for

Refactoring - the reactionsdon´t forget the team you are working with

24

@SvenRuppert

Page 25: From Mess To Masterpiece - JFokus 2017

25

@SvenRuppertThe way of working

Start Learning againfor example:

functionaladd a new Languagefocus on a new paradigm

but not everyone want to learn or better…. some are learning faster

reactive

this sometimes leads to ….. reactions….

Page 26: From Mess To Masterpiece - JFokus 2017

26

@SvenRuppertThe way of working

Start Learning againthis sometimes leads to ….. reactions….

running away

Page 27: From Mess To Masterpiece - JFokus 2017

27

@SvenRuppertThe way of working

Start Learning againthis sometimes leads to ….. reactions….

expecting something

Page 28: From Mess To Masterpiece - JFokus 2017

28

@SvenRuppertThe way of working

Start Learning againthis sometimes leads to ….. reactions….

feeling the near end

Page 29: From Mess To Masterpiece - JFokus 2017

29

@SvenRuppertThe way of working

Start Learning againthis sometimes leads to ….. reactions….

or only feeling to old

Page 30: From Mess To Masterpiece - JFokus 2017

30

@SvenRuppertThe way of working

Start Learning againthis sometimes leads to ….. reactions….

you have to deal with this

if you don´t want to loose them

make them happy again

How we solved

this?

Page 31: From Mess To Masterpiece - JFokus 2017

prepare for

Refactoring - Projectmanagementone size fit´s all ?

31

@SvenRuppert

Page 32: From Mess To Masterpiece - JFokus 2017

32

@SvenRuppertThe way of working

we are a product company with a lot of LTS contracts

we created three streams

Consultants - play and throw awayCore Developers - collect and clean

LTS Developers - keep alive

Why ?

Page 33: From Mess To Masterpiece - JFokus 2017

33

@SvenRuppertThe way of working

Consultants - play and throw awayCore Developer - collect and cleanLTS Developer - keep alive Why ?some want to learn and experimentsome need more stabil environmentssome did not want to change something

Page 34: From Mess To Masterpiece - JFokus 2017

34

@SvenRuppertThe way of working

Consultants - play and throw away

Core Developer - collect and clean

LTS Developer - keep alive

Why ?some want to learn and experiment

some need more stabil environments

some did not want to change something

amount of hours paid by the customer

rated on hours the systems are stabil

fixed income - bonus based on Change Request

Page 35: From Mess To Masterpiece - JFokus 2017

35

@SvenRuppertThe way of working

Consultants - play and throw away

Core Developer - collect and clean

LTS Developer - keep aliveSCRUM

Kanban

customer driven

roadmap driven

Page 36: From Mess To Masterpiece - JFokus 2017

36

@SvenRuppertThe way of working

SCRUM

Kanban

Consultants

LTS - Developers

Core - Developers Core - Developers

Fire

Consultants

Page 37: From Mess To Masterpiece - JFokus 2017

37

@SvenRuppertThe way of working

SCRUM

Kanban

Consultants

LTS - Developers

Core - Developers

Consultants Consultants Consultants

LTS - Developers LTS - Developers

Core - Developers Core - Developers

time based planning fixed size time slots

version based dynamic size time slots

Page 38: From Mess To Masterpiece - JFokus 2017

prepare for

Refactoring - Start learning againlearn how to learn together with a team again

38

@SvenRuppert

Page 39: From Mess To Masterpiece - JFokus 2017

39

@SvenRuppertKnowledge Sharing

Consultants

LTS - Developers

Core - Developers

build a source of knowledge

Page 40: From Mess To Masterpiece - JFokus 2017

40

@SvenRuppertKnowledge Sharing

Consultants

LTS - Developers

Core - Developers

Hacking session

Articles / Blogs

Screencasts Refactoring SessionsPOC

Page 41: From Mess To Masterpiece - JFokus 2017

41

@SvenRuppertKnowledge SharingHow to motivate your team to do it ?

explain it !!

Page 42: From Mess To Masterpiece - JFokus 2017

prepare for

Refactoring - Technologieschoose your weapons

42

@SvenRuppert

Page 43: From Mess To Masterpiece - JFokus 2017

43

@SvenRuppertTechnical Migrations

if you ask the consultants…to scale or change you need at least … ;-)

NoSQL

Events

Akka / Scala

ReactiveFunctional

maybe ;-)

Page 44: From Mess To Masterpiece - JFokus 2017

44

@SvenRuppertTechnical Transformation

Swing Vaadin

HashMap Hazelcast - Map

JDBC - ResultSet Speedment - Streams

what is the right technology for your team? what is the right order?

Java OOP Java FRP

Page 45: From Mess To Masterpiece - JFokus 2017

45

@SvenRuppertTechnical Transformation

what is the right technology for your team?

what is the right order?

reduce complexityscale

the team could work with

a lot more….

start with new modules ?start with the oldest one ?

most komplex one?… or ….

Page 46: From Mess To Masterpiece - JFokus 2017

46

@SvenRuppertTechnical Transformation

on thing that would limit your speed…

time

number of versions

v1

v2stabilize

Page 47: From Mess To Masterpiece - JFokus 2017

47

@SvenRuppertTechnical Transformation

on thing that would limit your speed…

time

number of versions v2stabilize

delta t compared to project lifetime

Page 48: From Mess To Masterpiece - JFokus 2017

prepare for

Refactoring - Safety belt choose your weapons

48

@SvenRuppert

Page 49: From Mess To Masterpiece - JFokus 2017

49

@SvenRuppertQM / QS - TDD

Do you have bugs in your code ?

since years you are

working hard on this….

no

Page 50: From Mess To Masterpiece - JFokus 2017

50

@SvenRuppertQM / QS - TDD

Codebase is > 13 years old no test coverage

how to decrease complexity?

remember….

how to start?what is the right point to start?

how to increase the quality of the tests?

Page 51: From Mess To Masterpiece - JFokus 2017

51

TDD with jUnit @SvenRuppert

are you using jUnit?

assume that the following would make sense.. ;-)

public class Service { public int add(int a, int b){ if(a<2){ return (a+b) * -1; } else { return a+b; } }}

How many tests

you will need ?

it depends ;-)

Page 52: From Mess To Masterpiece - JFokus 2017

52

TDD with jUnit @SvenRuppert

public class Service { public int add(int a, int b){ if(a<2){ return (a+b) * -1; } else { return a+b; } }}

How many tests

you will need ?

for line 100% coverage 2

but will this be enough? maybe ;-)

how to find out, what will be enough?how to find the right tests?

it depends ;-)

Page 53: From Mess To Masterpiece - JFokus 2017

53

Mutation Testing @SvenRuppert

generating the mutants and

practical TDD with Mutation Testing

running all junit testscheck the reports

write more / better tests

loop until quality target reached

Page 54: From Mess To Masterpiece - JFokus 2017

54

Mutation Testing - Hello World @SvenRuppert

public class Service { public int add(int a, int b){ if (a<2) { return (a+b) * -1; } else { return a+b; } }} 100% Line Coverage… and…@Testpublic void testAdd001() throws Exception { final int add = new Service().add(0, 0); Assertions.assertThat(add).isEqualTo(0); } @Test

public void testAdd002() throws Exception { final int add = new Service().add(3, 0); Assertions.assertThat(add).isEqualTo(3); }

Page 55: From Mess To Masterpiece - JFokus 2017

55

Mutation Testing - Hello World @SvenRuppert

final int add = new Service().add(0, 0); Assertions.assertThat(add).isEqualTo(0);

final int add = new Service().add(3, 0); Assertions.assertThat(add).isEqualTo(3);

Page 56: From Mess To Masterpiece - JFokus 2017

56

Mutation Testing - Hello World @SvenRuppert

final int add = new Service().add(0, 0);final int add = new Service().add(3, 0);

>> Generated mutations Killed 3

Page 57: From Mess To Masterpiece - JFokus 2017

57

Mutation Testing - Hello World @SvenRuppert

final int add = new Service().add(0, 0);final int add = new Service().add(3, 0);

>> Generated mutations Killed 3

Page 58: From Mess To Masterpiece - JFokus 2017

58

Mutation Testing - in short words @SvenRuppert

mutation testing is an add on to normal jUnit TDD

tools are supporting it well

generating and running all tests are time consuming

but most important

will effect your project structure

Page 59: From Mess To Masterpiece - JFokus 2017

59

Mutation Testing - Lesson Learned @SvenRuppert

mutation tests are often leading to

…cleaner code compared to jUnit only

Page 60: From Mess To Masterpiece - JFokus 2017

60

Mutation Testing - Lesson Learned @SvenRuppert

public static final String[] discardCommonPrefix(String a, String b) { String[] ret = { a, b }; int l = a.length() < b.length() ? a.length() : b.length(); for (int i = 0; i < l; i++) { if (a.charAt(i) == b.charAt(i)) { if (i + 1 < l) { ret[0] = a.substring(i + 1); ret[1] = b.substring(i + 1); } else { if (a.length() < b.length()) { ret[0] = ""; ret[1] = b.substring(i + 1); } if (a.length() == b.length()) { ret[0] = ""; ret[1] = „"; } if (a.length() > b.length()) { ret[0] = a.substring(i + 1); ret[1] = „"; } } } else break; } return ret; }

Page 61: From Mess To Masterpiece - JFokus 2017

61

Mutation Testing - Lesson Learned @SvenRuppert

public String[] discardCommonPrefix(String a, String b) { final String[] ret = new String[2]; int l; if (a.length() < b.length()) { l = a.length(); } else { l = b.length(); } int position = 0; for (; position < l; position++) { final char charA = a.charAt(position); final char charB = b.charAt(position); if (charA != charB) { break; } }

if (position >= a.length()) { ret[0] = ""; } else { ret[0] = a.substring(position); }

if (position >= b.length()) { ret[1] = ""; } else { ret[1] = b.substring(position); } return ret; }

Page 62: From Mess To Masterpiece - JFokus 2017

62

Mutation Testing - Lesson Learned @SvenRuppert

Version 1 Version 2 for { if { if else { if if if } } else }

if else for { if }

if else

if else

Page 63: From Mess To Masterpiece - JFokus 2017

63

Example of useless Code @SvenRuppert

Page 64: From Mess To Masterpiece - JFokus 2017

Functions

how use Functions…

@SvenRuppert

Page 65: From Mess To Masterpiece - JFokus 2017

Functions - Java8

65

@SvenRuppert

Page 66: From Mess To Masterpiece - JFokus 2017

Functions - Java8

66

@SvenRuppert

Page 67: From Mess To Masterpiece - JFokus 2017

Functions - Java8

67

@SvenRuppert

Page 68: From Mess To Masterpiece - JFokus 2017

prepare for

Refactoring - Design Pattern start developing design pattern again

68

@SvenRuppert

Page 69: From Mess To Masterpiece - JFokus 2017

NestedBuilder - The Beginning

69

@SvenRuppert

Page 70: From Mess To Masterpiece - JFokus 2017

NestedBuilder - The Beginning

70

@SvenRuppert

Car car = Car.newBuilder() .withEngine(engine) .withWheelList(wheels) .build();

Engine engine = Engine.newBuilder().withPower(100).withType(5).build();

Wheel wheel1 = Wheel.newBuilder().withType(2).withColour(3).withSize(4).build(); Wheel wheel2 = Wheel.newBuilder().withType(2).withColour(3).withSize(4).build();Wheel wheel3 = Wheel.newBuilder().withType(2).withColour(3).withSize(4).build();

List<Wheel> wheels = new ArrayList<>(); wheels.add(wheel1); wheels.add(wheel2); wheels.add(wheel3);}

Page 71: From Mess To Masterpiece - JFokus 2017

NestedBuilder - The Beginning

71

@SvenRuppert

Car car = Car.newBuilder() .withEngine(engine) .withWheelList(wheels) .build();

Engine engine = Engine.newBuilder().withPower(100).withType(5).build();

Wheel wheel1 = Wheel.newBuilder().withType(2).withColour(3).withSize(4).build(); Wheel wheel2 = Wheel.newBuilder().withType(2).withColour(3).withSize(4).build();Wheel wheel3 = Wheel.newBuilder().withType(2).withColour(3).withSize(4).build();

List<Wheel> wheels = new ArrayList<>(); wheels.add(wheel1); wheels.add(wheel2); wheels.add(wheel3);

Page 72: From Mess To Masterpiece - JFokus 2017

NestedBuilder - The Beginning

72

@SvenRuppert

Car car = Car.newBuilder() .withEngine(engine) .withWheelList(wheels) .build();

Engine engine = Engine.newBuilder().withPower(100).withType(5).build();

Wheel wheel1 = Wheel.newBuilder().withType(2).withColour(3).withSize(4).build(); Wheel wheel2 = Wheel.newBuilder().withType(2).withColour(3).withSize(4).build();Wheel wheel3 = Wheel.newBuilder().withType(2).withColour(3).withSize(4).build();

//List<Wheel> wheels = new ArrayList<>();// wheels.add(wheel1);// wheels.add(wheel2);// wheels.add(wheel3);

List<Wheel> wheelList = WheelListBuilder.newBuilder() .withNewList() .addWheel(wheel1) .addWheel(wheel2) .addWheel(wheel3) .build(); //more robust if you add tests at build()

}

}

how to combine ?

List<Wheel> wheels = new ArrayList<>(); wheels.add(wheel1); wheels.add(wheel2); wheels.add(wheel3);

Page 73: From Mess To Masterpiece - JFokus 2017

NestedBuilder - The Beginning

73

@SvenRuppert

Car car = Car.newBuilder() .withEngine(engine) .withWheelList(wheels) .build();

Engine engine = Engine.newBuilder().withPower(100).withType(5).build();

Wheel wheel1 = Wheel.newBuilder().withType(2).withColour(3).withSize(4).build(); Wheel wheel2 = Wheel.newBuilder().withType(2).withColour(3).withSize(4).build();Wheel wheel3 = Wheel.newBuilder().withType(2).withColour(3).withSize(4).build();List<Wheel> wheelList = WheelListBuilder.newBuilder() .withNewList() .addWheel(wheel1) .addWheel(wheel2) .addWheel(wheel3) .build();

}

}

how to combine ?

Page 74: From Mess To Masterpiece - JFokus 2017

NestedBuilder - The Beginning

74

@SvenRuppert

Car car = Car.newBuilder() .withEngine(engine) .withWheelList(wheels) .build();

Engine engine = Engine.newBuilder().withPower(100).withType(5).build();

// Wheel wheel1 = Wheel.newBuilder().withType(2).withColour(3).withSize(4).build(); // Wheel wheel2 = Wheel.newBuilder().withType(2).withColour(3).withSize(4).build();// Wheel wheel3 = Wheel.newBuilder().withType(2).withColour(3).withSize(4).build();// List<Wheel> wheelList = WheelListBuilder.newBuilder() .withNewList() .addWheel(wheel1) .addWheel(wheel2) .addWheel(wheel3) .build();

List<Wheel> wheels = wheelListBuilder .addWheel().withType(1).withSize(2).withColour(2).addWheelToList() .addWheel().withType(1).withSize(2).withColour(2).addWheelToList() .addWheel().withType(1).withSize(2).withColour(2).addWheelToList() .addWheel().withType(1).withSize(2).withColour(2).addWheelToList() .build();

Page 75: From Mess To Masterpiece - JFokus 2017

NestedBuilder - The Beginning

75

@SvenRuppert

Car car = Car.newBuilder() .withEngine(engine) .withWheelList(wheels) .build();

Engine engine = Engine.newBuilder().withPower(100).withType(5).build();

List<Wheel> wheels = wheelListBuilder .addWheel().withType(1).withSize(2).withColour(2).addWheelToList() .addWheel().withType(1).withSize(2).withColour(2).addWheelToList() .addWheel().withType(1).withSize(2).withColour(2).addWheelToList() .addWheel().withType(1).withSize(2).withColour(2).addWheelToList() .build();

WheelBuilder

WheelListBuilder

Page 76: From Mess To Masterpiece - JFokus 2017

NestedBuilder - The Beginning

76

@SvenRuppert

Car car = Car.newBuilder() .withEngine(engine) .withWheelList(wheels) .build();

Engine engine = Engine.newBuilder().withPower(100).withType(5).build();

List<Wheel> wheels = wheelListBuilder .addWheel().withType(1).withSize(2).withColour(2).addWheelToList() .addWheel().withType(1).withSize(2).withColour(2).addWheelToList() .addWheel().withType(1).withSize(2).withColour(2).addWheelToList() .addWheel().withType(1).withSize(2).withColour(2).addWheelToList() .build();

now we have to combine all

Car car = Car.newBuilder() .addEngine().withPower(100).withType(5).done() .addWheels() .addWheel().withType(1).withSize(2).withColour(2).addWheelToList() .addWheel().withType(1).withSize(2).withColour(2).addWheelToList() .addWheel().withType(1).withSize(2).withColour(2).addWheelToList() .addWheel().withType(1).withSize(2).withColour(2).addWheelToList() .done() .build();

Page 77: From Mess To Masterpiece - JFokus 2017

NestedBuilder - The Pattern

77

@SvenRuppert

public abstract class NestedBuilder<T, V> {

protected T parent;public abstract V build()

public <P extends NestedBuilder<T, V>> P withParentBuilder(T parent) { this.parent = parent; return (P) this;} parent will connect itself…

Page 78: From Mess To Masterpiece - JFokus 2017

NestedBuilder - The Pattern

78

@SvenRuppert

public abstract class NestedBuilder<T, V> {

public T done() {

Class<?> parentClass = parent.getClass();

try { V build = this.build(); String methodname = "with" + build.getClass().getSimpleName(); Method method = parentClass.getDeclaredMethod( methodname, build.getClass()); method.invoke(parent, build);} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) { e.printStackTrace();}

}

connect itself with parent

Page 79: From Mess To Masterpiece - JFokus 2017

NestedBuilder - The Pattern

79

@SvenRuppert

the basic steps in short words

the Parent-Builder will hold the Child-Builderthe Parent-Builder will have a addChild - Methodthe Child-Builder will extend the NestedBuilderthe rest could be generated with a default Builder-Generator

Page 80: From Mess To Masterpiece - JFokus 2017

NestedBuilder - The Pattern

80

@SvenRuppert

public class Parent { private KidA kidA; private KidB kidB; //snipp..... public static final class Builder { private KidA kidA; private KidB kidB; // to add manually private KidA.Builder builderKidA = KidA.newBuilder().withParentBuilder(this); private KidB.Builder builderKidB = KidB.newBuilder().withParentBuilder(this); public KidA.Builder addKidA() { return this.builderKidA; } public KidB.Builder addKidB() { return this.builderKidB; } //---------

connect itself with child

switch to Child-Builder

Page 81: From Mess To Masterpiece - JFokus 2017

NestedBuilder - The Pattern

81

@SvenRuppert

only extends on Child-Builder

public static final class Builder extends NestedBuilder<Parent.Builder, KidA> {

Page 82: From Mess To Masterpiece - JFokus 2017

NestedBuilder - The Pattern

82

@SvenRuppert

Parent build = Parent.newBuilder() .addKidA().withNote("A").done() .addKidB().withNote("B").done() .build();System.out.println("build = " + build);

and a child could be a parent in the same timeParent build = Parent.newBuilder()

.addKidA().withNote("A") .addKidB().withNote("B").done() .done()

.build(); System.out.println("build = " + build);

Page 83: From Mess To Masterpiece - JFokus 2017

Refactoring example

based on Java8

@SvenRuppert

Page 84: From Mess To Masterpiece - JFokus 2017

84

@SvenRuppertJava8 - Functional Interfaces - Example

typical legacy implementation

Page 85: From Mess To Masterpiece - JFokus 2017

85

@SvenRuppertJava8 - Functional Interfaces - Example

typical legacy implementation

Page 86: From Mess To Masterpiece - JFokus 2017

86

@SvenRuppertJava8 - Functional Interfaces - Example

Page 87: From Mess To Masterpiece - JFokus 2017

87

@SvenRuppertJava8 - Functional Interfaces - Example

Page 88: From Mess To Masterpiece - JFokus 2017

88

@SvenRuppertJava8 - Functional Interfaces - Example

Page 89: From Mess To Masterpiece - JFokus 2017

89

@SvenRuppertJava8 - Functional Interfaces - Example

Page 90: From Mess To Masterpiece - JFokus 2017

90

@SvenRuppertJava8 - Functional Interfaces - Example

Page 91: From Mess To Masterpiece - JFokus 2017

91

@SvenRuppertJava8 - Functional Interfaces - Example

Sourcecode is on github

Page 92: From Mess To Masterpiece - JFokus 2017

Interpreter - pre Java8

92

@SvenRuppert

Page 93: From Mess To Masterpiece - JFokus 2017

Interpreter - pre Java8

93

@SvenRuppert

Page 94: From Mess To Masterpiece - JFokus 2017

Interpreter - pre Java8

94

@SvenRuppert

Page 95: From Mess To Masterpiece - JFokus 2017

Interpreter - pre Java8

95

@SvenRuppert

Page 96: From Mess To Masterpiece - JFokus 2017

Interpreter - Java8 - Java9

96

@SvenRuppert

Page 97: From Mess To Masterpiece - JFokus 2017

Interpreter - Java8 - Java9

97

@SvenRuppert

Main Idea - DataStructure to Function

Page 98: From Mess To Masterpiece - JFokus 2017

Memoizing partial cache-ing ?

@SvenRuppert

full example and code http://www.functional-reactive.org/

Page 99: From Mess To Masterpiece - JFokus 2017

prepare for

Refactoring - Clean your code nano refactoring on language level

99

@SvenRuppert

Page 100: From Mess To Masterpiece - JFokus 2017

clean your code @SvenRuppert

delete JavaDocuse final for Attributes as much as possible

replace loops with streams

extract Functional Interfacesremove anonymous classes

use everywhere the same language level

Why ?

Page 101: From Mess To Masterpiece - JFokus 2017

clean your code @SvenRuppert

delete JavaDocuse final for Attributes as much as possiblereplace loops with streamsextract Functional Interfacesremove anonymous classesuse everywhere the same language level

Why ?

know the part you want to refactor

homogeneous sources are better for machines

Page 102: From Mess To Masterpiece - JFokus 2017

prepare for

Refactoring - Summary the full picture

102

@SvenRuppert

Page 103: From Mess To Masterpiece - JFokus 2017

Refactoring - Summary

103

@SvenRuppert

prepare your teamchange the way of working

work on your project managementbuild your safety belt - mutation testing

divide and conquer - @Inject build design pattern againextract cross functionality - Proxy's

clean your code

Page 104: From Mess To Masterpiece - JFokus 2017

prepare for

Management - Summary the full picture for the C-Level

104

@SvenRuppert

Page 105: From Mess To Masterpiece - JFokus 2017

Management - Summary

105

@SvenRuppert

Now it is time to relax again ;-)

Problem solved !

Page 106: From Mess To Masterpiece - JFokus 2017

Summary

106

@SvenRuppert

places to read more about it

www.functional-reactive.org

www.java-9.org

or contact me ;-) @SvenRuppert

Thank You !!!