Is spreading code with refactoring comments a good idea?
- by Uooo
I am working on a "spaghetti-code" project, and while I am fixing bugs and implementing new features, I also do some refactoring in order to make the code unit-testable.
The code is often so tightly coupled or complicated that fixing a small bug would result in a lot of classes being rewritten. So I decided to draw a line somewhere in the code where I stop refactoring. To make this clear, I drop some comments in the code explaining the situation, like:
class RefactoredClass {
private SingletonClass xyz;
// I know SingletonClass is a Singleton, so I would not need to pass it here.
// However, I would like to get rid of it in the future, so it is passed as a
// parameter here to make this change easier later.
public RefactoredClass(SingletonClass xyz) {
this.xyz = xyz;
}
}
Or, another piece of cake:
// This might be a good candidate to be refactored. The structure is like:
// Version String
// |
// +--> ...
// |
// +--> ...
// |
// ... and so on ...
//
Map map = new HashMap<String, Map<String, Map<String, List<String>>>>();
Is this a good idea? What should I keep in mind when doing so?