Refactoring Video Tutorial

Code Refactoring Video TutorialAfter you learn the core syntax of a language many programmers are lost on what to learn next. What do you need to know to create large flexible and extendable applications?

I did my best to teach you how to structure your programs in my Object Oriented Design Tutorial. And, to understand OOD you have to understand UML. Then we walked down the path laid by the programming masters when we looked at Design Patterns. That left me with the final part of writing great code, which is my refactoring video tutorial.

Code refactoring is used to improve code design to make it easier to understand and extend. Writing understandable code will allow others to easily modify it and in the end you’ll also find you write code faster because of code refactoring.

In the following 18 videos I’ll cover code refactoring in detail. Many of the tutorials came from questions you guys sent me. I hope you find it useful.

If you like videos like this it helps to tell Google+

Code Refactoring Code and Articles

Code Refactoring Pt 1: I explain what it is in the video below as well as cover the refactoring bad smells and 2 code refactorings to get you ready for what is coming.

Code Refactoring Pt 2: In this part of my code refactoring tutorial I talk about some basic concepts you have to understand. I’ll cover the process of method extraction. This will help you break down many lines of code into understandable blocks. I’ll also cover when not to extract methods and how to handle temporary and local variables.

Code Refactoring Pt 3: In this part of the code refactoring tutorial, I show you examples of how you can make your code more understandable using something called an Explaining Variable. We also explore many short cuts people take when writing code that will cause many problems later.

Code Refactoring Pt 4: In this video, we’ll cover converting simple types into class objects. We’ll also look at how to move fields and methods into other classes and a bunch of tricks to get the most out of that. I also show a few of the many ways Eclipse can help you write code quicker.

Code Refactoring Pt 5: In this part of the code refactoring tutorial, I will show you how to replace a constructor with a factory method in 2 code examples.

I also received a challenge from one of you guys that I will solve. The challenge involves how to create a singleton factory method. It sounds more complicated than it is, but by watching this you’ll learn a lot.

Code Refactoring Pt 6: In this part of the Code Refactoring tutorial I’ll focus on conditionals. Conditional statements can very often make your code very hard to read.

Here we’ll clean up conditional statements by extracting them into methods. We’ll look at how important naming can be to writing understandable code. We’ll take a look at guard clauses and when to use them. Then we’ll see how polymorphism can eliminate conditionals all together.

Code Refactoring Pt 7: We’ll explore how the strategy pattern can be used to eliminate conditionals during code refactoring. We’ll also see how it can make your code more dynamic and flexible. It is a wonderful pattern!

Code Refactoring Pt 8: I’ll show you how to eliminate duplicate code using the template method pattern. When objects perform similar steps in the same order, that is a sign that a template method is needed. To use it implement the similar code in a template method and allow subclasses to override the behavior that varies.

Code Refactoring Pt 9: I will cover how to turn an implied tree structure into a composite pattern.

What do you do when you want to model a tree structure? You can either list the info as primitives and then search through them for what you want or you can create objects that represent each level of the tree with the composite pattern.

Code Refactoring Pt 10: In this part of the code refactoring tutorial I’m going to revisit the Builder Design Pattern for a couple of reasons. First, I receive a bunch of questions about it. Secondly, in the next tutorial I’ll show you how to build composites, which were covered in the last part of the code refactoring tutorial, with the builder pattern. The builder pattern allows you to build complex objects in a series of steps.

Code Refactoring Pt 11: One of you guys sent me a request to explain the chapter in Refactoring to Patterns titled Encapsulate Composite with Builder. We will build a table structure (composite) using the Builder design pattern.

Code Refactoring Pt 12: I’ll show you how to eliminate large Accumulation Methods by Extracting Methods and Using a Collecting Parameter. It sounds complicated but it isn’t!

This tutorial will show you another way to make your code more readable. It will also introduce you to a few jargon terms you will need to know for the future.

Code Refactoring Pt 13: I’ll show you how to replace conditionals with the command pattern. I’m also going to do more though.

I’ll also review what the command pattern is. I’ll give an example of when you should use it. We’ll look at how to add flexibility with it.

Code Refactoring Pt 14: I’ll show you how and when to use the Adapter Design Pattern. With the adapter pattern we can create a new class without disturbing any other code. On top of that adapters make it easier to swap in code at runtime. They also allow you to communicate with code using method names that make sense to you.

Code Refactoring Pt 15: We’ll look at how to replace a primitive type with a class. Type safety is very important! So, what we want to do is to eliminate all operations on values that are not of the appropriate data type by protecting the program from bad input. One way we can do this is by replacing primitive types with classes.

Code Refactoring Pt 16: When new features are needed it is a bad idea to add new code to older classes. This makes compact easy to understand classes complicated because they break the Single responsibility principle. I’ll show you here how the decorator design pattern instead places each special case behavior (Embellishment) into its own class.

Code Refactoring Pt 17: This tutorial is all about the Visitor Design Pattern. You use the visitor design pattern when you want to perform a similar calculation on many different objects. It seems to confuse people, but I hope to solve that here. If you understand the concept of method overloading and the passing of objects back and forth for data access I don’t think you’ll have a problem.

Code Refactoring Pt 18: I’ll cover the Abstract Factory Pattern again to make sure you understand it. It is often considered a hard to understand pattern, but I’m sure you’ll get it after this video.

4 Responses to “Refactoring Video Tutorial”

  1. Sid Rajan says:

    In what order should we watch your Java/Design Patterns/UML/Object Oriented Design/Code Refactoring/Data Structures and Algorithms tutorials? Thanks a lot for posting quality content for free. It is very much appreciated.

    • Derek Banas says:

      You’re very welcome 🙂 I’m glad they are helping. I’d watch them in this order: Java, UML, Object Oriented Design, Design Patterns and then Refactoring. You could flip the refactoring and design patterns without any problem. Algorithms and Data Structures will start this week

  2. Lucas says:

    Hi Derek,

    Thanks for the new material! It’s getting more and more difficult to keep up with the stuff you post on the website. One thing is to watch the videos, the other and more difficult is to learn everything… Can’t wait to see the tutorials on algorithms though! I’m very curious how you are going to explain them and how deep you are going to dive into the subject.


    • Derek Banas says:

      You’re very welcome 🙂 I will try to upload a new algorithm tutorial tonight. I’m doing my best to make everything more interactive. I’ve been working on android apps that will allow people to work on the code as they watch the video and then answer questions to re-enforce the topics. I’m constantly trying to improve. I’m glad you like them

Leave a Reply

Your email address will not be published.