如何重构紧耦合类? [英] How to refactor tightly coupled classes?

查看:176
本文介绍了如何重构紧耦合类?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图重构一个很大的紧耦合的应用程序,并试图使其更易于维护和灵活。

I'm trying to refactor a big tightly coupled application and trying to make it more maintainable and flexible.

我有很多的单元测试,所以我希望重构一步一步来。

I've got many unit tests, so I'm hoping to refactor step by step.

这设计放大器;重构模式我应该考虑实施/应用来完成这个任务?

Which Design & Refactoring Patterns should I consider implementing / applying to accomplish this task ?

我能想到的一些:

  • Extract Interface
  • Extract Method
  • Dependency Injection

也随时分享自己的经验和最佳实践的这种重构工作。

Also feel free to share your own experience and best practices for this kind of refactoring job.

更新

我执行这个重构由于以下原因:在这个问题解释。基本上,我无法实现的插件系统,而不提取夫妇的接口,这些接口都高度耦合,需要分离的应用40+ DLL文件只是编译没有循环引用的问题。

I'm carrying out this refactoring because of the reasons explained in this question. Basically I can't implement a plugin system without extracting an couple of interfaces and those interfaces are highly coupled which requires separated the application in 40+ DLLs to just compile without circular referencing problem.

推荐答案

感谢所有的答案,有这么多不同的方式挣扎后,我发现,最好的办法是创造的一切接口。这让我随意更改设计,我只是打破了构建一天(一天,因为该项目是大,我需要解决这么多的引用和单元测试+一些重构)。

Thanks for all answers, After struggling with so many different ways I found that the best thing to do was creating interfaces for everything. This allowed me to change the design freely and I only break the build for a day (a day because the project was big and I need to fix so many references and unit tests + some refactoring).

在当天提取和固定所有的接口,我可以创建单独的解决方案,并与自由的设计发挥。

After day extracting and fixing all interfaces I can create separate solutions and play with the design freely.

我觉得应该朝着一切接口,然后基本上第一步试图摆脱内部的相关性。

Basically first move I think should be moving everything to interfaces and then try to get rid of internal dependencies.

这篇关于如何重构紧耦合类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆