Skip to content

Php code based at all the examples of Refactoring book

Notifications You must be signed in to change notification settings

devcorpio/refactoring

Repository files navigation

refactoring

Php code based on the examples of Refactoring book

chapter 01

  • Code without refactor in chapter_01
  • Code refactored in chapter_01_refactor

chapter 02, 03, 04, 05

Amazing theoretical concepts and tips to learn

chapter 06

You can see code in chapter_06-Composing_Methods folder, in that chapter I learned techniques like:

  • extract method
  • inline method
  • inline temp
  • replace temp with query
  • introducing explaining variable
  • split temporary variable
  • remove assignments to parameters
  • replace method with object
  • substitute algorithm

chapter 07

You can see code in chapter_07-moving_features_between_objects folder, in that chapter I learned techniques like:

  • move method
  • move field
  • extract class
  • inline class
  • hide delegate
  • remove middle man
  • introduce foreign method
  • introduce local extension

chapter 08

You can see code in chapter_08-organizing-data folder, in that chapter I learned techniques like:

  • self encapsulated field
  • replace data value with object
  • change reference to value
  • change value to reference
  • replace array with object
  • duplicated 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 09

You can see code in chapter_09-symplifying_conditionals_expressions folder, in that chapter I learned techniques like:

  • decompose conditional
  • consolidate conditional expression
  • consolidate duplicate conditionals fragments
  • remove control flag
  • replace nested conditional with guard clauses (including Joshua Kerievsky Version)
  • replace conditional with polymorphism
  • introduce null object
  • introduce assertion

chapter 10

You can see code in chapter_10-Making_Method_Calls_Simpler folder, in that chapter I learned techniques like:

  • rename method
  • add parameter
  • remove parameter
  • separate query from modifier
  • parameterize method
  • replace parameters with explicited methods
  • preserve whole object
  • replace parameter with method
  • introduce parameters object (range pattern)
  • remove setting method(use initializeField, as a alternative depending of your context)
  • hide method (You can use linter-tools for identify methods that should be privates)
  • replace constructor with factory method
  • encapsulate downcast
  • replace error code with exception
  • replace exception with test

chapter 11

In that section I didn't upload code.

  • pull up field
  • pull up method
  • pull up constructor body
  • push down method
  • push down field
  • extract subclass
  • extract superclass
  • extract interface
  • form template method
  • replace inheritance with delegation
  • replace delegation with inheritance

chapter 12, 13, 14, 15

Amazing theoretical concepts and tips to learn Last chapter was written by Kent Beck

conclusions

I understand why this book is a master piece. I recommend that book to anybody that wanna improve substantially the quality of the code that write.

This book must have PRIORITY over clean code. Having read refactoring book, you can get more profit from clean code book. I have no doubt.

About

Php code based at all the examples of Refactoring book

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages