31
Finternet-Group The Tao of Laravel Created by / Hung Nguyen @hungnq1989

The tao of laravel

Embed Size (px)

Citation preview

Finternet-GroupThe Tao of LaravelCreated by / Hung Nguyen @hungnq1989

inarticulate/ˌɪnɑːˈtɪkjʊlət/

(adj) unable to express one's ideas or feelings clearly or easily.

The Tao ofLaravel

It was a speech given by Taylor Otwell at Laracon EU 2015

SummaryProgrammers as artisansJiro Dreams of SushiLaravel : Pathway to �ow...Laravel Spark

道 | TAO | DAO | DO

The Pathway or The Principle

The Tao symbol

The dynamic Tao symbol

AgendaS.O.L.I.D princibleDependency injectionIoC containerHow to use IoC container in LaravelRepository & Unit of work pattern

S Single responsibility principle

O Open/closed principle

L Liskov substitution principle

I Interface segregation principle

D Dependency inversion principle

Single responsibility principleA class (method) should have only a single

responsibility (i.e. only one potential change inthe software's speci�cation should be able to

affect the speci�cation of the class)

Open/closed principleSoftware entities … should be open forextension, but closed for modi�cation.

Liskov substitution principleObjects in a program should be replaceable

with instances of their subtypes withoutaltering the correctness of that program.

That was initially introduced by Barbara Liskov in a 1987 conference keynote address entitled Dataabstraction and hierarchy.

Interface segregation principleMany client-speci�c interfaces are better than

one general-purpose interface.

Dependency inversion principleOne should “Depend upon Abstractions. Do

not depend upon concretions.”

DependencyInjection

“Dependency Injection” is a 25-dollar term fora 5-cent concept. […] Dependency injectionmeans giving an object its instance variables.

[…]. (James Shore)

Code time!

It is not new!Inversion of Control Containersand the Dependency Injectionpattern

Martin Fowler 2004

Designing Reusable Classes Johnson andFoote

1988

IoC container

IoC container help to resolve deeply nested classdependencies

CInject

Code time!

Laravel o�cal documenthttps://laravel.com/docs/5.1/container

A deep understanding of the Laravel servicecontainer is essential to building a powerful,

large application, as well as for contributing tothe Laravel core itself.

Repository pattern & Unit ofwork

Repository Mediates between the domain and datamapping layers using a collection-likeinterface for accessing domain objects.

Unit ofWork

Maintains a list of objects affected by abusiness transaction and coordinates thewriting out of changes and the resolution ofconcurrency problems.

Repository patternMinimise duplicate query logic

Easier to cache data

Decouple your application with your persistenceframework

Clean architecture should be independent from framework

Unit of work patternA Unit of Work keeps track of everything you

do during a business transaction that canaffect the database. When you're done, it

�gures out everything that needs to be doneto alter the database as a result of your work.

FIN