A couple of minutes ago we talked about the fact that well, we
might need to change our design a lot, so how we going to do
that, that's going to be expensive. Well it's not very expensive, if we can
do efficient refactoring. Which is another
one of the important xp practices. And
what does it mean to refactor? It means to take a piece of
code who's design might be suboptimal, because for example, we evolved it, we
didn't take into account that from the beginning some of the features that
had to be added later, probably because we didn't even know about this
feature, because the requirements evolved. So we're going to take this piece
of code and we're going to restructure it, so that it becomes simple
and maintainable. Developers are expected to
refactor as soon as opportunities for
improvement, are found. And that happens for example, before adding some code.
You might look at the code that you're about to modify, or
to which you are about to add parts, and say can we
change the program to make the addition simple, that has maintainability or
we can do it after adding some code to our code base.
We might look at the code, the resulting code, and say well
can we make the program simpler? Was the running all the tests
and the key point here is that we don't want to refactor on
speculation, but we want to refactor on demand, on the system, and the
process needed. Again the goal is just to keep the code simple
and maintainable, not to over do it. And as I mentioned before
we're going to have a whole lesson, the next lesson on refactoring. So
we're going to go in more depth in the discussion of this topic.