Now that we saw a number of refactorings, we also saw
how refactorings can be performed automatically within an ID, I'd like
to make you aware of some risks involved with the user
refactorings. Refactorings are a very powerful tool, but you also have to
be careful, first of all when you do more complex refactorings,
you may also introduce subtle faults. What, we don't really call
regression errors. You might change something in the class. You might
think that that's a behavior preserving
transformation when considering the whole code,
and instead your change is affecting the behavior of some of the
other parts of the code. So, it's introducing a regression that will cause
some other functionality, some other piece
of functionality some other feature, to
work incorrectly. So you always have to be careful, and as we saw
at the beginning one way to avoid that is to run tests.
Every time you make a refactoring every time you change your code and
refactor your code. So is to get the least some confidence in
the fact that your refactoring is
indeed behavior preserving. Also consider the refactoring
should not. Be abused. Refactoring should be performed when it's needed. It's
useful to improve the design of your code when you see problems
with the design of the code. Shouldn't just be applied for the
final code because you can apply, for example, easily within a tool.
So be careful not over doing it when you refactor. And for
the same reason that we mentioned at the beginning, you should be
particularly careful when you're using refactoring
for systems that are in production.
Because if you introduce a problem, before the system goes in production,
then you might be able to catch it earlier,
with testing. Or before it's released. But, if you introduce
a problem for a system in production, then you have
to issue a new version of the code. You'll be
affecting, you might be affecting some users, because the code
fails on their machine. So, you have to be twice
as careful, when you are doing refactoring, when you're changing
your code for a system that is already in production.