PHP Refactoring

  • An object is a set of data and processes that computer the data.
  • 2 basic data types: primitive and structured. Represented with associate arrays in PHP.
  • I need to replace data values with objects.
  • Remove all speculative code - use only what you need today.
  • Encapsulation field - setter/getter class. Expose their attributes (potentially problematic).
  • Encapsulate the collection then remove setting methods.
  • Big refactoring - change from procedural to object-oriented code is worth the effort?
  • You can chain functions to make a sentence: $this->order->getCustomer()->makeSilver()
The functions in the book were short - 1 or 2 lines. Very simple. Use abstract and encapsulation.
"...[Create] a small context to cope with when reading, understanding, designing and writing our code."