Chapter 7 - Refactoring Flashcards
What is the Motivation of Refactoring?
es gibt 3 Stellschrauben: Deadline, External Quality (Features) und Internal Quality (Code, sieht der Kunde nicht) wobei oft nur 2 von 3 anpassbar sind. Code wird öfter gelesen als geschrieben, oft aktueller als documentation
What is Refactoring?
improvement of the internal structure without changing external behavior, longevity (langlebigkeit) of software requires continuous improvement
How is refactoring done?
carried out in small steps, test cases safeguard the correctness of transformations, if there are no tests: write them at first!
Why might Refactoring be necessary?
adding functionality leads to duplicate code (unabsichtlich da Entwickler evtl. nicht ganzen Code kennt) –> Refactoring
When should Refactoring be done?
beim dritten Mal wo man über das Problem stolpert
What are problems with refactoring?
leads to Indirection (Umweg): nice code but bad performance –> 90/10 rule (90% of runtime is spent for 10% code)
Explain “Bad Smells”
when is design bad? Code metrics do not really help (e.g. inheritance depth of 3 might be worse or of 7 might be still okay…)
Name Bad Smells Indicators
Duplicate Code, Long methods, Switch statements, Comments
Explain “Refactoring to Patterns”
introduce patterns while refactoring, e.g. null object