java day kiev - refactoring legacy code

Post on 15-Apr-2017

209 Views

Category:

Software

3 Downloads

Preview:

Click to see full reader

TRANSCRIPT

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

@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

@nicolas_frankel #refactoring

Code in real life

@nicolas_frankel #refactoring

Refactoring“Process of restructuring existing computer

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

-- Wikipedia

@nicolas_frankel #refactoring

The boy scout rule“Always leave the campground cleaner than

you found it.”

@nicolas_frankel #refactoring

Object-oriented programming• Really?• Feels like procedural

• But in Java

@nicolas_frankel #refactoring

Object calisthenics• Proposed by Jeff Bay

@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

@nicolas_frankel #refactoring

Our own legacy code

Time for DEMO

Rémi SanlavilleJohan Martinsson

@nicolas_frankel #refactoring

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

Thanks!

top related