DECOUPLING PACKAGES
FROM YOUR FRAMEWORK
@ADAMWATHAN
Slide 2
Slide 2 text
@ADAMWATHAN
▸ Software developer
▸ Host of Full Stack Radio
▸ Former Audio engineer
▸ Competitive powerlifter
Slide 3
Slide 3 text
@ADAMWATHAN
▸ Software developer
▸ Host of Full Stack Radio
▸ Former Audio engineer
▸ Competitive powerlifter
▸ ...Batman?
Slide 4
Slide 4 text
No content
Slide 5
Slide 5 text
No content
Slide 6
Slide 6 text
No content
Slide 7
Slide 7 text
42,288
PACKAGES
Slide 8
Slide 8 text
413,057,365
PACKAGES INSTALLED
Slide 9
Slide 9 text
No content
Slide 10
Slide 10 text
An example...
Slide 11
Slide 11 text
FLUENT FORM BUILDER
Slide 12
Slide 12 text
1. REPOPULATE FORM WITH OLD INPUT IF SUBMISSION FAILS
Slide 13
Slide 13 text
Ditch this...
Slide 14
Slide 14 text
...for just this:
Slide 15
Slide 15 text
2. ABLE TO RETRIEVE ERROR MESSAGES FOR EACH ELEMENT
Slide 16
Slide 16 text
Something like this...
Slide 17
Slide 17 text
#1: RETRIEVING OLD INPUT
Slide 18
Slide 18 text
Probably this sort of thing...
Slide 19
Slide 19 text
In Laravel...
Slide 20
Slide 20 text
In Laravel...
Slide 21
Slide 21 text
So maybe...
Slide 22
Slide 22 text
Nope.
Slide 23
Slide 23 text
Composer.json...
Slide 24
Slide 24 text
The whole truth...
Slide 25
Slide 25 text
What about...
Slide 26
Slide 26 text
No dependencies
!==
NO COUPLING
Slide 27
Slide 27 text
So what's the
answer?
Slide 28
Slide 28 text
Dependency
INJECTION
Slide 29
Slide 29 text
Dependency injection is a software design pattern that
implements inversion of control and allows a program
design to follow the dependency inversion principle. 1
1 http://en.wikipedia.org/wiki/Dependency_injection
Slide 30
Slide 30 text
...Come again?
Slide 31
Slide 31 text
INSTEAD OF AN OBJECT GETTING
IT'S OWN DEPENDENCIES,
WE SHOULD GIVE THEM TO THE
OBJECT OURSELVES.
Slide 32
Slide 32 text
So this...
Slide 33
Slide 33 text
Becomes this...
Slide 34
Slide 34 text
THIS IS BETTER BUT...
Slide 35
Slide 35 text
We're still coupled...
Slide 36
Slide 36 text
DEPEND ON INTERFACES
not implementations
Slide 37
Slide 37 text
Something like...
Slide 38
Slide 38 text
INTERFACES 101
Slide 39
Slide 39 text
INTERFACES 101
▸ Like a contract
Slide 40
Slide 40 text
INTERFACES 101
▸ Like a contract
▸ Describes public API of a role
Slide 41
Slide 41 text
INTERFACES 101
▸ Like a contract
▸ Describes public API of a role
▸ Does not provide any implementation
Slide 42
Slide 42 text
INTERFACES 101
▸ Like a contract
▸ Describes public API of a role
▸ Does not provide any implementation
▸ Great as documentation in a package
Slide 43
Slide 43 text
An implementation...
Slide 44
Slide 44 text
Now instead of this...
Slide 45
Slide 45 text
...we can do this:
Slide 46
Slide 46 text
What about
OTHER
frameworks?
Slide 47
Slide 47 text
What about
NON-FRAMEWORK
applications?
Slide 48
Slide 48 text
Aww yeah
Slide 49
Slide 49 text
#2: ERROR MESSAGES
Slide 50
Slide 50 text
Something like this would be cool...
Slide 51
Slide 51 text
So we need these badboys...
Slide 52
Slide 52 text
Could do this...
Slide 53
Slide 53 text
Let's add it to the interface...
Slide 54
Slide 54 text
...and the implementation:
Slide 55
Slide 55 text
Looks good right?
Slide 56
Slide 56 text
Why a
SESSION?
Slide 57
Slide 57 text
Identify the right
ABSTRACTIONS
Slide 58
Slide 58 text
1.
Somewhere to get
OLD INPUT
Slide 59
Slide 59 text
2.
Somewhere to get
ERRORS
Slide 60
Slide 60 text
Somewhere to get old input...
Slide 61
Slide 61 text
Somewhere to get errors...
Slide 62
Slide 62 text
Somewhere to get old input...
Slide 63
Slide 63 text
Somewhere to get errors...
Slide 64
Slide 64 text
Updated Form Builder...
Slide 65
Slide 65 text
Laravel Old Input...
Slide 66
Slide 66 text
Laravel Error Store...
Slide 67
Slide 67 text
Legacy Old Input...
Slide 68
Slide 68 text
Legacy Error Store...
Slide 69
Slide 69 text
Symfony Old Input...
Slide 70
Slide 70 text
Focus on
ONE JOB
Slide 71
Slide 71 text
Bootstrap prototype...
Slide 72
Slide 72 text
Bootstrap prototype...
Slide 73
Slide 73 text
Bootstrap boilerplate...
Slide 74
Slide 74 text
...reduced to this:
Slide 75
Slide 75 text
Optimize for
COMPOSABILITY
Slide 76
Slide 76 text
BootForms dependencies...
Slide 77
Slide 77 text
Composabilitize!
Slide 78
Slide 78 text
No content
Slide 79
Slide 79 text
YOU DON'T HAVE TO SUPPORT EVERY FRAMEWORK OUT OF THE BOX...
JUST DON'T GET IN THE WAY.