lecture21_refactoring.pdf - CSC3380 Object Oriented Design Lecture 21 refactoring •This week •Refactoring •Hands on lab •Next week

lecture21_refactoring.pdf - CSC3380 Object Oriented Design...

This preview shows page 1 - 13 out of 41 pages.

CSC3380 Object Oriented Design Lecture 21: refactoring
Image of page 1
What’s left? This week: Refactoring Hands on lab Next week: Presentations Then: Spring break Last week: Code review Final review
Image of page 2
Today’s Lecture Refactoring
Image of page 3
What is refactoring? Changing the structure of code without changing behavior Here’s the classic example: Refactor if( x ) { return true; } else { return false; } To “return x;”
Image of page 4
Why? Refactoring is designed to “clean up” code. It can become Easier to read Easier to debug Easier to test Refactoring undoes “ technical debt
Image of page 5
Technical Debt Wikipedia: Technical debt (also known as design debt or code debt ) is a concept in software development that reflects the implied cost of additional rework caused by choosing an easy solution now instead of using a better approach that would take longer. Sometimes you take the “easy approach” You duplicate code You have a complicated base class You use singletons Give me more examples You pay for these decisions later
Image of page 6
Image of page 7