So if you follow my class so far, you know that
I like to give a little bit of history when I talk
about a specific topic. So I'm going to do the same also
in this case for refactoring. I'm going to start by mentioning, the fact
that refactoring is something that programmers have always done. I gave
you a trivial example just a minute ago of what refactoring is.
So even more complicated refactorings are
something that are commonplace for developers.
Somehow refactoring is especially important in
the context of object-oriented languages and
probably it's because the object-oriented features are well suited to
make designs flexible and reusable. Because of the fact that help
encapsulation, information hiding, and so they make it easier to
modify something without changing the functionality that it provides to the
outside world. However, you should keep in mind that refactoring
is really not specific to object oriented languages, you can also
refactor other languages, it's just more common to see it in
that context. So one of the first examples of a specific
discussion of what the refactorings are is Opdyke's PhD
thesis in 1990. Which discusses refactorings for small talk.
And some of you might be familiar with small
talk, which is a specific objectory language. And in
more recent times, refactoring's becoming increasing popular due to
lightweight development methodoogies, due to agile development, which is
something that we just discussed in this class. For
example, when we talked about extreme programming, we mentioned refactoring
a few times. And the reason why its so popular
is because re-factoring is one of the practices that help.
Making changes less expensive. And therefore adapt to changing requirements
and changing environments more quickly.
And continuing with historical perspective, one
of the milestones in the history of re-factoring [INAUDIBLE] is
a book by Martin Fowler. This is a book entitled
Improving the Design of Existing [INAUDIBLE]. And it contains a
catalog of refactorings, a list of bad smells, in code, and
we're going to see what that mean exactly. Nothing to
do with other kinds of bad smells. It talks about
guidelines on when to apply refactoring. And finally, which is
very useful, it provides example of code, before and after.
Applying the refactoring and we're going to use more of the
same style when discussing refactoring in the rest of this
lesson. More specifically what we're discussing next, are some examples
of refactoring and also some examples of code bad smells.