Refactoring Fundamentals

Refactoring is a critical developer skill that helps keep code from collapsing under its own weight. This course covers when and how to refactor code, as well as a wide variety of "code smells" that may indicate some refactoring is warranted. The course concludes with a refactoring kata that students can perform on their own to practice their refactoring skills.
Course info
Rating
(356)
Level
Intermediate
Updated
Dec 13, 2013
Duration
8h 1m
Table of contents
Introducing Refactoring
Bloating Code Smells
Obfuscating Code Smells
Object Orientation Abuser Code Smells
Code Smells: Change Preventer
Code Smells: Dispensables
Code Smells: The Couplers
Environment and Testing Code Smells
Method Refactorings
More Method Refactorings
Class and Object Refactorings
Class Hierarchy Refactorings
Pattern-Based Refactorings
Gilded Rose Kata
Description
Course info
Rating
(356)
Level
Intermediate
Updated
Dec 13, 2013
Duration
8h 1m
Description

Refactoring is a critical developer skill that helps keep code from collapsing under its own weight. Learn how to recognize "code smells" that may indicate the need for refactoring, the refactoring process, and when and how to apply specific refactorings to your code.

About the author
About the author

Steve Smith (@ardalis) is an entrepreneur and software developer with a passion for building quality software as effectively as possible.

More from the author
Pair Programming
Beginner
2h 29m
7 Apr 2016
Domain-Driven Design Fundamentals
Intermediate
4h 16m
25 Jun 2014
More courses by Steve Smith
Section Introduction Transcripts
Section Introduction Transcripts

Bloating Code Smells
Welcome back. In this part of the Refactoring Fundamentals course, we're going to continue looking at what wants refactoring, by investigating something the industry has termed Code Smells. Over the years and in various publications, a large number of specific Code Smells have been identified, and we're going to take a look at many of them in this course. Let's review where we are in this course. In the last module, we covered some of the basics of refactoring. Now, we're ready to define Code Smells and to review many examples of Code Smells. We'll refer to some common approaches to correcting them as we go, too. Later, we'll look at some common refactorings and how one can apply them.

Obfuscating Code Smells
Welcome back. As we continue the Refactoring Fundamentals course, we're going to have a look at another group of Code Smells that fall into the Obfuscators category. As always, if you have questions or feedback about the course, you can reach me online via Ardalis. com or on Twitter at @ardalis. We're continuing to explore the wide world of Code Smells in this module. Once we've covered these, we'll look at specific refactorings in more detail. In the last module, we saw that Code Smells can be organized into groups, based on their effect on our code. We're going to jump down to the Obfuscators group in this module, since there are a number of Code Smells that fall into both the Obfuscator and the Bloater categories, that I'd like to talk about next.

Object Orientation Abuser Code Smells
Welcome back. In this module, we're going to quickly cover a few more Code Smells that fall into the Object Orientation Abusers category. We'll be taking a look at more examples of Code Smells in this module, before we move on to looking at refactorings. The Code Smells that fall into this category mainly disrupt the value provided by object-oriented languages, such as inheritance and polymorphism. Obviously, they mainly only apply to object-oriented languages, especially strongly-typed languages like C#. These coding constructs may break polymorphism, and without polymorphism, software systems written in strongly-typed, object-oriented languages tend to have increased repetition and tighter coupling, both of which make the software more expensive to change and maintain.

Code Smells: Change Preventer
Hi there and welcome back. In this module, we're going to quickly review a few more code smells that make it difficult for us to change our code. As we've seen in this course, we've looked at what code smells are and we're continuing to look at examples of code smells. After we're done with that we'll be looking at some common refactorings and then looking at how to apply them. In terms of organizing code smells, we just saw how some coding constructs go against object orientation. The next group of smells we're going to look at is called the change preventers group. These are coding techniques that, once in place in a system, make it difficult for us to change the behavior of the system.

Code Smells: Dispensables
Hi there. In this module we're going to learn about a group of code smells that represent things that our system could pretty well do without. Collectively, these are referred to as dispensables. In this module we're continuing to examine code smells. In the last module, we examined the change preventers. In this one, we're moving on to talk about dispensables. In the next module we'll talk more about couplers.

Code Smells: The Couplers
Welcome back. In this module we'll learn about a group of code smells known as the couplers. No, they're not cupids or matchmakers. Let's get started. As you've probably guessed, we are still working through examples of code smells, though we've also seen quite a number common refactorings at this point as well. In the last module, we examined the dispensables, now we're on to the last of the categories described in the original taxonomy, which is the couplers.

Environment and Testing Code Smells
Hello again, this is Steve Smith. In this last module on Code Smells we're going to take a quick look at some environment smells, and then cover a variety of testing smells that make our tests less effective. Once we've finished with this module, we'll move on to looking specifically at a number of common refactorings. We finished looking at the class code smells from Fowler's book Refactoring, now we're going to check out some environment smells observed by Robert C. Martin, and then some test smells compiled from my own experience, as well as various sources online.

Method Refactorings
Welcome back. In this module we're going to take a look at a number of refactorings that focus on composing methods into small, cohesive, understandable units. Scott Hanselman also returns in this module to provide some insight into some of these refactoring techniques. We've finally come to that point in the course where we're ready to look at specific refactoring examples now that we've seen the code smells that call for them. It's a good idea to keep your methods short, clear, well-named, and for them to be focused on doing one thing. The refactorings in this module, shown at the right, can help you to achieve this goal. There are actually quite a few refactorings related to methods, so we'll look at a few more in the next module as well.

More Method Refactorings
Hi, and welcome back. In this next module we're going to continue looking at refactorings that focus on improving the design of our methods making them clearer, smaller, and easier for us to work with. We're continuing to look at a number of different common refactorings. This is the second module in which we're going to focus on things that make our methods better. Specifically in this module we're going to look at these 12 method refactorings, all of which contribute to making our methods simpler and our use of these methods clearer.

Class and Object Refactorings
In the last couple of modules we've focused on method-level refactorings. In this module we're going to take a look at the larger picture and look at how classes and objects are organized. These refactorings deal with creating and organizing classes, as well as interfaces. We'll be looking at another 11 specific refactorings and how to apply them correctly in this module. Specifically, we're going to examine a number of refactorings that improve the design of our system at the class level. Most of these are pretty simple involving moving a code construct from one class to another. Since these refactorings deal with objects and object-oriented design in addition to the code smells we discussed previously in this course, you may also want to review the SOLID Principles of Object Oriented Design course. These principles can be a great guide as you consider whether a particular refactoring is warranted. In the next module we'll look at how we can organize responsibilities among different classes using inheritance and delegation.

Class Hierarchy Refactorings
Welcome back. In the last module we looked at a number of refactorings that related to the organization of classes. In this module we take another step back and consider refactorings that affect generalization and how our classes relate to their parent and child classes within an inheritance hierarchy. In this module we'll see 10 more individual refactorings and how you should apply them correctly. These 10 refactorings deal with responsibilities between different levels of class hierarchies. Some simply move a single bit of responsibility up our down the hierarchy while later ones change how classes are organized in ways that can greatly affect how clients of your classes interact with them.

Pattern-Based Refactorings
Hi, and welcome back. In this module we're going to wrap up our coverage of specific refactorings by exploring a few that relate to design patterns. We started with method-level refactorings, moved up to classes, and then object hierarchies. Now we're ready to look at design pattern-based techniques that usually encapsulate a number of different refactorings. We'll be looking at 10 refactorings that refer to design patterns in this module. We won't spend much time describing the patterns themselves. For more on that there is already an extensive design patterns library available on Pluralsight. We'll focus here on things to consider before applying the refactoring and of course the steps involved in applying the refactoring correctly. Of course there are many different design patterns. In this module we'll be looking at refactoring techniques that relate to factories, Template Method, null objects, visitors, decorators, commands, strategy, state, and adapter. For more on these or other design patterns, be sure to check out the Design Patterns Library course as well, which covers over 30 different patterns.