Skip to content

DanielJudele/Refactoring

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

146 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Refactoring

A collection of techniques which might help developers to refactor the code. The code samples were implemented using JavaScript as a programming language. For testing I used Mocha.

Basic set

  1. Change Function Declaration
  2. Combine Functions into Class
  3. Combine Functions into Transform
  4. Introduce Parameter Object
  5. Rename variable

Encapsulation

  1. Encapsulate Collection
  2. Encapsulate Record
  3. Encapsulate Variable
  4. Hide Delegate
  5. Remove Middle Man
  6. Replace Primitive with Object
  7. Replace Temp with Query
  8. Substitute Algorithm

Extract

  1. Extract Class
  2. Extract Function
  3. Extract Variable

Inline

  1. Inline Class
  2. Inline Function
  3. Inline Variable

Moving Features

  1. Move Function
  2. Move Field
  3. Move statements into Function
  4. Move statements to Callers
  5. Remove Dead Code
  6. Replace Inline Code with Function Call
  7. Replace loop with pipeline
  8. Slide statements
  9. Split loop

Organizing Data

  1. Change Reference to Value
  2. Change Value to Reference
  3. Rename Field
  4. Replace Derived Variable with Query
  5. Split Variable

Simplifying Conditional Logic

  1. Consolidate Conditional Expression
  2. Decompose Conditional
  3. Introduce Special Case
  4. Introduce Assertion
  5. Replace Nested Conditional with Guard Clauses
  6. Replace Conditional with Polymorphism

Split

  1. Split phase

Refactoring APIs

  1. Separate Query from Modifier
  2. Parameterize Function
  3. Preserve Whole Object
  4. Remove Flag Argument
  5. Remove Setting Method
  6. Replace Parameter with Query
  7. Replace Query with Parameter
  8. Replace Constructor with Factory Function
  9. Replace Function with Command
  10. Replace Command with Function

Dealing with Inheritance

  1. Collapse Hierarchy
  2. Extras Superclass
  3. Pull Up Method
  4. Pull Up Field
  5. Push Down Method
  6. Push Down Field
  7. Remove Subclass
  8. Replace Type Code with Subclasses
  9. Replace Subclass with Delegate
  10. Replace Superclass with Delegate

Bibliography

Book: Refactoring Improving the Design of Existing Code by Martin Fowler, with Kent Beck

Online catalog of refactorings, Martin Fowler

About

A collection of techniques which might help developers to refactor the code.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors