We talk about how important it is to keep your code in working order, but no one ever really talks about keeping the container for your code in working order --- Your Project Solutions.
Per Wikipedia Refactoring code can be defined as:
Means improving it without changing its overall results, and is sometimes informally referred to as "cleaning it up". Refactoring neither fixes bug nor adds new functionality, though it might precede either activity
Lets take a look at some of the reasons why we refactor our code base (this list is NOT the be-all-end-all list)
- Keep our code soft and flexible
- We encounter new needs for our code and we refactor to allow for these changes
- Improve the design of the code
- Make the code design easier to understand
If you look at the above list you can see that you can apply many of these to the structure of your application. Let me provide a few examples
Keep our code soft and flexible Keep your source tree/project tree flexible
We all have been on projects that just kept growing and growing. If you continue to let this happen eventually you will find yourself in a world of hurt. Take the time, prune your project solutions. Maybe it make sense to create multiple solutions… Either way keep it under control.
- We encounter new needs for our
code Structure and we refactor to allow for these changes
When our code starts to smell we refactor it. We may refactor the layout, the structure or how the pieces work. We should do the same for our code structure. If a given assembly is doing too much then break it down. If a given namespace has too much responsibility, create a new one.
- Improve the design of the
code source tree
See above :)
- Make the
code design source layout easier to understand
Making your project easier to navigate and find stuff is very, very important. We refactor code so the next guy can determine which way is up. We should refactor our project structure so the next guy knows how to find/add what is needed.
So the next time you think that refactoring only applies to your source code, stop and think again. The principles of refactoring (making changes to the content without changing the intent) can apply to many other aspects of our jobs.
Till next time,
04-15-2009 2:27 PM