SlideShare una empresa de Scribd logo
1 de 94
Descargar para leer sin conexión
Włodek 
Krakowski 
Effec%ve 
Refactoring
A 
few 
words 
about 
myself 
Master’s 
degree 
in 
Computer 
Science 
(AGH 
: 
1996-­‐2001) 
13 
+ 
years 
of 
experience, 
observing 
things 
and 
improving 
them 
J 
Sabre 
: 
Junior 
-­‐> 
... 
-­‐> 
Team 
Leader 
Lumesse 
: 
Applica%on 
Architect 
Ocado 
: 
Team 
Leader 
again 
:-­‐) 
Włodzimierz 
Krakowski 
2014 2
So 
this 
is 
the 
place 
where 
I 
am 
refactoring 
:-­‐) 
Włodzimierz 
Krakowski 
2014 3
Refactoring 
to 
be 
applied... 
In 
theory 
In 
prac%ce 
In 
psychology 
Włodzimierz 
Krakowski 
2014 4
What 
these 
stories 
are 
about? 
Centuries 
ago 
... 
Many 
years 
ago 
... 
Nowadays... 
Włodzimierz 
Krakowski 
2014 5
Centuries 
ago... 
Once 
upon 
a 
%me 
there 
were 
a 
farmer 
and 
his 
goose… 
One 
day 
he 
no%ced 
that 
his 
goose 
laid 
down 
a 
golden 
egg… 
Since 
that 
day 
happy 
& 
rich 
life 
was 
going 
on… 
Włodzimierz 
Krakowski 
2014 6
Centuries 
ago... 
But 
aZer 
some 
%me 
the 
farmer 
became 
very 
greedy 
& 
impa%ent… 
… 
and 
finally 
he 
decided 
to 
kill 
the 
goose 
in 
order 
to 
get 
all 
of 
the 
gold 
from 
inside 
at 
once... 
Włodzimierz 
Krakowski 
2014 7
Centuries 
ago... 
Surprisingly 
opposite 
to 
his 
thoughts 
there 
was 
no 
gold 
inside 
the 
goose 
at 
all… 
What 
does 
the 
golden 
egg 
refer 
to? 
What 
does 
the 
goose 
refer 
to? 
Włodzimierz 
Krakowski 
2014 8
ProducOon 
and 
ProducOon 
Capability 
cannot 
be 
considered 
a 
separated 
items 
Włodzimierz 
Krakowski 
2014 9
What 
is 
effecOveness? 
• At 
first 
glance 
it 
looks 
like 
the 
effecOveness 
seems 
to 
be 
amount/size 
of 
today’s 
producOon 
• But 
diligent 
leadership 
and 
management 
needs 
to 
consider 
the 
future 
as 
well 
Włodzimierz 
Krakowski 
2014 10
Full 
picture 
of 
effecOveness 
• At 
a 
bigger 
picture 
EffecOveness 
is 
not 
only 
the 
amount 
of 
things 
being 
produced 
today 
but 
also 
ability 
to 
conOnue 
the 
producOon 
tomorrow 
• Therefore 
there 
must 
be 
a 
balance 
between 
today 
and 
tomorrow 
Włodzimierz 
Krakowski 
2014 11
Many 
years 
ago... 
Let’s 
imagine 
you 
are 
working 
in 
a 
factory... 
Włodzimierz 
Krakowski 
2014 12
Many 
years 
ago... 
CONTEST 
FOR 
EMPLOYEES 
: 
The 
one 
who 
will 
produce 
that 
biggest 
amount 
of 
the 
items 
is 
the 
winner 
Włodzimierz 
Krakowski 
2014 13
Many 
years 
ago... 
WINNER 
OF 
THE 
CONTEST 
WAS... 
... 
engineer 
who 
was 
running 
his 
machine 
24/7 
without 
any 
maintanance... 
Włodzimierz 
Krakowski 
2014 14
Many 
years 
ago... 
FACTS 
• Any 
machine 
can 
be 
working 
very 
well 
without 
any 
maintenance 
for 
some 
Ome 
• Any 
machine 
can 
be 
even 
the 
best 
for 
a 
while 
(because 
when 
the 
other 
machines 
are 
being 
maintained 
it 
can 
be 
is 
sOll 
working…) 
Włodzimierz 
Krakowski 
2014 15
Many 
years 
ago... 
• Later 
YOU 
as 
new 
(promoted) 
owner 
becomes 
responsible 
for 
such 
a 
“best” 
machine 
that 
„won” 
the 
contest 
• But 
it 
breaks 
more 
and 
more 
oeen… 
• Finally 
it 
needs 
to 
be 
replaced 
with 
a 
new 
one… 
what 
is 
more 
expensive 
that 
all 
savings 
“achieved” 
by 
lack 
of 
con%nues 
maintenance 
in 
the 
past 
Włodzimierz 
Krakowski 
2014 16
ProducOon 
and 
ProducOon 
Capability 
cannot 
be 
considered 
a 
separated 
items 
Włodzimierz 
Krakowski 
2014 17
NOWADAYS 
Is 
there 
any 
difference 
in 
our 
industry? 
Włodzimierz 
Krakowski 
2014 18
What 
is 
a 
good 
product 
in 
soeware 
development? 
• Soeware 
that 
is 
working 
as 
expected 
and 
solves 
business 
problems 
• Clients 
can 
use 
it 
efficiently 
• The 
number 
of 
funcOonality 
defects 
is 
low 
• Soeware 
is 
scalable 
if 
the 
number 
of 
input 
data 
grows 
• The 
revenue 
taken 
is 
bigger 
then 
cost 
of 
building 
it 
• … 
Włodzimierz 
Krakowski 
2014 19
What 
is 
producOon 
capability 
in 
soeware 
development? 
Fact 
: 
Soeware 
very 
rarely 
stays 
as 
it 
is 
The 
ability 
to 
extend 
the 
soeware, 
fix 
the 
defects 
is 
purely 
related 
to 
its 
technical 
state 
– Readability 
– Testability 
– Reusability 
– Complexity 
– Design 
– Maintainability 
– Extendibility 
– Performance 
• ProducOon 
capacity 
is 
ability 
to 
conOnue 
working 
with 
the 
exisOng 
soeware. 
Włodzimierz 
Krakowski 
2014 20
What 
is 
producOon 
capability 
in 
soeware 
development? 
• Second 
part 
of 
producOon 
capacity 
is 
developer’s 
– Knowledge 
– Skills 
– Desire 
to 
grow 
Włodzimierz 
Krakowski 
2014 21
Principle 
of 
balance 
Produc%on 
and 
produc%on 
capibility 
needs 
to 
grow 
together 
Włodzimierz 
Krakowski 
2014 22
Balance 
in 
soeware 
development 
Refactoring 
is 
a 
technique 
that 
can 
allow 
you 
to 
keep 
the 
balance 
when 
working 
in 
soZware 
industry 
Włodzimierz 
Krakowski 
2014 23
What 
is 
correct 
definiOon 
of 
“refactoring”? 
Is 
it 
only 
“changing 
code 
structure 
without 
changing 
its 
behavior”? 
Włodzimierz 
Krakowski 
2014 24
Refactoring 
definiOon 
• Code 
refactoring 
is 
a 
"disciplined 
technique 
for 
restructuring 
an 
exisOng 
body 
of 
code, 
altering 
its 
internal 
structure 
without 
changing 
its 
external 
behavior", 
undertaken 
in 
order 
to 
improve 
some 
of 
the 
nonfunc%onal 
aeributes 
of 
the 
soeware. 
• Refactoring 
is 
not 
– New 
funcOonality 
– Fixing 
bugs 
• Although 
it 
– follows 
them 
or 
– proceeds 
them 
Włodzimierz 
Krakowski 
2014 25
What 
are 
non-­‐funcOonal 
amributes 
of 
soeware? 
Włodzimierz 
Krakowski 
2014 26
When 
do 
we 
refactor? 
Włodzimierz 
Krakowski 
2014 27
3 
Books 
It’s 
like 
Encyclopedia... 
Turns 
it 
into 
Use 
cases.... 
Presents 
End 
to 
end 
flow 
Włodzimierz 
Krakowski 
2014 28
A 
very 
simple 
refactoring... 
Before AZer 
Włodzimierz 
Krakowski 
2014 29
Samples 
Refactoring 
Results 
Before AZer 
Włodzimierz 
Krakowski 
2014 30
Pyramid 
of 
Refactoring 
Włodzimierz 
Krakowski 
2014 31
Pyramid 
of 
Refactoring 
Włodzimierz 
Krakowski 
2014 32
Why 
is 
it 
bemer 
to 
have 
smaller 
pieces? 
SMALLER 
SMALLER 
SMALLER 
SMALLER 
SMALLER 
SMALLER 
at 
least 
up 
to 
some 
point 
it 
is 
: 
• Easier 
to 
read 
• Easier 
to 
understand 
• Easier 
to 
divide 
into 
• related 
parts 
/ 
groups 
• Easier 
to 
move 
to 
other 
classes 
• Easier 
to 
test 
• Easier 
to 
reuse 
!!! 
Włodzimierz 
Krakowski 
2014 33
Code 
segregaOon 
vs. 
garbage 
segregaOon 
It 
might 
seem 
funny 
to 
compare 
them… 
Włodzimierz 
Krakowski 
2014 34
When 
to 
stop 
: 
once 
Simple 
Design 
is 
achieved 
1. Passes 
all 
of 
the 
tests. 
2. Communicates 
the 
programmer's 
intenOons, 
i.e., 
has 
good 
names 
for 
every 
important 
concept. 
3. Expresses 
everything 
once 
and 
only 
once, 
i.e., 
it 
duplicates 
no 
code 
or 
logic 
or 
knowledge. 
4. Includes 
nothing 
that's 
unnecessary. 
Włodzimierz 
Krakowski 
2014 35
Brainstorming… 
What 
to 
do 
to 
make 
refactoring 
happen 
every 
day 
in 
my 
team? 
Włodzimierz 
Krakowski 
2014 36
Answers... 
• We 
need 
agreement 
from 
management 
• We 
need 
code 
Reviews 
• Clients 
must 
understand 
it 
• It 
must 
become 
part 
of 
stories 
• There 
must 
be 
Ome 
• There 
must 
be 
knowledge 
• Tests 
are 
needed 
• We 
need 
to 
prioriOze 
it 
• The 
architect 
needs 
to 
decide 
... 
• .... 
• How 
poor 
we 
are... 
(!!!) 
Włodzimierz 
Krakowski 
2014 37
Were 
these 
results 
usefull? 
What 
to 
do 
to 
make 
refactoring 
happen 
every 
day 
in 
my 
team? 
What 
is 
wrong 
with 
this 
quesOon? 
Włodzimierz 
Krakowski 
2014 38
How 
to 
take 
care 
of 
effecOveness? 
It 
is 
not 
a 
book 
about 
developing 
soeware 
but 
… 
Włodzimierz 
Krakowski 
2014 39
Habit 
1: 
Be 
ProacOve 
• The 
are 
two 
opOons 
• Be 
proac%ve 
– 
you 
are/become 
the 
leader 
– of 
the 
change 
– Be 
reac%ve 
-­‐ 
you 
need 
to 
follow 
behind 
/ 
adjust 
– to 
the 
change 
• Therefore 
using 
refactoring 
– You 
can 
be 
driver 
of 
the 
change 
– Or 
you 
have 
to 
accept 
what 
is 
going 
on 
– (e.g. 
there 
is 
no 
refactoring 
at 
all 
in 
the 
team) 
• Be 
part 
of 
the 
soluOon 
– 
not 
part 
of 
the 
problem 
Włodzimierz 
Krakowski 
2014 40
Habit 
1: 
Be 
ProacOve 
Laugh 
at 
it 
and 
live 
with 
it 
You 
get 
rid 
of 
responsibility 
Laugh 
at 
it 
but 
also 
take 
ac%on 
to 
solve 
the 
problem 
You 
take 
the 
responsibility 
Włodzimierz 
Krakowski 
2014 41
Habit 
1: 
Be 
ProacOve 
There 
are 
always 
things 
we 
can 
influence… 
So 
start 
from 
small 
refactorings 
in 
your 
daily 
code! 
Włodzimierz 
Krakowski 
2014 42
Pyramid 
of 
Refactoring 
again! 
Włodzimierz 
Krakowski 
2014 43
Why 
aren’t 
we 
proacOve? 
The 
role 
of 
the 
vic%m 
role 
sounds 
beeer? 
„It’s 
not 
me, 
it’s 
the 
team” 
We 
don’t 
believe 
in 
step 
by 
step 
approach... 
And 
therefore 
do 
not 
even 
take 
the 
first 
step 
!!! 
Włodzimierz 
Krakowski 
2014 44
Why 
aren’t 
we 
proacOve? 
Maybe 
we 
prefer 
even 
not 
to 
try 
to 
avoid 
failure... 
Isn’t 
it 
always 
safe 
to 
say 
„We 
as 
a 
team 
failed... 
Shame 
on 
us” 
Włodzimierz 
Krakowski 
2014 45
Habit 
2: 
Begin 
with 
the 
End 
in 
Mind 
• Improvements 
and 
invenOons 
are 
usually 
created 
twice 
– First 
Ome 
in 
your 
mind 
(leadership) 
– Second 
Ome 
in 
reality 
(management) 
• Whenever 
you 
want 
to 
achieve 
something 
answer 
the 
quesOons 
: 
– What 
is 
my 
goal? 
– Why 
I 
should 
do 
this? 
– How 
will 
I 
do 
this? 
• Be 
aware 
of 
the 
difference 
between 
leadership 
and 
management 
Włodzimierz 
Krakowski 
2014 46
Habit 
2: 
Begin 
with 
the 
End 
in 
Mind 
What 
do 
you 
want 
to 
do? 
• Keep 
the 
code 
at 
one 
level 
of 
abstracOon? 
• Keep 
things 
separated 
in 
different 
classes? 
• Replace 
condiOonals 
with 
Strategy 
Design 
Pamern? 
• Replace 
condiOonals 
with 
Polymorphism 
/ 
Subclasses? 
• Get 
rid 
of 
duplicaOon? 
Włodzimierz 
Krakowski 
2014 47
Habit 
2: 
Begin 
with 
the 
End 
in 
Mind 
Why 
do 
you 
want 
to 
do 
this 
parOcular 
code 
transformaOon? 
• Readability 
– So 
we 
save 
a 
lot 
of 
Ome 
• Extendibility 
– We 
we 
add 
new 
funcOonality 
• Testability 
– We 
can 
can 
be 
sure 
about 
our 
soluOon 
• Performance 
gain 
– So 
our 
clients 
are 
not 
frustrated 
• … 
Włodzimierz 
Krakowski 
2014 48
Habit 
2: 
Begin 
with 
the 
End 
in 
Mind 
How 
are 
you 
going 
to 
do 
this? 
• Automated 
refactorings 
from 
IDE 
(IntelliJ/Eclipse) 
• Small 
steps 
• Two 
simultaneous 
soluOons 
for 
a 
while? 
How 
do 
you 
know 
you 
are 
on 
track? 
Do 
you 
have 
test 
coverage? 
How 
will 
you 
know 
you 
are 
done? 
Włodzimierz 
Krakowski 
2014 49
Leadership 
vs 
Management 
There 
is 
a 
natural 
relaOon 
between 
pamerns 
and 
refactorings. 
DESIGN 
PATTERNS 
are 
where 
you 
want 
to 
be, 
REFACTORINGS 
are 
ways 
to 
get 
there 
from 
somewhere 
else. 
-­‐ 
MarOn 
Fowler 
Włodzimierz 
Krakowski 
2014 50
Pyramid 
of 
Refactoring 
again! 
Włodzimierz 
Krakowski 
2014 51
Find 
Your 
Own 
MoOvator 
in 
order 
to 
answer 
these 
quesOons 
You 
need 
to 
be 
driven 
by 
yourself 
from 
inside 
Włodzimierz 
Krakowski 
2014 52
Refactoring 
strategies 
Make 
everything 
as 
simple 
as 
possible, 
but 
not 
simpler. 
Albert 
Einstein 
• Refactor 
to 
understand 
• Separate 
things 
that 
change 
from 
things 
that 
don’t 
change 
Włodzimierz 
Krakowski 
2014 53
Refactoring 
strategies 
Don’t 
reinvent 
the 
wheel 
HeurisOcs 
for 
quickly 
finding 
where/ 
what 
code 
that 
should 
be 
refactored 
– 
Code 
Smells 
• Code 
duplicaOon 
• Long 
methods 
• Large 
classes 
• Data 
clumps 
• PrimiOve 
obsession 
• Shotgun 
surgery 
• AlternaOve 
classes 
with 
different 
interfaces 
• … 
Włodzimierz 
Krakowski 
2014 54
Common 
percepOon 
of 
tasks 
to 
do 
Włodzimierz 
Krakowski 
2014 55
Habit 
3: 
Put 
First 
Things 
First 
(importance 
before 
urgency) 
How 
do 
we 
spend 
%me? 
Włodzimierz 
Krakowski 
2014 56
Habit 
3: 
Put 
First 
Things 
First 
(importance 
before 
urgency) 
What 
happens 
if 
we 
do 
not 
spent 
%me 
on 
preven%on? 
Włodzimierz 
Krakowski 
2014 57
Habit 
3: 
Put 
First 
Things 
First 
(importance 
before 
urgency) 
What 
each 
quadrant 
symbolizes? 
Włodzimierz 
Krakowski 
2014 58
Habit 
3: 
Put 
First 
Things 
First 
(importance 
before 
urgency) 
Time 
for 
refactoring 
comes 
only 
it 
is 
treated 
as 
important 
item 
Włodzimierz 
Krakowski 
2014 59
Habit 
3: 
Put 
First 
Things 
First 
(importance 
before 
urgency) 
• Do 
we 
have 
to 
find 
the 
Ome 
for 
refactoring? 
– It 
is 
not 
about 
finding 
Ome. 
• Do 
we 
need 
to 
have 
permission 
(e.g. 
from 
manager) 
to 
do 
the 
refactoring? 
– Usually 
it 
is 
not 
about 
any 
permission 
especially 
if 
it 
is 
everyday 
pracOce… 
• What 
is 
TDD? 
– Test 
– Code 
– Refactor 
• Are 
we 
doing 
full 
cycle 
of 
TDD? 
• How 
to 
“find” 
Ome 
for 
refactoring? 
– Treat 
it 
as 
important 
item 
Włodzimierz 
Krakowski 
2014 60
Refactoring 
strategies 
Choose 
the 
most 
appropriate 
%me 
for 
refactoring 
• Extend 
then 
refactor 
• Refactor 
then 
extend 
• Debug/fix 
then 
refactor 
• Refactor 
then 
debug/fix 
Włodzimierz 
Krakowski 
2014 61
Pyramid 
of 
Refactoring 
again! 
Włodzimierz 
Krakowski 
2014 62
Why 
don’t 
we 
focus 
on 
important? 
Addi%onal 
IF 
is 
urgent 
and 
important 
... But 
refactoring 
is 
only 
IMPORTANT... 
Włodzimierz 
Krakowski 
2014 63
Habit 
4: 
Think 
Win-­‐Win 
What 
is 
the 
problem 
with 
compe%%on? 
Somebody 
must 
lose 
in 
order 
for 
somebody 
to 
win... 
Włodzimierz 
Krakowski 
2014 64
Habit 
4: 
Think 
Win-­‐Win 
How 
does 
it 
relate 
to 
refactoring? 
There 
must 
be 
a 
balance. 
• One 
“WIN” 
refers 
to 
business 
quality 
• The 
other 
“WIN” 
refers 
to 
technical 
quality 
These 
two 
must 
grow 
together 
Otherwise 
one 
or 
the 
other 
side 
feels 
to 
be 
abused 
and 
that 
drives 
into 
the 
conflicts 
and 
lack 
of 
cooperaOon. 
Włodzimierz 
Krakowski 
2014 65
Habit 
4: 
Think 
Win-­‐Win 
• But 
in 
case 
of 
relaOons 
between 
people 
/ 
inside 
teams 
the 
“rat’s 
race” 
approach 
is 
not 
working… 
Włodzimierz 
Krakowski 
2014 66
Habit 
4: 
Think 
Win-­‐Win 
• What 
is 
TDD 
(again)? 
– Test 
– Code 
– Refactor 
• It 
is 
nothing 
less 
or 
more 
then 
the 
win-­‐win 
strategy 
between 
func%onal 
and 
technical 
quality 
Włodzimierz 
Krakowski 
2014 67
Habit 
4: 
Think 
Win-­‐Win 
– 
one 
more 
key 
point 
REMEMBER 
: 
nobody 
enforces 
you 
to 
stay 
if 
win-­‐win 
is 
not 
possible… 
Włodzimierz 
Krakowski 
2014 68
Habit 
4: 
Win 
– 
Win 
in 
Design? 
Włodzimierz 
Krakowski 
2014 69
Pyramid 
of 
Refactoring 
again! 
Włodzimierz 
Krakowski 
2014 70
Habit 
5: 
Seek 
First 
to 
Understand, 
Then 
to 
be 
Understood 
Let’s 
imagine 
two 
people 
convincing 
each 
other 
who 
is 
right 
But 
what 
if 
they 
focused 
on 
listening 
first 
instead 
of 
talking 
first? 
Włodzimierz 
Krakowski 
2014 71
Habit 
5: 
Seek 
First 
to 
Understand, 
Then 
to 
be 
Understood 
Now 
let’s 
imagine 
how 
each 
of 
them 
feels 
once 
they 
know 
are 
have 
been 
understood 
by 
the 
other 
party… 
… 
aZer 
a 
while 
they 
want 
to 
listen 
to 
the 
other 
person 
as 
well 
because 
they 
feel 
safe 
instead 
of 
being 
aeacked 
Włodzimierz 
Krakowski 
2014 72
Habit 
5: 
Seek 
First 
to 
Understand, 
Then 
to 
be 
Understood 
How 
does 
it 
relate 
to 
refactoring? 
• Do 
not 
enforce 
your 
soluOon 
at 
the 
beginning 
• First 
understand 
the 
code, 
the 
design, 
the 
needs, 
the 
flow 
before 
you 
take 
any 
ac%ons 
Włodzimierz 
Krakowski 
2014 73
Habit 
5: 
Seek 
First 
to 
Understand, 
Then 
to 
be 
Understood 
Do 
not 
refactor 
everything 
that 
is 
around 
you 
just 
because 
now 
you 
think 
your 
solu%on 
is 
beeer 
and 
the 
other 
solu%on’s 
is 
worse 
Włodzimierz 
Krakowski 
2014 74
Habit 
5: 
Seek 
First 
to 
Understand, 
Then 
to 
be 
Understood 
But 
once 
you 
understand 
the 
others 
then 
seek 
to 
be 
understood 
by 
them 
as 
well 
(win-­‐win) 
Teach 
the 
others 
how 
to 
refactor 
in 
order 
to 
improve 
your 
refactoring 
skills 
Włodzimierz 
Krakowski 
2014 75
Pyramid 
of 
Refactoring 
again! 
Włodzimierz 
Krakowski 
2014 76
Habit 
6: 
Synergize 
Synergy 
happens 
when 
the 
whole 
system 
is 
greater 
that 
sum 
of 
its 
components 
What 
does 
it 
mean 
in 
reality? 
• It 
is 
seeking 
for 
3rd 
alternaOves 
• Maybe 
not 
my 
soluOon 
• Maybe 
not 
your 
soluOon 
• But 
3rd 
soluOon 
instead 
that 
is 
bemer 
then 
any 
soluOon 
each 
of 
us 
thought 
separately 
Włodzimierz 
Krakowski 
2014 77
Habit 6: Refactoring – each item 
synergizes 
READABIL 
ITY 
Clean 
Code 
TESTABILI 
TY 
PERFORMAN 
CE 
EXTENDIBIL 
ITY 
MAINTANA 
NCE 
Włodzimierz 
Krakowski 
2014 78
Habit 
6: 
Refactoring 
together 
is 
a 
big 
synergy 
Let’s 
do 
a 
code 
review 
before 
refactoring 
given 
code 
Let’s 
review 
aZer 
the 
refactoring 
if 
it 
the 
improvement 
is 
indeed 
visible 
“No 
one 
can 
write 
good 
code 
at 
first, 
but 
we 
can 
find 
faults 
in 
other’s 
code 
really 
well” 
(Venkat 
Subramaniam) 
Włodzimierz 
Krakowski 
2014 79
Pyramid 
of 
Refactoring 
again! 
Włodzimierz 
Krakowski 
2014 80
Habit 
7: 
Sharpen 
the 
Saw 
Do 
you 
know 
the 
story 
about 
a 
man 
cuong 
off 
a 
tree 
with 
blunt 
saw 
and 
having 
no 
%me 
to 
sharpen 
it? 
Włodzimierz 
Krakowski 
2014 81
Habit 
7: 
Sharpen 
the 
Saw 
How 
does 
it 
refer 
to 
refactoring 
then? 
But 
nothing 
more? 
Włodzimierz 
Krakowski 
2014 82
Habit 
7: 
Sharpen 
the 
Saw 
Włodzimierz 
Krakowski 
2014 83
Habit 
7: 
Sharpen 
the 
Saw 
Włodzimierz 
Krakowski 
2014 84
Pyramid 
of 
Refactoring 
again! 
Włodzimierz 
Krakowski 
2014 85
One 
more 
brainstorming… 
What 
I 
can 
do 
refactoring 
happen 
every 
day 
in 
my 
team? 
Isn’t 
it 
a 
bemer 
quesOon? 
Włodzimierz 
Krakowski 
2014 86
Answers... 
• ... 
Just 
start 
doing 
it 
• I 
can 
point 
the 
places 
to 
refactor 
once 
I 
see 
them 
• I 
will 
ask/consult 
with 
the 
others 
dirty 
code 
I 
found 
• I 
will 
show 
the 
refactoring 
I 
did 
yesterday 
• I 
can 
organize 
a 
training 
to 
share 
my 
skills 
/ 
knowledge 
• I 
will 
become 
a 
manager 
and 
entroduce 
it 
J 
• Lead 
/ 
Teach 
fellow 
programmers 
• Brown 
bags 
• Watch 
presentaOons 
together 
• We 
are 
not 
so 
poor 
any 
longer 
(!!!) 
Włodzimierz 
Krakowski 
2014 87
7 
HABITS 
OF 
EFFECTIVE 
REFACTORING 
Włodzimierz 
Krakowski 
2014 88
One 
more 
brainstorming… 
How 
seven 
habits 
of 
effec%ve 
refactoring 
can 
help 
us 
achieve 
the 
brainstormed 
ideas? 
Włodzimierz 
Krakowski 
2014 89
Answers... 
Do 
It 
Yourself!!! 
BE 
PROACTIVE 
J 
Włodzimierz 
Krakowski 
2014 90
Make 
the 
world 
around 
you 
bemer 
all 
the 
Ome 
“Leave 
the 
campground 
cleaner 
than 
you 
found 
it” 
The 
Boy 
Scouts 
of 
America 
How 
does 
it 
refer 
to 
refactoring? 
Check-­‐in 
cleaner 
code 
than 
you 
checked 
it 
out! 
Włodzimierz 
Krakowski 
2014 91
Refactoring 
must 
become 
your 
habit 
What 
is 
a 
habit: 
it 
is 
an 
ac%on 
performed 
repeatedly 
and 
automa%cally, 
usually 
almost 
without 
your 
awareness 
It 
is 
a 
merge 
of 
knowledge, 
skills 
and 
desire 
Włodzimierz 
Krakowski 
2014 92
Keep 
growing 
all 
the 
Ome! 
You 
need 
to 
experience 
to 
understand 
You 
need 
to 
collaborate 
& 
teach 
to 
grow 
Włodzimierz 
Krakowski 
2014 93
Thank 
you! 
wlodzimierz.krakowski 
(at) 
gmail.com 
Włodzimierz 
Krakowski 
2014 94

Más contenido relacionado

Similar a JDD2014: Effective refactoring - Włodek Krakowski

Examples how to move towards Zero Defects
Examples how to move towards Zero DefectsExamples how to move towards Zero Defects
Examples how to move towards Zero DefectsSQALab
 
Piotr Bogobowicz "Using simulation game to start working in Agile style – Kin...
Piotr Bogobowicz "Using simulation game to start working in Agile style – Kin...Piotr Bogobowicz "Using simulation game to start working in Agile style – Kin...
Piotr Bogobowicz "Using simulation game to start working in Agile style – Kin...Lviv Startup Club
 
Feedback Loops in Practice
Feedback Loops in PracticeFeedback Loops in Practice
Feedback Loops in PracticeMarcus Denker
 
Methodologies - Transitioning Waterfall to Agile
Methodologies - Transitioning Waterfall to AgileMethodologies - Transitioning Waterfall to Agile
Methodologies - Transitioning Waterfall to AgileTricode (part of Dept)
 
Design Thinking and the Business Model Canvas for the Mobile Economy
Design Thinking and the Business Model Canvas for the Mobile EconomyDesign Thinking and the Business Model Canvas for the Mobile Economy
Design Thinking and the Business Model Canvas for the Mobile EconomySerge Van Oudenhove
 
Cracking The Solidworks Career Code
Cracking The Solidworks Career CodeCracking The Solidworks Career Code
Cracking The Solidworks Career CodeSoumya Suman
 
Product is Hard - Marty Cagan
Product is Hard - Marty CaganProduct is Hard - Marty Cagan
Product is Hard - Marty CaganAnthony Marter
 
Getting Stakeholder Buy-in for xAPI
Getting Stakeholder Buy-in for xAPIGetting Stakeholder Buy-in for xAPI
Getting Stakeholder Buy-in for xAPIWilliam Welder
 
Transforming IT Infrastructure
Transforming IT InfrastructureTransforming IT Infrastructure
Transforming IT Infrastructuretim_evdbt
 
Designing for Possible Futures
Designing for Possible FuturesDesigning for Possible Futures
Designing for Possible Futures1508 A/S
 
Никита Галкин "Technical backlog: инструкция к применению"
Никита Галкин "Technical backlog: инструкция к применению"Никита Галкин "Technical backlog: инструкция к применению"
Никита Галкин "Technical backlog: инструкция к применению"Fwdays
 
Solid principles of oo design
Solid principles of oo designSolid principles of oo design
Solid principles of oo designConfiz
 
Defining your Path to Success by Prof Dirk Buyens
Defining your Path to Success by Prof Dirk BuyensDefining your Path to Success by Prof Dirk Buyens
Defining your Path to Success by Prof Dirk BuyensVlerick Business School
 
Experience Vlerick Day - Inge De Clippeleer
Experience Vlerick Day - Inge De ClippeleerExperience Vlerick Day - Inge De Clippeleer
Experience Vlerick Day - Inge De ClippeleerVlerick Business School
 
Scrum: From the Classroom to the Workplace :: FCUP 2018
Scrum: From the Classroom to the Workplace :: FCUP 2018Scrum: From the Classroom to the Workplace :: FCUP 2018
Scrum: From the Classroom to the Workplace :: FCUP 2018Pedro Gustavo Torres
 
UX Research: What They Don't Teach You in Grad School
UX Research: What They Don't Teach You in Grad SchoolUX Research: What They Don't Teach You in Grad School
UX Research: What They Don't Teach You in Grad SchoolGfK User Centric
 
Web 2.0 Collaboration Tools: A Quick Guide
Web 2.0 Collaboration Tools: A Quick GuideWeb 2.0 Collaboration Tools: A Quick Guide
Web 2.0 Collaboration Tools: A Quick GuideMohamed Amin Embi
 
How to go about building great tech products
How to go about building great tech productsHow to go about building great tech products
How to go about building great tech productsKuliza Technologies
 

Similar a JDD2014: Effective refactoring - Włodek Krakowski (20)

Anti patterns
Anti patternsAnti patterns
Anti patterns
 
Examples how to move towards Zero Defects
Examples how to move towards Zero DefectsExamples how to move towards Zero Defects
Examples how to move towards Zero Defects
 
Piotr Bogobowicz "Using simulation game to start working in Agile style – Kin...
Piotr Bogobowicz "Using simulation game to start working in Agile style – Kin...Piotr Bogobowicz "Using simulation game to start working in Agile style – Kin...
Piotr Bogobowicz "Using simulation game to start working in Agile style – Kin...
 
Feedback Loops in Practice
Feedback Loops in PracticeFeedback Loops in Practice
Feedback Loops in Practice
 
Methodologies - Transitioning Waterfall to Agile
Methodologies - Transitioning Waterfall to AgileMethodologies - Transitioning Waterfall to Agile
Methodologies - Transitioning Waterfall to Agile
 
Design Thinking and the Business Model Canvas for the Mobile Economy
Design Thinking and the Business Model Canvas for the Mobile EconomyDesign Thinking and the Business Model Canvas for the Mobile Economy
Design Thinking and the Business Model Canvas for the Mobile Economy
 
Cracking The Solidworks Career Code
Cracking The Solidworks Career CodeCracking The Solidworks Career Code
Cracking The Solidworks Career Code
 
Product is Hard - Marty Cagan
Product is Hard - Marty CaganProduct is Hard - Marty Cagan
Product is Hard - Marty Cagan
 
The domino maze
The domino mazeThe domino maze
The domino maze
 
Getting Stakeholder Buy-in for xAPI
Getting Stakeholder Buy-in for xAPIGetting Stakeholder Buy-in for xAPI
Getting Stakeholder Buy-in for xAPI
 
Transforming IT Infrastructure
Transforming IT InfrastructureTransforming IT Infrastructure
Transforming IT Infrastructure
 
Designing for Possible Futures
Designing for Possible FuturesDesigning for Possible Futures
Designing for Possible Futures
 
Никита Галкин "Technical backlog: инструкция к применению"
Никита Галкин "Technical backlog: инструкция к применению"Никита Галкин "Technical backlog: инструкция к применению"
Никита Галкин "Technical backlog: инструкция к применению"
 
Solid principles of oo design
Solid principles of oo designSolid principles of oo design
Solid principles of oo design
 
Defining your Path to Success by Prof Dirk Buyens
Defining your Path to Success by Prof Dirk BuyensDefining your Path to Success by Prof Dirk Buyens
Defining your Path to Success by Prof Dirk Buyens
 
Experience Vlerick Day - Inge De Clippeleer
Experience Vlerick Day - Inge De ClippeleerExperience Vlerick Day - Inge De Clippeleer
Experience Vlerick Day - Inge De Clippeleer
 
Scrum: From the Classroom to the Workplace :: FCUP 2018
Scrum: From the Classroom to the Workplace :: FCUP 2018Scrum: From the Classroom to the Workplace :: FCUP 2018
Scrum: From the Classroom to the Workplace :: FCUP 2018
 
UX Research: What They Don't Teach You in Grad School
UX Research: What They Don't Teach You in Grad SchoolUX Research: What They Don't Teach You in Grad School
UX Research: What They Don't Teach You in Grad School
 
Web 2.0 Collaboration Tools: A Quick Guide
Web 2.0 Collaboration Tools: A Quick GuideWeb 2.0 Collaboration Tools: A Quick Guide
Web 2.0 Collaboration Tools: A Quick Guide
 
How to go about building great tech products
How to go about building great tech productsHow to go about building great tech products
How to go about building great tech products
 

Último

%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...masabamasaba
 
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...masabamasaba
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...Shane Coughlan
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesVictorSzoltysek
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyviewmasabamasaba
 
Generic or specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisionsGeneric or specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisionsBert Jan Schrijver
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Steffen Staab
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech studentsHimanshiGarg82
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024Mind IT Systems
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnAmarnathKambale
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...SelfMade bd
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...Health
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisamasabamasaba
 
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburgmasabamasaba
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfVishalKumarJha10
 

Último (20)

%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
 
Generic or specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisionsGeneric or specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisions
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
 

JDD2014: Effective refactoring - Włodek Krakowski

  • 2. A few words about myself Master’s degree in Computer Science (AGH : 1996-­‐2001) 13 + years of experience, observing things and improving them J Sabre : Junior -­‐> ... -­‐> Team Leader Lumesse : Applica%on Architect Ocado : Team Leader again :-­‐) Włodzimierz Krakowski 2014 2
  • 3. So this is the place where I am refactoring :-­‐) Włodzimierz Krakowski 2014 3
  • 4. Refactoring to be applied... In theory In prac%ce In psychology Włodzimierz Krakowski 2014 4
  • 5. What these stories are about? Centuries ago ... Many years ago ... Nowadays... Włodzimierz Krakowski 2014 5
  • 6. Centuries ago... Once upon a %me there were a farmer and his goose… One day he no%ced that his goose laid down a golden egg… Since that day happy & rich life was going on… Włodzimierz Krakowski 2014 6
  • 7. Centuries ago... But aZer some %me the farmer became very greedy & impa%ent… … and finally he decided to kill the goose in order to get all of the gold from inside at once... Włodzimierz Krakowski 2014 7
  • 8. Centuries ago... Surprisingly opposite to his thoughts there was no gold inside the goose at all… What does the golden egg refer to? What does the goose refer to? Włodzimierz Krakowski 2014 8
  • 9. ProducOon and ProducOon Capability cannot be considered a separated items Włodzimierz Krakowski 2014 9
  • 10. What is effecOveness? • At first glance it looks like the effecOveness seems to be amount/size of today’s producOon • But diligent leadership and management needs to consider the future as well Włodzimierz Krakowski 2014 10
  • 11. Full picture of effecOveness • At a bigger picture EffecOveness is not only the amount of things being produced today but also ability to conOnue the producOon tomorrow • Therefore there must be a balance between today and tomorrow Włodzimierz Krakowski 2014 11
  • 12. Many years ago... Let’s imagine you are working in a factory... Włodzimierz Krakowski 2014 12
  • 13. Many years ago... CONTEST FOR EMPLOYEES : The one who will produce that biggest amount of the items is the winner Włodzimierz Krakowski 2014 13
  • 14. Many years ago... WINNER OF THE CONTEST WAS... ... engineer who was running his machine 24/7 without any maintanance... Włodzimierz Krakowski 2014 14
  • 15. Many years ago... FACTS • Any machine can be working very well without any maintenance for some Ome • Any machine can be even the best for a while (because when the other machines are being maintained it can be is sOll working…) Włodzimierz Krakowski 2014 15
  • 16. Many years ago... • Later YOU as new (promoted) owner becomes responsible for such a “best” machine that „won” the contest • But it breaks more and more oeen… • Finally it needs to be replaced with a new one… what is more expensive that all savings “achieved” by lack of con%nues maintenance in the past Włodzimierz Krakowski 2014 16
  • 17. ProducOon and ProducOon Capability cannot be considered a separated items Włodzimierz Krakowski 2014 17
  • 18. NOWADAYS Is there any difference in our industry? Włodzimierz Krakowski 2014 18
  • 19. What is a good product in soeware development? • Soeware that is working as expected and solves business problems • Clients can use it efficiently • The number of funcOonality defects is low • Soeware is scalable if the number of input data grows • The revenue taken is bigger then cost of building it • … Włodzimierz Krakowski 2014 19
  • 20. What is producOon capability in soeware development? Fact : Soeware very rarely stays as it is The ability to extend the soeware, fix the defects is purely related to its technical state – Readability – Testability – Reusability – Complexity – Design – Maintainability – Extendibility – Performance • ProducOon capacity is ability to conOnue working with the exisOng soeware. Włodzimierz Krakowski 2014 20
  • 21. What is producOon capability in soeware development? • Second part of producOon capacity is developer’s – Knowledge – Skills – Desire to grow Włodzimierz Krakowski 2014 21
  • 22. Principle of balance Produc%on and produc%on capibility needs to grow together Włodzimierz Krakowski 2014 22
  • 23. Balance in soeware development Refactoring is a technique that can allow you to keep the balance when working in soZware industry Włodzimierz Krakowski 2014 23
  • 24. What is correct definiOon of “refactoring”? Is it only “changing code structure without changing its behavior”? Włodzimierz Krakowski 2014 24
  • 25. Refactoring definiOon • Code refactoring is a "disciplined technique for restructuring an exisOng body of code, altering its internal structure without changing its external behavior", undertaken in order to improve some of the nonfunc%onal aeributes of the soeware. • Refactoring is not – New funcOonality – Fixing bugs • Although it – follows them or – proceeds them Włodzimierz Krakowski 2014 25
  • 26. What are non-­‐funcOonal amributes of soeware? Włodzimierz Krakowski 2014 26
  • 27. When do we refactor? Włodzimierz Krakowski 2014 27
  • 28. 3 Books It’s like Encyclopedia... Turns it into Use cases.... Presents End to end flow Włodzimierz Krakowski 2014 28
  • 29. A very simple refactoring... Before AZer Włodzimierz Krakowski 2014 29
  • 30. Samples Refactoring Results Before AZer Włodzimierz Krakowski 2014 30
  • 31. Pyramid of Refactoring Włodzimierz Krakowski 2014 31
  • 32. Pyramid of Refactoring Włodzimierz Krakowski 2014 32
  • 33. Why is it bemer to have smaller pieces? SMALLER SMALLER SMALLER SMALLER SMALLER SMALLER at least up to some point it is : • Easier to read • Easier to understand • Easier to divide into • related parts / groups • Easier to move to other classes • Easier to test • Easier to reuse !!! Włodzimierz Krakowski 2014 33
  • 34. Code segregaOon vs. garbage segregaOon It might seem funny to compare them… Włodzimierz Krakowski 2014 34
  • 35. When to stop : once Simple Design is achieved 1. Passes all of the tests. 2. Communicates the programmer's intenOons, i.e., has good names for every important concept. 3. Expresses everything once and only once, i.e., it duplicates no code or logic or knowledge. 4. Includes nothing that's unnecessary. Włodzimierz Krakowski 2014 35
  • 36. Brainstorming… What to do to make refactoring happen every day in my team? Włodzimierz Krakowski 2014 36
  • 37. Answers... • We need agreement from management • We need code Reviews • Clients must understand it • It must become part of stories • There must be Ome • There must be knowledge • Tests are needed • We need to prioriOze it • The architect needs to decide ... • .... • How poor we are... (!!!) Włodzimierz Krakowski 2014 37
  • 38. Were these results usefull? What to do to make refactoring happen every day in my team? What is wrong with this quesOon? Włodzimierz Krakowski 2014 38
  • 39. How to take care of effecOveness? It is not a book about developing soeware but … Włodzimierz Krakowski 2014 39
  • 40. Habit 1: Be ProacOve • The are two opOons • Be proac%ve – you are/become the leader – of the change – Be reac%ve -­‐ you need to follow behind / adjust – to the change • Therefore using refactoring – You can be driver of the change – Or you have to accept what is going on – (e.g. there is no refactoring at all in the team) • Be part of the soluOon – not part of the problem Włodzimierz Krakowski 2014 40
  • 41. Habit 1: Be ProacOve Laugh at it and live with it You get rid of responsibility Laugh at it but also take ac%on to solve the problem You take the responsibility Włodzimierz Krakowski 2014 41
  • 42. Habit 1: Be ProacOve There are always things we can influence… So start from small refactorings in your daily code! Włodzimierz Krakowski 2014 42
  • 43. Pyramid of Refactoring again! Włodzimierz Krakowski 2014 43
  • 44. Why aren’t we proacOve? The role of the vic%m role sounds beeer? „It’s not me, it’s the team” We don’t believe in step by step approach... And therefore do not even take the first step !!! Włodzimierz Krakowski 2014 44
  • 45. Why aren’t we proacOve? Maybe we prefer even not to try to avoid failure... Isn’t it always safe to say „We as a team failed... Shame on us” Włodzimierz Krakowski 2014 45
  • 46. Habit 2: Begin with the End in Mind • Improvements and invenOons are usually created twice – First Ome in your mind (leadership) – Second Ome in reality (management) • Whenever you want to achieve something answer the quesOons : – What is my goal? – Why I should do this? – How will I do this? • Be aware of the difference between leadership and management Włodzimierz Krakowski 2014 46
  • 47. Habit 2: Begin with the End in Mind What do you want to do? • Keep the code at one level of abstracOon? • Keep things separated in different classes? • Replace condiOonals with Strategy Design Pamern? • Replace condiOonals with Polymorphism / Subclasses? • Get rid of duplicaOon? Włodzimierz Krakowski 2014 47
  • 48. Habit 2: Begin with the End in Mind Why do you want to do this parOcular code transformaOon? • Readability – So we save a lot of Ome • Extendibility – We we add new funcOonality • Testability – We can can be sure about our soluOon • Performance gain – So our clients are not frustrated • … Włodzimierz Krakowski 2014 48
  • 49. Habit 2: Begin with the End in Mind How are you going to do this? • Automated refactorings from IDE (IntelliJ/Eclipse) • Small steps • Two simultaneous soluOons for a while? How do you know you are on track? Do you have test coverage? How will you know you are done? Włodzimierz Krakowski 2014 49
  • 50. Leadership vs Management There is a natural relaOon between pamerns and refactorings. DESIGN PATTERNS are where you want to be, REFACTORINGS are ways to get there from somewhere else. -­‐ MarOn Fowler Włodzimierz Krakowski 2014 50
  • 51. Pyramid of Refactoring again! Włodzimierz Krakowski 2014 51
  • 52. Find Your Own MoOvator in order to answer these quesOons You need to be driven by yourself from inside Włodzimierz Krakowski 2014 52
  • 53. Refactoring strategies Make everything as simple as possible, but not simpler. Albert Einstein • Refactor to understand • Separate things that change from things that don’t change Włodzimierz Krakowski 2014 53
  • 54. Refactoring strategies Don’t reinvent the wheel HeurisOcs for quickly finding where/ what code that should be refactored – Code Smells • Code duplicaOon • Long methods • Large classes • Data clumps • PrimiOve obsession • Shotgun surgery • AlternaOve classes with different interfaces • … Włodzimierz Krakowski 2014 54
  • 55. Common percepOon of tasks to do Włodzimierz Krakowski 2014 55
  • 56. Habit 3: Put First Things First (importance before urgency) How do we spend %me? Włodzimierz Krakowski 2014 56
  • 57. Habit 3: Put First Things First (importance before urgency) What happens if we do not spent %me on preven%on? Włodzimierz Krakowski 2014 57
  • 58. Habit 3: Put First Things First (importance before urgency) What each quadrant symbolizes? Włodzimierz Krakowski 2014 58
  • 59. Habit 3: Put First Things First (importance before urgency) Time for refactoring comes only it is treated as important item Włodzimierz Krakowski 2014 59
  • 60. Habit 3: Put First Things First (importance before urgency) • Do we have to find the Ome for refactoring? – It is not about finding Ome. • Do we need to have permission (e.g. from manager) to do the refactoring? – Usually it is not about any permission especially if it is everyday pracOce… • What is TDD? – Test – Code – Refactor • Are we doing full cycle of TDD? • How to “find” Ome for refactoring? – Treat it as important item Włodzimierz Krakowski 2014 60
  • 61. Refactoring strategies Choose the most appropriate %me for refactoring • Extend then refactor • Refactor then extend • Debug/fix then refactor • Refactor then debug/fix Włodzimierz Krakowski 2014 61
  • 62. Pyramid of Refactoring again! Włodzimierz Krakowski 2014 62
  • 63. Why don’t we focus on important? Addi%onal IF is urgent and important ... But refactoring is only IMPORTANT... Włodzimierz Krakowski 2014 63
  • 64. Habit 4: Think Win-­‐Win What is the problem with compe%%on? Somebody must lose in order for somebody to win... Włodzimierz Krakowski 2014 64
  • 65. Habit 4: Think Win-­‐Win How does it relate to refactoring? There must be a balance. • One “WIN” refers to business quality • The other “WIN” refers to technical quality These two must grow together Otherwise one or the other side feels to be abused and that drives into the conflicts and lack of cooperaOon. Włodzimierz Krakowski 2014 65
  • 66. Habit 4: Think Win-­‐Win • But in case of relaOons between people / inside teams the “rat’s race” approach is not working… Włodzimierz Krakowski 2014 66
  • 67. Habit 4: Think Win-­‐Win • What is TDD (again)? – Test – Code – Refactor • It is nothing less or more then the win-­‐win strategy between func%onal and technical quality Włodzimierz Krakowski 2014 67
  • 68. Habit 4: Think Win-­‐Win – one more key point REMEMBER : nobody enforces you to stay if win-­‐win is not possible… Włodzimierz Krakowski 2014 68
  • 69. Habit 4: Win – Win in Design? Włodzimierz Krakowski 2014 69
  • 70. Pyramid of Refactoring again! Włodzimierz Krakowski 2014 70
  • 71. Habit 5: Seek First to Understand, Then to be Understood Let’s imagine two people convincing each other who is right But what if they focused on listening first instead of talking first? Włodzimierz Krakowski 2014 71
  • 72. Habit 5: Seek First to Understand, Then to be Understood Now let’s imagine how each of them feels once they know are have been understood by the other party… … aZer a while they want to listen to the other person as well because they feel safe instead of being aeacked Włodzimierz Krakowski 2014 72
  • 73. Habit 5: Seek First to Understand, Then to be Understood How does it relate to refactoring? • Do not enforce your soluOon at the beginning • First understand the code, the design, the needs, the flow before you take any ac%ons Włodzimierz Krakowski 2014 73
  • 74. Habit 5: Seek First to Understand, Then to be Understood Do not refactor everything that is around you just because now you think your solu%on is beeer and the other solu%on’s is worse Włodzimierz Krakowski 2014 74
  • 75. Habit 5: Seek First to Understand, Then to be Understood But once you understand the others then seek to be understood by them as well (win-­‐win) Teach the others how to refactor in order to improve your refactoring skills Włodzimierz Krakowski 2014 75
  • 76. Pyramid of Refactoring again! Włodzimierz Krakowski 2014 76
  • 77. Habit 6: Synergize Synergy happens when the whole system is greater that sum of its components What does it mean in reality? • It is seeking for 3rd alternaOves • Maybe not my soluOon • Maybe not your soluOon • But 3rd soluOon instead that is bemer then any soluOon each of us thought separately Włodzimierz Krakowski 2014 77
  • 78. Habit 6: Refactoring – each item synergizes READABIL ITY Clean Code TESTABILI TY PERFORMAN CE EXTENDIBIL ITY MAINTANA NCE Włodzimierz Krakowski 2014 78
  • 79. Habit 6: Refactoring together is a big synergy Let’s do a code review before refactoring given code Let’s review aZer the refactoring if it the improvement is indeed visible “No one can write good code at first, but we can find faults in other’s code really well” (Venkat Subramaniam) Włodzimierz Krakowski 2014 79
  • 80. Pyramid of Refactoring again! Włodzimierz Krakowski 2014 80
  • 81. Habit 7: Sharpen the Saw Do you know the story about a man cuong off a tree with blunt saw and having no %me to sharpen it? Włodzimierz Krakowski 2014 81
  • 82. Habit 7: Sharpen the Saw How does it refer to refactoring then? But nothing more? Włodzimierz Krakowski 2014 82
  • 83. Habit 7: Sharpen the Saw Włodzimierz Krakowski 2014 83
  • 84. Habit 7: Sharpen the Saw Włodzimierz Krakowski 2014 84
  • 85. Pyramid of Refactoring again! Włodzimierz Krakowski 2014 85
  • 86. One more brainstorming… What I can do refactoring happen every day in my team? Isn’t it a bemer quesOon? Włodzimierz Krakowski 2014 86
  • 87. Answers... • ... Just start doing it • I can point the places to refactor once I see them • I will ask/consult with the others dirty code I found • I will show the refactoring I did yesterday • I can organize a training to share my skills / knowledge • I will become a manager and entroduce it J • Lead / Teach fellow programmers • Brown bags • Watch presentaOons together • We are not so poor any longer (!!!) Włodzimierz Krakowski 2014 87
  • 88. 7 HABITS OF EFFECTIVE REFACTORING Włodzimierz Krakowski 2014 88
  • 89. One more brainstorming… How seven habits of effec%ve refactoring can help us achieve the brainstormed ideas? Włodzimierz Krakowski 2014 89
  • 90. Answers... Do It Yourself!!! BE PROACTIVE J Włodzimierz Krakowski 2014 90
  • 91. Make the world around you bemer all the Ome “Leave the campground cleaner than you found it” The Boy Scouts of America How does it refer to refactoring? Check-­‐in cleaner code than you checked it out! Włodzimierz Krakowski 2014 91
  • 92. Refactoring must become your habit What is a habit: it is an ac%on performed repeatedly and automa%cally, usually almost without your awareness It is a merge of knowledge, skills and desire Włodzimierz Krakowski 2014 92
  • 93. Keep growing all the Ome! You need to experience to understand You need to collaborate & teach to grow Włodzimierz Krakowski 2014 93
  • 94. Thank you! wlodzimierz.krakowski (at) gmail.com Włodzimierz Krakowski 2014 94