Navgation: HOME > Graduate study > Content
《Refactoring: Improving the Design of Existing Code》Course Syllabus
Time:2017-04-11 Hit:

《Refactoring: Improving the Design of Existing Code》Course Syllabus

Course Name

Refactoring: Improving the Design of Existing Code


Prof. Chao QI

Course Type

Elective Course

Prerequisite Courses

Java, UML


Computer Science

Learning Method

Mentoring, discussion, and programming


1st semester






1. Objective & Requirement

Your class library works, but could it be better? Refactoring: Improving the Design of Existing Code shows how refactoring can make object-oriented code simpler and easier to maintain. Today refactoring requires considerable design know-how, but once tools become available, all programmers should be able to improve their code using refactoring techniques.

Besides an introduction to refactoring, this handbook provides a catalog of dozens of tips for improving code. The best thing about Refactoring is its remarkably clear presentation, along with excellent nuts-and-bolts advice, from object expert Martin Fowler. The author is also an authority on software patterns and UML, and this experience helps make this a better book, one that should be immediately accessible to any intermediate or advanced object-oriented developer. (Just like patterns, each refactoring tip is presented with a simple name, a "motivation," and examples using Java and UML.)

Early chapters stress the importance of testing in successful refactoring. (When you improve code, you have to test to verify that it still works.) After the discussion on how to detect the "smell" of bad code, readers get to the heart of the book, its catalog of over 70 "refactorings"--tips for better and simpler class design. Each tip is illustrated with "before" and "after" code, along with an explanation. Later chapters provide a quick look at refactoring research.

Like software patterns, refactoring may be an idea whose time has come. This groundbreaking title will surely help bring refactoring to the programming mainstream. With its clear advice on a hot new topic, Refactoring is sure to be essential reading for anyone who writes or maintains object-oriented software.

Topics Covered: Refactoring, improving software code, redesign, design tips, patterns, unit testing, refactoring research, and tools.

2. Topics to be covered

We will explore the concepts and techniques of Refactoring. We will give the encyclopedic coverage of all the related methods in Improving the Design of Existing Code. The following core topics will be discussed in this course.

Chapter 1. Refactoring, a First Example

*The Starting Point

*The First Step in Refactoring

*Decomposing and Redistributing the Statement Method

* Replacing the Conditional Logic on Price Code with Polymorphism

* Final Thoughts

Chapter 2. Principles in Refactoring

*Defining Refactoring

*Why Should You Refactor?

*Refactoring Helps You Find Bugs

*When Should You Refactor?

*What Do I Tell My Manager?

* Problems with Refactoring

* Refactoring and Design

* Refactoring and Performance

*Where Did Refactoring Come From?

Chapter 3. Bad Smells in Code

*Duplicated Code

*Long Method

*Large Class

*Long Parameter List

*Divergent Change

*Shotgun Surgery

*Feature Envy

*Data Clumps

*Primitive Obsession

*Switch Statements

*Parallel Inheritance Hierarchies

*Lazy Class

*Speculative Generality

*Temporary Field

*Message Chains

*Middle Man

*Inappropriate Intimacy

*Alternative Classes with Different Interfaces

*Incomplete Library Class

*Data Class

*Refused Bequest

Chapter 4. Building Tests

*The Value of Self-testing Code

*The JUnit Testing Framework

*Adding More Tests

Chapter 5. Toward a Catalog of Refactorings

*Format of the Refactorings

*Finding References

*How Mature Are These Refactorings?

Chapter 6. Composing Methods

*Extract Method

*Inline Method

*Inline Temp

*Replace Temp with Query

*Introduce Explaining Variable

*Split Temporary Variable

*Remove Assignments to Parameters

*Replace Method with Method Object

*Substitute Algorithm

Chapter 7. Moving Features Between Objects

*Move Method

*Move Field

*Extract Class

*Inline Class

*Hide Delegate

*Remove Middle Man

*Introduce Foreign Method

*Introduce Local Extension

Chapter 8. Organizing Data

*Self Encapsulate Field

*Replace Data Value with Object

*Change Reference to Value

*Replace Array with Object

*Duplicate Observed Data

*Change Unidirectional Association to Bidirectional

*Change Bidirectional Association to Unidirectional

*Replace Magic Number with Symbolic Constant

*Encapsulate Field

*Encapsulate Collection

*Replace Record with Data Class

*Replace Type Code with Class

*Replace Type Code with Subclasses

*Replace Type Code with State/Strategy

*Replace Subclass with Fields

Chapter 9. Simplifying Conditional Expressions 

*Decompose Conditional

*Consolidate Conditional Expression

*Consolidate Duplicate Conditional Fragments

*Replace Nested Conditional with Guard Clauses

*Replace Conditional with Polymorphism

*Introduce Assertion

Chapter 10. Making Method Calls Simpler

*Rename Method

*Add Parameter

*Remove Parameter

*Separate Query from Modifier

*Parameterize Method

*Replace Parameter with Explicit Methods

*Preserve Whole Object

*Replace Parameter with Method

*Introduce Parameter Object

*Remove Setting Method

*Hide Method

*Replace Constructor with Factory Method

*Encapsulate Downcast

*Replace Error Code with Exception

*Replace Exception with Test

Chapter 11. Dealing with Generalization

*Pull Up Field

*Pull Up Method

*Pull Up Constructor Body

*Push Down Method

*Push Down Field

*Extract Subclass Extract Superclass Extract Interface

*Collapse HierarchyForm Template Method

*Replace Inheritance with Delegation

*Replace Delegation with Inheritance

Chapter 12. Big Refactorings

*Tease Apart Inheritance

*Convert Procedural Design to Objects

*Separate Domain from Presentation

*Extract Hierarchy

Chapter 13. Refactoring, Reuse, and Reality

*A Reality Check

*Why Are Developers Reluctant to Refactor Their Programs?

*A Reality Check (Revisited)

*Resources and References for Refactoring

*Implications Regarding Software Reuse and Technology Transfer

*A Final Note


Chapter 14. Refactoring Tools 

*Refactoring with a Tool

*Technical Criteria for a Refactoring Tool

*Practical Criteria for a Refactoring Tool

*Wrap Up

3. Textbook

Martin Fowler, Kent Beck (Contributor), John Brant (Contributor), William Opdyke, don Roberts. Improving the Design of Existing Code, 2010. 

4. Reference Books

[1] Kent.Beck eXtreme Programming eXplained: Embrace Change. Reading, Mass.:

Addison-Wesley, 2000.
[2] FowlerM.Scott.K. UML Distilled, Second Edition: A Brief Guide to the Standard

Object Modeling Language. Reading, Mass.: Addison-Wesley, 2000.

5. Course Evaluation (Tentative)

Assignments                           30%

Course Project                        40%

Exam                     30%