Search code examples
.netdesign-patternsrefactoringcoupling

How to refactor tightly coupled classes?


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 ?

I can think of some :

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

UPDATE

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.


Solution

  • 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.