java day kiev - refactoring legacy code

11
Рефакторинг легаси кода

Upload: nicolas-frankel

Post on 15-Apr-2017

209 views

Category:

Software


3 download

TRANSCRIPT

Page 1: Java Day Kiev - Refactoring Legacy Code

Рефакторинглегаси кода

Page 2: Java Day Kiev - Refactoring Legacy Code

@nicolas_frankel #refactoring

Write once, read many“Even if you don't intend anybody else to read

your code, there's still a very good chance that somebody will have to stare at your code and figure out what it does: That person is probably going to be you, twelve months from now.”

MSDN blog

Page 3: Java Day Kiev - Refactoring Legacy Code

@nicolas_frankel #refactoring

Code in real life

Page 4: Java Day Kiev - Refactoring Legacy Code

@nicolas_frankel #refactoring

Refactoring“Process of restructuring existing computer

code – changing the factoring – without changing its external behavior”

-- Wikipedia

Page 5: Java Day Kiev - Refactoring Legacy Code

@nicolas_frankel #refactoring

The boy scout rule“Always leave the campground cleaner than

you found it.”

Page 6: Java Day Kiev - Refactoring Legacy Code

@nicolas_frankel #refactoring

Object-oriented programming• Really?• Feels like procedural

• But in Java

Page 7: Java Day Kiev - Refactoring Legacy Code

@nicolas_frankel #refactoring

Object calisthenics• Proposed by Jeff Bay

Page 8: Java Day Kiev - Refactoring Legacy Code

@nicolas_frankel #refactoring

Object calisthenics1. Use only 1 level of indentation per method2. Don’t use else3. Wrap all primitives and strings4. Use only one . per line5. Don’t abbreviate6. Keep all entities small7. Don’t use any classes with more than 2 instance

variables8. Use first-class collections9. Don’t use any getters/setters/properties

Page 9: Java Day Kiev - Refactoring Legacy Code

@nicolas_frankel #refactoring

Our own legacy code

Time for DEMO

Rémi SanlavilleJohan Martinsson

Page 10: Java Day Kiev - Refactoring Legacy Code

@nicolas_frankel #refactoring

Q&Ahttp://blog.frankel.ch/@nicolas_frankel http://frankel.in/https://git.io/vwUcS

Page 11: Java Day Kiev - Refactoring Legacy Code

Thanks!