Skip to content

Playing with design patters based on Colin Decarlo "Design Patterns with Laravel" Laracon 2018 talk

Notifications You must be signed in to change notification settings

lsfiege/design-patterns-php

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 

Repository files navigation

Practice design patterns using Laravel examples

  • Adapter
  • Strategy
  • Factory pattern combined with both

Adapter Pattern

  • Integrating 3rd party APIs
  • Depedency Inversion
  • Use the container to swap implementations

Benefits

  • Inverts dependency
  • Ability to swap out implementations
  • Easy to test

Strategy Pattern

  • Clean up branching logic in large cases
  • In-depth refactoring

Benefits

  • Simplifies containing classes by removing conditional logic
  • Allows to defer decisions until runtime
  • Makes the clauses using the strategies "pluggable"

Factory Pattern

  • Identify factories hidding in code
  • Extact class refactor
  • Take advantaje of Auto-wiring Service Container

Primmer

  • Only responsible for creating objects of a specific type
  • Encapsulate decision process for choosing the appropriate concretion

Benefits

  • Moves creation logic out of dependant classes
  • Simple and composable
  • Lean on the Service Container to construct and inject

Based on Colin Decarlo "Design Patterns with Laravel" Laracon 2018 talk

About

Playing with design patters based on Colin Decarlo "Design Patterns with Laravel" Laracon 2018 talk

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages