Tuesday, April 9, 2013

A Simple Method for Dividing Code into Components

In the 3Q's method, the second stage of refactoring legacy code is 'Divide and Conquer'. In this stage, we discover and separate (or simply reorganize) the code into manageable components. Usually, this is done as per the following simple workflow:

discover and split your code into components
What to do while dividing your code into components
This is rather a straightforward logical sequence of modularizing legacy code. What we are interested now is how each step is done.

In an experiment that I have done with one team, we have separated the classes into components and After the first step, this how it looked like :)

Analysis of violations between the newly specified components
Red lines indicate communication between components which should not be allowed. As you see, nearly there are violations between all components! This is very normal, because these components are specified for the first time; and previously, all classes were allowed to talk to all other classes in the application code.

But, how did we detect these violations? In a later blog: Detect Architectural Violations Using ConQAT answers this question.

No comments: