Architecture and testabilityListen to your tests on steroids Giorgio Sironi
Who I am
PHP freelancer from 2005, software architect @ Allbus
Writer for DZone[, php|architect]
Bachelor of Computer Engineering @ PoliMi cum laude
This talk
Maintainability, and why testing
Various techniques to favor ease of testing AND maintainability
What is maintainability?
Being ready to change!but not too much
Taking the first bullet
Favored by maintainability
New requirements
Evolving requirements
Iterative development (Agile)
Long-term maintenance
Kinds of tests
Unit tests (1 object)
Functional tests (N objects), end-to-end tests (All objects)
Integration tests (external resources)
Maintainability (1 of 2)
SOLID principles (not all of them)Single responsibility
Open/closed
Dependency Inversion
Maintainability (2 of 2)
Loose couplingHigh cohesionInformation hiding...needed from day 1, like readability and testability
That was the boring part...
Good but...
Good buzzwords, but how do I apply that in practice?
Testing first
Testing first Testable code
Testable code Maintainable code
Maintainable code Happy programmer
Problems with tests
A test is slow?
A test is brittle?
A test is difficult to write?
Solution to problems with tests
Change the design to ease testing (listen to your tests)
Examples of listening to the tests
Small tests => high cohesion
Unit tests => loose coupling
Fast tests => in-memory isolation4 pillars...
1. Dependency injection
No new operators outside of Factories
Easy to change lifecycles and implementations
1. Dependency Injection (without)
Top Related