Code Refactoring

Code RefactoringWelcome to the beginning of my Code Refactoring 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.

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. The code used follows the video.

If you like videos like this, it helps to tell Google [googleplusone]

Code Refactoring Code from the Video

Code Refactoring Presentation

What is Refactoring

Refactoring makes code understandable and easy to extend
Refactoring makes it quicker to create complicated systems

Why Should you Refactor

You remove excess code so it is easier to understand & modify
By refactoring code you can better understand others code
You eliminate the having to remember what old code does
You can write code quicker

What Are Bad Smells?

Bad smells are common design problems
Bad design is normally unclear, complicated or duplicated

The Bad Smells

Duplicated Code
Long Methods
Complex Conditional Statements
Primitive Obsession
Indecent Exposure
Solution Sprawl
Alternative Classes with Different Interfaces
Lazy Classes
Large Classes
Switch Statements
Combinatorial Explosions
Oddball Solutions

How Will I Teach Refactoring

Cover a common problem
Cover its solution
Explain design patterns used if needed
Provide the solution in code form
Provide a checklist that can be used to quickly jump to refactoring solutions

Creation Problems

Creation Method
Replace Constructors with Creation Methods
Which constructor should be called?
Wish constructors had descriptive names?
Constructors can’t have the same attribute signatures

Avoid Duplication & Chain Constructors

More constructors, More problems
General purpose constructors save the day

14 thoughts on “Code Refactoring”

    1. I’m technically teaching everything I think some one needs to make great games. After refactoring I’ll cover algorithms and then I’ll move into 2D / 3D graphics. Then I’ll show how to make Java games and then I’ll move them over to Android and teach C and OpenGL with Android.

  1. Hey Derek,
    just wanted to say thanks so much for these vids. I have been doing full time for a few months now, and your tutorials are totally fantastic. Presentation, explanation and content all 5 star!

  2. Derek — I appreciate so much your tutorial. I got a new job to work for a big corporation because I used your method during the job interview. It’s speak less of how to say THANK YOU!

    1. I am very happy that you took the time to tell me that I helped in some way. Thank you very much and I wish you all of the best with your new job πŸ™‚

Leave a Reply

Your email address will not be published. Required fields are marked *