SlideShare a Scribd company logo
Change begins with awareness
Appetite comes with testing
“It's a dangerous business, Frodo, going out
your door. You step onto the road, and if you
don't keep your feet, there's no knowing
where you might be swept off to.”
J.R.R. Tolkien, The Lord of the Rings
Change begins with awareness
Defect Cost Increase
Change begins with awareness
Defect Cost Increase
Change begins with awareness
Stress cycle
Change begins with awareness
Testing as...
documentation
Change begins with awareness
Testing as...
instrument for
cooperation
Change begins with awareness
Testing as...
instrument for
open source
cooperation
Change begins with awareness
Pair programming
Change begins with awareness
All begins with...
...a need
Change begins with awareness
And...
“Supporting multiple user classes is not easy at all. It would
make the bundle code far more complex as we would
basically need to change all places interacting with the user
to be able to handle all user classes. I don't really want to
go this way (it will also make it more likely to introduce
bugs).”
...a delusion
Change begins with awareness
But...
In Symfony2, all core classes use the service container,
so it is easy to extend, configure and use any object
...a hope
Change begins with awareness
Service Container
Dependency Injection Container
use AcmeHelloBundleMailer;
$mailer = new Mailer('sendmail');
$mailer->send('info@netmeans.net', ... );
Change begins with awareness
Service Container
Dependency Injection Container
class Mailer
{
private $mailerType;
public function __construct($mailerType)
{
$this->mailerType = $mailerType
}
public function send($to, ...)
{
...
}
}
services:
my_mailer:
class: AcmeHelloBundleMailer
arguments: [sendmail]
Change begins with awareness
Service Container
Dependency Injection Container
class HelloController extends Controller
{
public function sendEmailAction()
{
$mailer = $this->get('my_mailer');
$mailer->send('info@netmeans.net', ... );
}
}
Change begins with awareness
FOSUserBundle
fos_user:
db_driver: orm
firewall_name: main
user_class: AcmeUserBundleEntityUser
Change begins with awareness
FOSUserBundle
fos_user:
db_driver: orm
firewall_name: main
user_class: AcmeUserBundleEntityUser
service:
user_manager: custom_user_manager
Change begins with awareness
So ...
...a solution
We have to create our custom
UserManager that accepts in the
constructor an object that have the
responsibility to discriminate user
types
Change begins with awareness
First of all: test
We start writing some functional
tests to check correct integration
of FOSUserBundle
Change begins with awareness
Custom UserManager
Class UserManager extends FOSUserBundleEntityUserManager
{
protected $userDiscriminator;
public function __construct(..., UserDiscriminator $userDiscriminator)
public function getClass()
{
return $this->userDiscriminator->getClass();
}
}
Change begins with awareness
UserDiscriminator
public function getClass()
{
return 'Acme/UserBundle/Entity/UserOne';
}
Change begins with awareness
From here it's all smooth
With little iterations, we improve
UserManager and UserDiscriminator
with unit and functional tests,
passing from a dirty code to a more
elegant one
Change begins with awareness
NmnMultiUserBundle
fos_user:
db_driver: orm
firewall_name: main
user_class: AcmeUserBundleEntityUser
service:
user_manager: nmn_user_manager
registration:
form:
handler: nmn_user_registration_form_handler
profile:
form:
handler: nmn_user_profile_form_handler
Change begins with awareness
NmnMultiUserBundle
parameters:
nmn_user_discriminator_parameters:
classes:
user_one:
entity: AcmeUserBundleEntityUserOne
registration: AcmeUserBundleFormTypeRegistrationUserOneFormType
profile: AcmeUserBundleFormTypeProfileUserOneFormType
factory:
user_two:
entity: AcmeUserBundleEntityUserTwo
registration: AcmeUserBundleFormTypeRegistrationUserTwoFormType
profile: AcmeUserBundleFormTypeProfileUserTwoFormType
factory:
Change begins with awareness
NmnMultiUserBundle
Ok, it is an hack :)
A lazy way to use for free most of the
functionality of FOSUserBundle ...
... but it is ready to be improved by
anyone.
Change begins with awareness
NmnMultiUserBundle
github.com/netmeansnet/NmnMultiUserBundle
github.com/netmeansnet/NmnMultiUserBundleSandbox
travis-ci.org/#!/netmeansnet/NmnMultiUserBundle
@leonardo_nmn
@euxpom
Change begins with awareness
Some Books
I know this sounds strident and unilateral, but given the record I don't
think the surgeons should have to defend hand-washing, and I don't
think programmers should have to defend TDD
The Clean Coder
A code of Conduct for Professional Programmers
Martin, Robert C.
Some Books
In software development, “perfect” is a verb, not an adjective
Extreme Programming Explained
Embrace Change
Beck, Kent
Change begins with awareness
In XP, testing is as important as programming
Change begins with awareness
Some Books
Building testable applications is Hard
The Grumpy Programmer's Guide To Building
Testable Applications in PHP
Hartjes, Chris
The reason for investing in automated testing is obvious: any bugs you
catch before your application makes it into production cost less in terms
of resources (money, developer time) to fix than fixing it into production

More Related Content

Similar to Appetite comes with testing

Environment Variables in Angular
Environment Variables in AngularEnvironment Variables in Angular
Environment Variables in Angular
Knoldus Inc.
 
Feedback loops between tooling and culture
Feedback loops between tooling and cultureFeedback loops between tooling and culture
Feedback loops between tooling and culture
Chris Winters
 
Legacy is Good
Legacy is GoodLegacy is Good
Legacy is Good
Uberto Barbini
 
Idempotency of commands in distributed systems
Idempotency of commands in distributed systemsIdempotency of commands in distributed systems
Idempotency of commands in distributed systems
Max Małecki
 
Selenium web driver | java
Selenium web driver | javaSelenium web driver | java
Selenium web driver | java
Rajesh Kumar
 
The quest for global design principles (SymfonyLive Berlin 2015)
The quest for global design principles (SymfonyLive Berlin 2015)The quest for global design principles (SymfonyLive Berlin 2015)
The quest for global design principles (SymfonyLive Berlin 2015)
Matthias Noback
 
Slide 1 - Oklahoma State University - Welcome
Slide 1 - Oklahoma State University - WelcomeSlide 1 - Oklahoma State University - Welcome
Slide 1 - Oklahoma State University - Welcomebutest
 
My programming final proj. (1)
My programming final proj. (1)My programming final proj. (1)
My programming final proj. (1)aeden_brines
 
Lesson10 behavioral patterns
Lesson10 behavioral patternsLesson10 behavioral patterns
Lesson10 behavioral patterns
OktJona
 
The quest for global design principles - PHP Benelux 2016
The quest for global design principles - PHP Benelux 2016The quest for global design principles - PHP Benelux 2016
The quest for global design principles - PHP Benelux 2016
Matthias Noback
 
Building Large Scale Javascript Application
Building Large Scale Javascript ApplicationBuilding Large Scale Javascript Application
Building Large Scale Javascript Application
Anis Ahmad
 
Vendredi Tech_ la programmation fonctionnelle.pptx
Vendredi Tech_ la programmation fonctionnelle.pptxVendredi Tech_ la programmation fonctionnelle.pptx
Vendredi Tech_ la programmation fonctionnelle.pptx
Guillaume Saint Etienne
 
ANDROID FDP PPT
ANDROID FDP PPTANDROID FDP PPT
ANDROID FDP PPT
skumartarget
 
Appendices
AppendicesAppendices
Appendicesloisy28
 
How Does A Persuasive Essay Look Like. Kolobbo
How Does A Persuasive Essay Look Like. KolobboHow Does A Persuasive Essay Look Like. Kolobbo
How Does A Persuasive Essay Look Like. Kolobbo
Samantha Jones
 
Transforming Novices into Skilled Accessibility Testers - CSUN 2016
Transforming Novices into Skilled Accessibility Testers - CSUN 2016Transforming Novices into Skilled Accessibility Testers - CSUN 2016
Transforming Novices into Skilled Accessibility Testers - CSUN 2016
Mark Stimson
 
Cucumber presentation
Cucumber presentationCucumber presentation
Cucumber presentation
Akhila B
 
Evolve Your Code
Evolve Your CodeEvolve Your Code
Evolve Your Code
RookieOne
 
Android Activities.pdf
Android Activities.pdfAndroid Activities.pdf
Android Activities.pdf
ssusere71a07
 

Similar to Appetite comes with testing (20)

Environment Variables in Angular
Environment Variables in AngularEnvironment Variables in Angular
Environment Variables in Angular
 
JUNit Presentation
JUNit PresentationJUNit Presentation
JUNit Presentation
 
Feedback loops between tooling and culture
Feedback loops between tooling and cultureFeedback loops between tooling and culture
Feedback loops between tooling and culture
 
Legacy is Good
Legacy is GoodLegacy is Good
Legacy is Good
 
Idempotency of commands in distributed systems
Idempotency of commands in distributed systemsIdempotency of commands in distributed systems
Idempotency of commands in distributed systems
 
Selenium web driver | java
Selenium web driver | javaSelenium web driver | java
Selenium web driver | java
 
The quest for global design principles (SymfonyLive Berlin 2015)
The quest for global design principles (SymfonyLive Berlin 2015)The quest for global design principles (SymfonyLive Berlin 2015)
The quest for global design principles (SymfonyLive Berlin 2015)
 
Slide 1 - Oklahoma State University - Welcome
Slide 1 - Oklahoma State University - WelcomeSlide 1 - Oklahoma State University - Welcome
Slide 1 - Oklahoma State University - Welcome
 
My programming final proj. (1)
My programming final proj. (1)My programming final proj. (1)
My programming final proj. (1)
 
Lesson10 behavioral patterns
Lesson10 behavioral patternsLesson10 behavioral patterns
Lesson10 behavioral patterns
 
The quest for global design principles - PHP Benelux 2016
The quest for global design principles - PHP Benelux 2016The quest for global design principles - PHP Benelux 2016
The quest for global design principles - PHP Benelux 2016
 
Building Large Scale Javascript Application
Building Large Scale Javascript ApplicationBuilding Large Scale Javascript Application
Building Large Scale Javascript Application
 
Vendredi Tech_ la programmation fonctionnelle.pptx
Vendredi Tech_ la programmation fonctionnelle.pptxVendredi Tech_ la programmation fonctionnelle.pptx
Vendredi Tech_ la programmation fonctionnelle.pptx
 
ANDROID FDP PPT
ANDROID FDP PPTANDROID FDP PPT
ANDROID FDP PPT
 
Appendices
AppendicesAppendices
Appendices
 
How Does A Persuasive Essay Look Like. Kolobbo
How Does A Persuasive Essay Look Like. KolobboHow Does A Persuasive Essay Look Like. Kolobbo
How Does A Persuasive Essay Look Like. Kolobbo
 
Transforming Novices into Skilled Accessibility Testers - CSUN 2016
Transforming Novices into Skilled Accessibility Testers - CSUN 2016Transforming Novices into Skilled Accessibility Testers - CSUN 2016
Transforming Novices into Skilled Accessibility Testers - CSUN 2016
 
Cucumber presentation
Cucumber presentationCucumber presentation
Cucumber presentation
 
Evolve Your Code
Evolve Your CodeEvolve Your Code
Evolve Your Code
 
Android Activities.pdf
Android Activities.pdfAndroid Activities.pdf
Android Activities.pdf
 

Recently uploaded

International Workshop on Artificial Intelligence in Software Testing
International Workshop on Artificial Intelligence in Software TestingInternational Workshop on Artificial Intelligence in Software Testing
International Workshop on Artificial Intelligence in Software Testing
Sebastiano Panichella
 
Obesity causes and management and associated medical conditions
Obesity causes and management and associated medical conditionsObesity causes and management and associated medical conditions
Obesity causes and management and associated medical conditions
Faculty of Medicine And Health Sciences
 
Media as a Mind Controlling Strategy In Old and Modern Era
Media as a Mind Controlling Strategy In Old and Modern EraMedia as a Mind Controlling Strategy In Old and Modern Era
Media as a Mind Controlling Strategy In Old and Modern Era
faizulhassanfaiz1670
 
Burning Issue Presentation By Kenmaryon.pdf
Burning Issue Presentation By Kenmaryon.pdfBurning Issue Presentation By Kenmaryon.pdf
Burning Issue Presentation By Kenmaryon.pdf
kkirkland2
 
Announcement of 18th IEEE International Conference on Software Testing, Verif...
Announcement of 18th IEEE International Conference on Software Testing, Verif...Announcement of 18th IEEE International Conference on Software Testing, Verif...
Announcement of 18th IEEE International Conference on Software Testing, Verif...
Sebastiano Panichella
 
2024-05-30_meetup_devops_aix-marseille.pdf
2024-05-30_meetup_devops_aix-marseille.pdf2024-05-30_meetup_devops_aix-marseille.pdf
2024-05-30_meetup_devops_aix-marseille.pdf
Frederic Leger
 
Collapsing Narratives: Exploring Non-Linearity • a micro report by Rosie Wells
Collapsing Narratives: Exploring Non-Linearity • a micro report by Rosie WellsCollapsing Narratives: Exploring Non-Linearity • a micro report by Rosie Wells
Collapsing Narratives: Exploring Non-Linearity • a micro report by Rosie Wells
Rosie Wells
 
Gregory Harris' Civics Presentation.pptx
Gregory Harris' Civics Presentation.pptxGregory Harris' Civics Presentation.pptx
Gregory Harris' Civics Presentation.pptx
gharris9
 
Doctoral Symposium at the 17th IEEE International Conference on Software Test...
Doctoral Symposium at the 17th IEEE International Conference on Software Test...Doctoral Symposium at the 17th IEEE International Conference on Software Test...
Doctoral Symposium at the 17th IEEE International Conference on Software Test...
Sebastiano Panichella
 
María Carolina Martínez - eCommerce Day Colombia 2024
María Carolina Martínez - eCommerce Day Colombia 2024María Carolina Martínez - eCommerce Day Colombia 2024
María Carolina Martínez - eCommerce Day Colombia 2024
eCommerce Institute
 
somanykidsbutsofewfathers-140705000023-phpapp02.pptx
somanykidsbutsofewfathers-140705000023-phpapp02.pptxsomanykidsbutsofewfathers-140705000023-phpapp02.pptx
somanykidsbutsofewfathers-140705000023-phpapp02.pptx
Howard Spence
 
Gregory Harris - Cycle 2 - Civics Presentation
Gregory Harris - Cycle 2 - Civics PresentationGregory Harris - Cycle 2 - Civics Presentation
Gregory Harris - Cycle 2 - Civics Presentation
gharris9
 
Presentatie 4. Jochen Cremer - TU Delft 28 mei 2024
Presentatie 4. Jochen Cremer - TU Delft 28 mei 2024Presentatie 4. Jochen Cremer - TU Delft 28 mei 2024
Presentatie 4. Jochen Cremer - TU Delft 28 mei 2024
Dutch Power
 
Presentatie 8. Joost van der Linde & Daniel Anderton - Eliq 28 mei 2024
Presentatie 8. Joost van der Linde & Daniel Anderton - Eliq 28 mei 2024Presentatie 8. Joost van der Linde & Daniel Anderton - Eliq 28 mei 2024
Presentatie 8. Joost van der Linde & Daniel Anderton - Eliq 28 mei 2024
Dutch Power
 
AWANG ANIQKMALBIN AWANG TAJUDIN B22080004 ASSIGNMENT 2 MPU3193 PHILOSOPHY AND...
AWANG ANIQKMALBIN AWANG TAJUDIN B22080004 ASSIGNMENT 2 MPU3193 PHILOSOPHY AND...AWANG ANIQKMALBIN AWANG TAJUDIN B22080004 ASSIGNMENT 2 MPU3193 PHILOSOPHY AND...
AWANG ANIQKMALBIN AWANG TAJUDIN B22080004 ASSIGNMENT 2 MPU3193 PHILOSOPHY AND...
AwangAniqkmals
 
Supercharge your AI - SSP Industry Breakout Session 2024-v2_1.pdf
Supercharge your AI - SSP Industry Breakout Session 2024-v2_1.pdfSupercharge your AI - SSP Industry Breakout Session 2024-v2_1.pdf
Supercharge your AI - SSP Industry Breakout Session 2024-v2_1.pdf
Access Innovations, Inc.
 
Bitcoin Lightning wallet and tic-tac-toe game XOXO
Bitcoin Lightning wallet and tic-tac-toe game XOXOBitcoin Lightning wallet and tic-tac-toe game XOXO
Bitcoin Lightning wallet and tic-tac-toe game XOXO
Matjaž Lipuš
 
Bonzo subscription_hjjjjjjjj5hhhhhhh_2024.pdf
Bonzo subscription_hjjjjjjjj5hhhhhhh_2024.pdfBonzo subscription_hjjjjjjjj5hhhhhhh_2024.pdf
Bonzo subscription_hjjjjjjjj5hhhhhhh_2024.pdf
khadija278284
 
Tom tresser burning issue.pptx My Burning issue
Tom tresser burning issue.pptx My Burning issueTom tresser burning issue.pptx My Burning issue
Tom tresser burning issue.pptx My Burning issue
amekonnen
 

Recently uploaded (19)

International Workshop on Artificial Intelligence in Software Testing
International Workshop on Artificial Intelligence in Software TestingInternational Workshop on Artificial Intelligence in Software Testing
International Workshop on Artificial Intelligence in Software Testing
 
Obesity causes and management and associated medical conditions
Obesity causes and management and associated medical conditionsObesity causes and management and associated medical conditions
Obesity causes and management and associated medical conditions
 
Media as a Mind Controlling Strategy In Old and Modern Era
Media as a Mind Controlling Strategy In Old and Modern EraMedia as a Mind Controlling Strategy In Old and Modern Era
Media as a Mind Controlling Strategy In Old and Modern Era
 
Burning Issue Presentation By Kenmaryon.pdf
Burning Issue Presentation By Kenmaryon.pdfBurning Issue Presentation By Kenmaryon.pdf
Burning Issue Presentation By Kenmaryon.pdf
 
Announcement of 18th IEEE International Conference on Software Testing, Verif...
Announcement of 18th IEEE International Conference on Software Testing, Verif...Announcement of 18th IEEE International Conference on Software Testing, Verif...
Announcement of 18th IEEE International Conference on Software Testing, Verif...
 
2024-05-30_meetup_devops_aix-marseille.pdf
2024-05-30_meetup_devops_aix-marseille.pdf2024-05-30_meetup_devops_aix-marseille.pdf
2024-05-30_meetup_devops_aix-marseille.pdf
 
Collapsing Narratives: Exploring Non-Linearity • a micro report by Rosie Wells
Collapsing Narratives: Exploring Non-Linearity • a micro report by Rosie WellsCollapsing Narratives: Exploring Non-Linearity • a micro report by Rosie Wells
Collapsing Narratives: Exploring Non-Linearity • a micro report by Rosie Wells
 
Gregory Harris' Civics Presentation.pptx
Gregory Harris' Civics Presentation.pptxGregory Harris' Civics Presentation.pptx
Gregory Harris' Civics Presentation.pptx
 
Doctoral Symposium at the 17th IEEE International Conference on Software Test...
Doctoral Symposium at the 17th IEEE International Conference on Software Test...Doctoral Symposium at the 17th IEEE International Conference on Software Test...
Doctoral Symposium at the 17th IEEE International Conference on Software Test...
 
María Carolina Martínez - eCommerce Day Colombia 2024
María Carolina Martínez - eCommerce Day Colombia 2024María Carolina Martínez - eCommerce Day Colombia 2024
María Carolina Martínez - eCommerce Day Colombia 2024
 
somanykidsbutsofewfathers-140705000023-phpapp02.pptx
somanykidsbutsofewfathers-140705000023-phpapp02.pptxsomanykidsbutsofewfathers-140705000023-phpapp02.pptx
somanykidsbutsofewfathers-140705000023-phpapp02.pptx
 
Gregory Harris - Cycle 2 - Civics Presentation
Gregory Harris - Cycle 2 - Civics PresentationGregory Harris - Cycle 2 - Civics Presentation
Gregory Harris - Cycle 2 - Civics Presentation
 
Presentatie 4. Jochen Cremer - TU Delft 28 mei 2024
Presentatie 4. Jochen Cremer - TU Delft 28 mei 2024Presentatie 4. Jochen Cremer - TU Delft 28 mei 2024
Presentatie 4. Jochen Cremer - TU Delft 28 mei 2024
 
Presentatie 8. Joost van der Linde & Daniel Anderton - Eliq 28 mei 2024
Presentatie 8. Joost van der Linde & Daniel Anderton - Eliq 28 mei 2024Presentatie 8. Joost van der Linde & Daniel Anderton - Eliq 28 mei 2024
Presentatie 8. Joost van der Linde & Daniel Anderton - Eliq 28 mei 2024
 
AWANG ANIQKMALBIN AWANG TAJUDIN B22080004 ASSIGNMENT 2 MPU3193 PHILOSOPHY AND...
AWANG ANIQKMALBIN AWANG TAJUDIN B22080004 ASSIGNMENT 2 MPU3193 PHILOSOPHY AND...AWANG ANIQKMALBIN AWANG TAJUDIN B22080004 ASSIGNMENT 2 MPU3193 PHILOSOPHY AND...
AWANG ANIQKMALBIN AWANG TAJUDIN B22080004 ASSIGNMENT 2 MPU3193 PHILOSOPHY AND...
 
Supercharge your AI - SSP Industry Breakout Session 2024-v2_1.pdf
Supercharge your AI - SSP Industry Breakout Session 2024-v2_1.pdfSupercharge your AI - SSP Industry Breakout Session 2024-v2_1.pdf
Supercharge your AI - SSP Industry Breakout Session 2024-v2_1.pdf
 
Bitcoin Lightning wallet and tic-tac-toe game XOXO
Bitcoin Lightning wallet and tic-tac-toe game XOXOBitcoin Lightning wallet and tic-tac-toe game XOXO
Bitcoin Lightning wallet and tic-tac-toe game XOXO
 
Bonzo subscription_hjjjjjjjj5hhhhhhh_2024.pdf
Bonzo subscription_hjjjjjjjj5hhhhhhh_2024.pdfBonzo subscription_hjjjjjjjj5hhhhhhh_2024.pdf
Bonzo subscription_hjjjjjjjj5hhhhhhh_2024.pdf
 
Tom tresser burning issue.pptx My Burning issue
Tom tresser burning issue.pptx My Burning issueTom tresser burning issue.pptx My Burning issue
Tom tresser burning issue.pptx My Burning issue
 

Appetite comes with testing

  • 1. Change begins with awareness Appetite comes with testing “It's a dangerous business, Frodo, going out your door. You step onto the road, and if you don't keep your feet, there's no knowing where you might be swept off to.” J.R.R. Tolkien, The Lord of the Rings
  • 2. Change begins with awareness Defect Cost Increase
  • 3. Change begins with awareness Defect Cost Increase
  • 4. Change begins with awareness Stress cycle
  • 5. Change begins with awareness Testing as... documentation
  • 6. Change begins with awareness Testing as... instrument for cooperation
  • 7. Change begins with awareness Testing as... instrument for open source cooperation
  • 8. Change begins with awareness Pair programming
  • 9. Change begins with awareness All begins with... ...a need
  • 10. Change begins with awareness And... “Supporting multiple user classes is not easy at all. It would make the bundle code far more complex as we would basically need to change all places interacting with the user to be able to handle all user classes. I don't really want to go this way (it will also make it more likely to introduce bugs).” ...a delusion
  • 11. Change begins with awareness But... In Symfony2, all core classes use the service container, so it is easy to extend, configure and use any object ...a hope
  • 12. Change begins with awareness Service Container Dependency Injection Container use AcmeHelloBundleMailer; $mailer = new Mailer('sendmail'); $mailer->send('info@netmeans.net', ... );
  • 13. Change begins with awareness Service Container Dependency Injection Container class Mailer { private $mailerType; public function __construct($mailerType) { $this->mailerType = $mailerType } public function send($to, ...) { ... } } services: my_mailer: class: AcmeHelloBundleMailer arguments: [sendmail]
  • 14. Change begins with awareness Service Container Dependency Injection Container class HelloController extends Controller { public function sendEmailAction() { $mailer = $this->get('my_mailer'); $mailer->send('info@netmeans.net', ... ); } }
  • 15. Change begins with awareness FOSUserBundle fos_user: db_driver: orm firewall_name: main user_class: AcmeUserBundleEntityUser
  • 16. Change begins with awareness FOSUserBundle fos_user: db_driver: orm firewall_name: main user_class: AcmeUserBundleEntityUser service: user_manager: custom_user_manager
  • 17. Change begins with awareness So ... ...a solution We have to create our custom UserManager that accepts in the constructor an object that have the responsibility to discriminate user types
  • 18. Change begins with awareness First of all: test We start writing some functional tests to check correct integration of FOSUserBundle
  • 19. Change begins with awareness Custom UserManager Class UserManager extends FOSUserBundleEntityUserManager { protected $userDiscriminator; public function __construct(..., UserDiscriminator $userDiscriminator) public function getClass() { return $this->userDiscriminator->getClass(); } }
  • 20. Change begins with awareness UserDiscriminator public function getClass() { return 'Acme/UserBundle/Entity/UserOne'; }
  • 21. Change begins with awareness From here it's all smooth With little iterations, we improve UserManager and UserDiscriminator with unit and functional tests, passing from a dirty code to a more elegant one
  • 22. Change begins with awareness NmnMultiUserBundle fos_user: db_driver: orm firewall_name: main user_class: AcmeUserBundleEntityUser service: user_manager: nmn_user_manager registration: form: handler: nmn_user_registration_form_handler profile: form: handler: nmn_user_profile_form_handler
  • 23. Change begins with awareness NmnMultiUserBundle parameters: nmn_user_discriminator_parameters: classes: user_one: entity: AcmeUserBundleEntityUserOne registration: AcmeUserBundleFormTypeRegistrationUserOneFormType profile: AcmeUserBundleFormTypeProfileUserOneFormType factory: user_two: entity: AcmeUserBundleEntityUserTwo registration: AcmeUserBundleFormTypeRegistrationUserTwoFormType profile: AcmeUserBundleFormTypeProfileUserTwoFormType factory:
  • 24. Change begins with awareness NmnMultiUserBundle Ok, it is an hack :) A lazy way to use for free most of the functionality of FOSUserBundle ... ... but it is ready to be improved by anyone.
  • 25. Change begins with awareness NmnMultiUserBundle github.com/netmeansnet/NmnMultiUserBundle github.com/netmeansnet/NmnMultiUserBundleSandbox travis-ci.org/#!/netmeansnet/NmnMultiUserBundle @leonardo_nmn @euxpom
  • 26. Change begins with awareness Some Books I know this sounds strident and unilateral, but given the record I don't think the surgeons should have to defend hand-washing, and I don't think programmers should have to defend TDD The Clean Coder A code of Conduct for Professional Programmers Martin, Robert C.
  • 27. Some Books In software development, “perfect” is a verb, not an adjective Extreme Programming Explained Embrace Change Beck, Kent Change begins with awareness In XP, testing is as important as programming
  • 28. Change begins with awareness Some Books Building testable applications is Hard The Grumpy Programmer's Guide To Building Testable Applications in PHP Hartjes, Chris The reason for investing in automated testing is obvious: any bugs you catch before your application makes it into production cost less in terms of resources (money, developer time) to fix than fixing it into production