You like basejumping from buildings in China ? You like stratopheric jump ? You like refactoring without unit tests ? Well, it's your choice...
At first, try this command :
$ php mondrian.php digraph ~/MyProjectAs I said, check the ratio class/interface and the ratio of contract method on concrete methods to evaluate the level of abstraction. The lower they are, the difficultier the refactoring will be.
Second, try this command :
$ php mondrian.php spaghetti --cycle ~/MyProjectIf there is no cluster (strongly connected components), you are a lucky developer. If not, I recommand you to break the circle.
What are these classes ?
hmmm... you have to rethink and abstract the model, add some interfaces to decouple these classes. It can be tricky and you have perhaps to talk to the business people what they really want to do ?
There are good chances you need a Mediator pattern to "bind" these colleagues to work together. Don't forget to make an interface for this Mediator.
Third, try this command :
$ php mondrian.php spaghetti --strategy=concrete ~/MyProjectIs there one big ball of mud ? Well, you can check if there would be false edges because of method name collision. You can ignore calls in .mondrian.yml file. But wait ! This could mean there is a common contract between all these classes. Try to add the --cycle option to see the most intricated components but don't try to break it now.
Fourth, you could iterate these three commands :
$ php mondrian.php hidden ~/MyProjectIt helps you to find if there is really a non-typed parameter between two classes. Therefore, you start to add new dependencies, go to first stage.
Since there is no type, add new interfaces or abstract classes.
And this one :
$ php mondrian.php liskov ~/MyProjectIt shows you (in red) which classes need to be abstracted first. The red circles are the most used classes accross the source. If you abstract them with new interfaces, there are good chances you'll break many cycles and dependencies.
That's why it is the perfect time to use the refactor tool :
$ php mondrian.php refactor:abstract ~/MyProjectAnd make many iterations in this very stage.
Fifth, now you have a better matches between source code and digraph, you could try this command :
$ php mondrian.php bottleneck ~/MyProjectIt tells you what is the most critical component. It is not SRP since it should have too many responsibilities.
And this too :
$ php mondrian.php ripple ~/MyProjectIt tells you what is "on the top" of this package and what is "under the facade". This is the time to use a Facade pattern perhaps.
Sixth, it's time to show all dependencies with this command :
$ php mondrian.php spaghetti --strategy=any --cycle ~/MyProjectBeware, if you have too many classes in a cluster, Cthulhu is coming.
Seventh, you can carefully eliminates bad edges with :
$ php mondrian.php cycle ~/MyProjectCheck the collision, create new interfaces and go to stage two or three.
As you can see, there is no magic behind refactoring. It is an iterative process but with this tools, you can check at each step if you go in the right direction. Don't forget to branch over and over with GIT it is made for that !
It is only an example. Your process may be very different, depending of what kind of source code you have.
There are some guidances, in order of priority :