Is spreading code with refactoring comments a good idea?
Posted
by
Uooo
on Programmers
See other posts from Programmers
or by Uooo
Published on 2013-11-05T08:00:37Z
Indexed on
2013/11/05
10:11 UTC
Read the original article
Hit count: 195
refactoring
|comments
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?
© Programmers or respective owner