I'm doing a project that requires some refactoring.
My domain class is like:
Book {
static belongsTo[category: category]
Category category;
String name;
}
Category {
static hasMany [books: Book]
String name;
Category parent;
}
Now I want to change that one book may belongsTo many categories. I know how to transform the domains, but overwhelmed by the fact that I must change every single appearance of category in my view/controller/service.
For example, when a book can be in 开发者_JAVA百科2 categories, I no longer can use the navigator like "Sciences > Math > Math for elemental class".
I'm new in this project, so that I also fear that I may broke something while trying to repair the code.
Did anyone have the same experience? Is there any tip that can help reduce the complexity of this refactoring work?
Intellij Idea is very good at refactoring Java and is good enough with Grails.
Still, you'd better covered the changed classes with unit tests.
You can also provide a fallback transient property getCategory() { categories.size() == 1 ? categories[0] : null }
- this will hide some failures, and remove it only after you clean up with other problems introduced.
Sorry, nothing besides common advice.
精彩评论