Refactoring with Design Patterns

9 downloads 180790 Views 105KB Size Report
Jan 25, 2014 ... Me. ▷ Working at Qafoo. We promote high quality code with trainings and consulting http://qafoo.com. ▷ Doctrine Developer. ▷ Symfony ...
Refactoring with Design Patterns Qafoo GmbH January 25, 2014

Me I

Working at Qafoo

We promote high quality code with trainings and consulting

http://qafoo.com I

Doctrine Developer

I

Symfony Contributor

I

Twitter @beberlei and @qafoo

Motivation

Neglecting Object-Oriented design leads to underengineering

Motivation

but focusing soley on Design-Pattern leads to overengineering

Refactoring

I

small changes to internal code structure

I

Apply extract method and class again and again

I

See Matthias Verraes talk tomorrow, 16:10

Refactoring and Patterns

Refactoring towards Patterns to avoid both under- and overengineering.

Code

http://qa.fo/phpbnl14

Factory

A factory creates an object for you. I

Getting control over object creation

I

Most important issue for every code-base Actually 4 patterns

I

I I I I

Factory Factory Method Abstract Factory Builder

Facade

A facade provides a simplified interface to a larger body of code. I

Make code reusable (business logic, ..)

I

Integrate third party code (libraries)

I

Avoid hard dependencies on technical details

I

Strongly Related to the Adapter/Bridge patterns

Strategy/Policy Pattern

Strategy allows to exchange algorithms at run time. I

Object-oriented switch statement

I

When calculations are changing frequently

I

Or when they change based on state

I

Construction of strategies often combined with a factory

https://joind.in/10287