开发者

Abstracting multiple C# classes

I have to deal with a project where someone else has copied and pasted the same class some 12 times, added some custo开发者_如何学运维mization, but mainly, the structure of the classes are really similar because they were copied from each other.

I am itching to refactor the code because I can't stand looking at the code base.

Is there a tool that can automate some of this headache, that is, extract identical properties and methods into a parent class and make the other classes inherit from it?


Similar to arivman, give Resharper a shot. 30 day free trial, life-time license available per person (means can take it back home, and to other jobs if they'll allow it).


I don't know any free solution (other than doing it yourself), but you could give NET Refractor from KnowDotNet a shot. They even have a 30 day free trial!


I'd also recommend you to use a tool like Clone Detective before you opt for the Natural selection, there might be more hidden duplication.

Resharper squigglies will definitely give you some hints about code smells and keyboard combos to fix then in a jiffy.

You could also potentially use some bits and pieces from here and i personally find branching and tagging to be quite effective in situations like these. Any analytical due diligence prior to delving in the code i think goes a long way too.


Here we use simian to find the duplicate code. But again you still need manual intervention 2 remove or 2 update it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜