Skip to content

BennyM/Refactor-Examples

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Refactoring

This repository is my starting point to illustrate several refactorings.

The naming of the examples mentioned below is based upon the book: Refactoring by Martin Fowler. An online catalog is also available. Another very good reference is Working Effectively with Legacy Code by Michael Feathers.

Conditionals

Decompose

Extract methods from the condition, then and else part.

Consolidate

Combine conditions with the same result.

Guard Clauses

Conditinal behaviour can make the path unclear.

Strategy

Use a strategy to decide the outcome.

Replace with Polymorphism

Different behaviour based on an identifier (int, enum, type). Encapsulate in class.

Method calls

Seperate query from modifier

Create two methods, one for the query and one for the modification.

Null Objects

Replace null value with null object

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages