Property of Penn Engineering
Intro to Refactoring
Copyright By PowCoder代写 加微信 powcoder
Property of Penn Engineering
“Any fool can write code
that a computer will
understand.
“Good programmers write
code that humans can
understand.”
Refactoring
Property of Penn Engineering
• Improve the internal quality of the code
• Simplify future code changes
• Reduce the amount of code to maintain
• Refactoring is not bug fixing!
Goals of Refactoring
Property of Penn Engineering
• CONSTANTLY! “Refactor mercilessly”
• When you see code (or are writing code) that
doesn’t adhere to the intended design
• As a way of getting an understanding of the code
When Should We Refactor?
Property of Penn Engineering
• CAREFULLY! Run tests after every change
• Make small changes before big ones
• Be careful about:
• Introducing bugs
• Breaking “published” interfaces
• Unnecessarily decreasing external quality
How Should We Refactor?
Property of Penn Engineering
• CODE SMELLS: indications of bad design
• Code that is hard to read or understand
• Code that does not adhere to conventions
• Code that is unnecessary or in the wrong place
What Should We Refactor?
Property of Penn Engineering
• Improving the internal quality of existing code
• Do this carefully! Always test after each change
• Always be on the lookout for code smells
Refactoring
程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com