Original Post
Refactor! Refactor! Refactor! How often do you refactor your code? What's your process? I don't refactor enough. Sometimes I spend too long refactoring something that doesn't need it. #1) Identify small problems - refactoring repeated code into functions, reorganizing variables. I find that starting with this leads naturally into #2) Microscopic re-engineering - Without making any major engineering changes, reorganize within a class. Take advantage of nested classes, isolate code to respective classes. Maybe a method would belong better in a different class, to make a relationship clearer. #3) Massive re-engineering - so you have a functional prototype, and now you need to make it more extensible, flexible, or freeze its implementation for a while. Break classes up. Look to design patterns to simplify relationships, but don't re-engineer without clearly stated reasons. I like to start with small nagging issues, and I find that by clearing up areas of code that have been bugging me for a while, there is a natural outward growth into more major revisions; the necessary intensive revisions tend to make themselves apparent by focusing on small issues first. Anything I'm missing? Any tips? Often I delay refactoring for too long because it feels like housekeeping, but I try and stay in a cycle of implementing functionality, and once a new (major) feature has been added, either rewrite that portion of code from scratch with a new design (you learn a lot of lessons writing the code the first time around, and don't want to locked into the 'hacky' implementation you used to just get it working) or if the code is clear enough, simply refactor. How do you find the balance between rewriting a component and simply refactoring what you already have? What do you consider?