Episode 57: Refactoring Code
Podcast: Play in new window | Download
Refactoring your code is essential in large topics. We talk about what refactoring is and things to look for when refactoring
News/Follow-ups – 00:36
- Bitbucket upgrades space
- HotGloo leaves beta, releases plans
- Balsamiq is also great for wire framing – from Craig
Geek Tool – 06:40
- Pocket Ref – Your pocket reference for everything
- O’Reilly Pocket Reference Series
Webapps – 09:09
- DummyImage – Dummy images to fill spaces
- Visual representation of popular sorting algorithms
Topic – 15:56
- Refactoring Code
- What?
- Change source code without changing the external functions/behavior
- Why?
- Improved readability
- Reduced complexity
- Improved maintainability
- Improve extensibility
- Things you can do
- Break large routines into smaller sub routines
- Look for duplicated code and reduce it to used a shared function
- Code smells (episode 21)
- Find old commented out code and remove it, use SCM for storing old code you might want
- Find methods with 7+ parameters – Usually means that a new class should be created
- Replace variables with names like x and foo – Sometimes as developers we are too busy in our train of thought to think of descriptive variable names and make something up just for the time being. Find these and change them to more descriptive ones.
- Look for comments that tell the what and not the why
- A severe code stench emanates when the scroll bar appears – Reduce complex nested ifs and loops
- Look for methods for gtgtwhich you cannot understand/explain in less than 25 seconds
- A group of unit tests are needed before refactoring
- Getting Started with Refactoring
- What?
March 8th, 2010 at 8:00 am
Pretty cool seeing the sorting algorithms visually. I had a Computer Science professor who was really into sorting and made code all of the popular sorts.
March 8th, 2010 at 9:54 am
Yeah looking at those animations reminded me that I don’t remember how to do the different sorts anymore! I should bone up.