Create a superclass from multiple classes that have common members [closed]

删除回忆录丶 提交于 2020-01-13 14:56:04

问题


I've had this a number of times now. In longer running software projects two or three classes are totally different at the outset. However, as time goes by requirements change, users get a bit smarter, on rare occasions I even get a bit smarter and two seemingly different processes turn out to be very similar. As a consequence, code needs to be modified and these two or three classes end up looking too similar for comfort. They're just screaming to be inherited from a common superclass.

Now I'm an innate lazy guy (reason why I'm making software in the first place) and I'd love to have a tool that does the merging into a superclass for me. With Resharper I can create a superclass from one type.

Does anyone know of a tool that can do this trick with multiple classes, or otherwise some kind of comparison tool that presents commonalities between a number of classes?


回答1:


There is no tool I know of that can take two or more classes and simply define commonalities.

The closest I have seen in refactoring tools would only operate on a single class and still require input from a programmer.

This is a complex thing to do automatically, so in my opinion a programmer is the best tool...



来源:https://stackoverflow.com/questions/7415869/create-a-superclass-from-multiple-classes-that-have-common-members

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!